_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q264900
BizDataObj_Lite._run_search
test
protected function _run_search($limit = null) { // get database connection $db = $this->getDBConnection("READ"); $querySQL = $this->getSQLHelper()->buildQuerySQL($this); $this->_fetch4countQuery = $querySQL; if ($limit && count($limit) > 0 && $limit['count'] > 0) { $sql = $db->limit($querySQL, $limit['count'], $limit['offset']); } else { $sql = $querySQL; } try { if ($this->cacheLifeTime > 0) { $cache_id = md5($this->objectName . $sql . serialize($bindValues)); //try to process cache service. $cacheSvc = Openbizx::getService(CACHE_SERVICE, 1); $cacheSvc->init($this->objectName, $this->cacheLifeTime); if ($cacheSvc->test($cache_id)) { //Openbizx::$app->getLog()->log(LOG_DEBUG, "DATAOBJ", "Cache Hit. Query Sql = ".$sql); $resultSetArray = $cacheSvc->load($cache_id); } else { Openbizx::$app->getLog()->log(LOG_DEBUG, "DATAOBJ", "Query Sql = " . $sql); $resultSet = $db->query($sql);
php
{ "resource": "" }
q264901
BizDataObj_Lite._getNumberRecords
test
private function _getNumberRecords($db, $sql) { $has_subquery = false; if (preg_match("/\(\s*?SELECT\s*?.+\)/si", $sql)) { $has_subquery = true; } if (preg_match("/^\s*SELECT\s+DISTINCT/is", $sql) || preg_match('/\s+GROUP\s+BY\s+/is', $sql)) { // ok, has SELECT DISTINCT or GROUP BY so see if we can use a table alias $rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is', '', $sql); $rewritesql = "SELECT COUNT(*) FROM ($rewritesql) _TABLE_ALIAS_"; } elseif ($has_subquery == false) { // now replace SELECT ... FROM with SELECT COUNT(*) FROM $rewritesql = preg_replace('/\s*?SELECT\s.*?\s+FROM\s/is', 'SELECT COUNT(*) FROM ', $sql); // Because count(*) and 'order by' fails with mssql, access and postgresql. // Also a good speedup optimization - skips sorting! $rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is', '', $rewritesql); } else { $rewritesql = $sql; } try { if ($this->cacheLifeTime > 0) {
php
{ "resource": "" }
q264902
BizDataObj_Lite._fetch_record
test
protected function _fetch_record(&$resultSet) { if (!is_array($resultSet)) { return null; } $sqlArr = current($resultSet); if ($sqlArr) { $this->currentRecord = $this->bizRecord->convertSqlArrToRecArr($sqlArr); $this->currentRecord = $this->bizRecord->getRecordArr($sqlArr);
php
{ "resource": "" }
q264903
InputElement.addSCKeyScript
test
protected function addSCKeyScript() { $keyMap = $this->getSCKeyFuncMap(); if (count($keyMap) == 0) { return ""; } Openbizx::$app->getClientProxy()->appendScripts("shortcut", "shortcut.js"); $str = "<script>\n"; $formObj = $this->getFormObj();
php
{ "resource": "" }
q264904
Application.config
test
public function config(string $key, $default = null) {
php
{ "resource": "" }
q264905
Application.bootstrap
test
public function bootstrap(): void { foreach( $this->config('bootstrap', []) as $file ){ $bootstrap =
php
{ "resource": "" }
q264906
authService.authDBUser
test
protected function authDBUser($userName, $password) { $boAuth = Openbizx::getObject($this->authticationDataObj); if (!$boAuth) return false; $searchRule = "[login]='$userName'"; $recordList = array(); $boAuth->fetchRecords($searchRule, $recordList, 1); $encType = $recordList[0]["enctype"];
php
{ "resource": "" }
q264907
FileWrapper.setRequest
test
protected function setRequest($request): void { if (is_null($this->path)) { throw \AWonderPHP\FileWrapper\NullPropertyException::propertyIsNull('path'); } if (! is_null($request)) { if (! is_string($request)) { throw \AWonderPHP\FileWrapper\TypeErrorException::requestWrongType($request); }
php
{ "resource": "" }
q264908
FileWrapper.setMaxAge
test
protected function setMaxAge($maxage): void { $now = time(); if (is_int($maxage)) { if ($maxage > $now) { $this->maxage = $maxage - $now; return; } if ($maxage >= 0) { $this->maxage = $maxage; return; } throw \AWonderPHP\FileWrapper\InvalidArgumentException::negativeMaxAge(); } if ($maxage instanceof \DateInterval) { $dt = new \DateTime(); $dt->add($maxage); $ts = $dt->getTimestamp(); $seconds = $ts - $now; if ($seconds >= 0) { $this->maxage = $seconds; return; } throw \AWonderPHP\FileWrapper\InvalidArgumentException::negativeMaxAge(); } if (! is_string($maxage)) { throw
php
{ "resource": "" }
q264909
FileWrapper.mimeTypoFix
test
protected function mimeTypoFix($input): string { if (is_null($this->path)) { throw \AWonderPHP\FileWrapper\NullPropertyException::propertyIsNull('path'); } $input = trim($input); $mime = $input; switch ($input) { case 'application/font-woff': $mime = 'font/woff'; break; case 'audio/m4a': $mime = 'audio/mp4'; break; case 'audio/matroska': $mime = 'audio/x-matroska'; break; case 'audio/mp3': $mime = 'audio/mpeg'; break; case 'audio/x-aiff': $mime = 'audio/aiff'; break; case 'audio/wav': $mime = 'audio/x-wav'; break; case 'audio/x-m4a': $mime = 'audio/mp4'; break; case 'audio/x-matroska': $arr = explode('.', $this->path); $ext = strtolower(end($arr)); switch ($ext) { case 'weba': $mime = 'audio/webm'; break; } break; case 'image/jpg': $mime = 'image/jpeg';
php
{ "resource": "" }
q264910
FileWrapper.validMimeType
test
protected function validMimeType($input): void { if (is_null($this->path)) { throw \AWonderPHP\FileWrapper\NullPropertyException::propertyIsNull('path'); } if (! is_null($input)) { if (! is_string($input)) { throw \AWonderPHP\FileWrapper\TypeErrorException::mimeWrongType($input); } $input = trim(strtolower($input)); try { $input = $this->mimeTypoFix($input); } catch (\ErrorException $e) { error_log($e->getMessage()); $this->internalError = true; return; } if (in_array($input, $this->validMime)) { $this->mime = $input; return; } } // do what we can if ($input == "application/octet-stream") { $input = null; } $error = false; if (! is_null($input)) { $arr = explode('/', $input); if (count($arr) != 2) { $error = true; } elseif (! in_array($arr[0], array('application', 'audio', 'font', 'image', 'multipart',
php
{ "resource": "" }
q264911
FileWrapper.textCheck
test
protected function textCheck(): void { if (is_null($this->mime)) { throw \AWonderPHP\FileWrapper\NullPropertyException::propertyIsNull('mime'); } $test = substr($this->mime, 0, 5);
php
{ "resource": "" }
q264912
FileWrapper.checkFullFile
test
protected function checkFullFile(): void { if (is_null($this->filesize)) { throw \AWonderPHP\FileWrapper\NullPropertyException::propertyIsNull('filesize'); } $this->end = $this->filesize - 1; $this->total = $this->filesize; if ($this->istext) { return; } if ($this->filesize > $this->chunksize) { $this->ranges = 'bytes'; if (isset($_SERVER['HTTP_RANGE'])) { list($size_unit, $range_orig) = explode('=', $_SERVER['HTTP_RANGE'], 2); if ($size_unit == 'bytes') { $this->fullfile = false; //below causes noise in log, so do w/ if then instead. Not using extra_ranges anyway
php
{ "resource": "" }
q264913
FileWrapper.setFileProperties
test
protected function setFileProperties(): void { if (is_null($this->path)) { throw \AWonderPHP\FileWrapper\NullPropertyException::propertyIsNull('path'); } date_default_timezone_set('UTC'); $this->filesize = filesize($this->path); $this->timestamp = filemtime($this->path); $this->lastmod = preg_replace('/\+0000$/', 'GMT', date('r', $this->timestamp)); $inode = fileinode($this->path); // The f4a24ef etc strings - my understand in that // because of caching proxies, the Etag needs to be // different for different types of transfer encoding // (e.g. brotli, gzip, deflate) or content could be // delivered to a client that the client can not // decompress. // This class assumes only text files will potentially // be further compressed when serving. $etagEnd = 'f4a24ef'; if ($this->istext) { if (ini_get('zlib.output_compression')) { $accept = 'identity'; if ($this->minify) { $etagEnd = '3d'; } else { $etagEnd = '4c'; } if (isset($this->REQHEADERS['accept-encoding'])) { $T = trim(strtolower($this->REQHEADERS['accept-encoding'])); if (strpos($T, 'gzip') !== false) { $accept = 'gzip'; } elseif (strpos($T, 'deflate') !== false) {
php
{ "resource": "" }
q264914
FileWrapper.cacheCheck
test
protected function cacheCheck() { if (is_null($this->etag)) { throw \AWonderPHP\FileWrapper\NullPropertyException::propertyIsNull('etag'); } if (isset($this->REQHEADERS['if-none-match'])) { $reqETAG=trim($this->REQHEADERS['if-none-match'], '\'"'); if (strcmp($reqETAG, $this->etag) == 0) { $this->cacheok=true;
php
{ "resource": "" }
q264915
FileWrapper.readFromFilesystem
test
protected function readFromFilesystem(): void { if (is_null($this->path)) { throw \AWonderPHP\FileWrapper\NullPropertyException::propertyIsNull('path'); } $chunk = $this->chunksize; $sent = 0; $fp = fopen($this->path, 'rb'); fseek($fp, $this->start); while (!feof($fp)) { if (($this->total - $sent) < $chunk) { $chunk = $this->total - $sent;
php
{ "resource": "" }
q264916
FileWrapper.sendContent
test
protected function sendContent(): bool { if (is_null($this->path)) { $this->sendInternalError(); return false; } if (is_null($this->request)) { $this->sendInternalError(); return false; } if (is_null($this->etag)) { $this->sendInternalError(); return false; } if (is_null($this->mime)) { $this->sendInternalError(); return false; } if (is_null($this->filesize)) { $this->sendInternalError(); return false; } //make sure zlib output compression turned off ini_set("zlib.output_compression", "Off"); if ($this->attachment) { header('Content-Description: File Transfer'); header('Content-Disposition: attachment; filename="' . $this->request . '"'); } if ($this->maxage == 0) { header('Cache-Control: must-revalidate'); } else { header('Cache-Control: max-age=' . $this->maxage); } header('Last-Modified: ' . $this->lastmod); header('ETag: "' . $this->etag . '"'); header('Accept-Ranges: ' . $this->ranges); if ($this->fullfile) {
php
{ "resource": "" }
q264917
FileWrapper.cleanSource
test
protected function cleanSource($content): string { if (is_null($this->path)) { throw \AWonderPHP\FileWrapper\NullPropertyException::propertyIsNull('path'); } //nuke BOM when we definitely have UTF8 $bom = pack('H*', 'EFBBBF'); //DOS to UNIX $content = str_replace("\r\n", "\n", $content); //Classic Mac to UNIX $content = str_replace("\r", "\n", $content); if (function_exists('mb_detect_encoding')) { if (mb_detect_encoding($content, 'UTF-8', true)) { $this->charEnc="UTF-8"; $content = preg_replace("/^$bom/", '', $content); } elseif ($ENC = mb_detect_encoding($content, $this->charsetlist, true)) { $this->charEnc=$ENC; if (function_exists('iconv')) { if ($new = iconv($ENC, 'UTF-8', $content)) { $this->charEnc="UTF-8";
php
{ "resource": "" }
q264918
FileWrapper.jsminify
test
protected function jsminify($content): string { $JSqueeze = new \Patchwork\JSqueeze();
php
{ "resource": "" }
q264919
FileWrapper.cssminify
test
protected function cssminify($content): string { $content = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $content); $content = str_replace(': ', ':', $content); $content = str_replace(array("\r\n", "\r", "\n", "\t"), '', $content); $content = preg_replace("/ {2,}/", ' ', $content); $content = str_replace(array('} '), '}', $content); $content = str_replace(array('{ '), '{', $content); $content = str_replace(array('; '), ';', $content);
php
{ "resource": "" }
q264920
FileWrapper.textwordwrap
test
protected function textwordwrap($content): string { $tmp = explode("\n", $content); $currmax = 0; foreach ($tmp as $line) { if (function_exists('mb_strlen')) { $lw = mb_strlen($line); if ($lw === false) { $lw = strlen($line); } } else { $lw = strlen($line); } if ($lw > $currmax) { $currmax = $lw; } } if ($currmax > 120) { $n = count($tmp); for ($i=0; $i<$n; $i++) { if (function_exists('mbWordWrap')) { $tmp[$i] = mbWordWrap($tmp[$i], 80, "\n", true);
php
{ "resource": "" }
q264921
FileWrapper.getTextContent
test
protected function getTextContent(): bool { if (is_null($this->path)) { $this->sendInternalError(); return false; } if (is_null($this->mime)) { $this->sendInternalError(); return false; } $content = file_get_contents($this->path); if ($this->toUTF8) { try { $content = $this->cleanSource($content); } catch (\ErrorException $e) { error_log($e->getMessage()); $this->sendInternalError(); return false; } } if ($this->minify) { switch ($this->mime) { case "application/javascript": $content=$this->jsminify($content); break; case "text/css": $content=$this->cssminify($content); break;
php
{ "resource": "" }
q264922
FileWrapper.serveText
test
protected function serveText(): bool { // move this to a class property in future FIXME $vary = array(); if (is_null($this->request)) { $this->sendInternalError(); return false; } if (is_null($this->etag)) { $this->sendInternalError(); return false; } if ($this->attachment) { header('Content-Description: File Transfer'); header('Content-Disposition: attachment; filename="' . $this->request . '"'); } if ($this->maxage == 0) {
php
{ "resource": "" }
q264923
FileWrapper.setAllowOrigin
test
public function setAllowOrigin($origin): void { $origin = trim($origin); // fixme - send catchable error if origin isn't valid // possibly could check
php
{ "resource": "" }
q264924
FileWrapper.sendfile
test
public function sendfile(): bool { if ($this->internalError) { $this->sendInternalError(); return false; } if ($this->cacheok) { header("HTTP/1.1 304 Not Modified"); return true; } if (is_null($this->path)) { header("HTTP/1.0 404 Not Found"); return false; } if ($this->badrange) {
php
{ "resource": "" }
q264925
AbstractTextingManager.registerProvider
test
public function registerProvider(TextingProviderInterface $provider) { if (!$this->defaultProvider) { $this->defaultProvider = &$provider;
php
{ "resource": "" }
q264926
ExplicitNormalizer.denormalize
test
public function denormalize($data, $class, $format = null, array $context = []) { $reflection = new ReflectionClass($class); $instance = $reflection->newInstanceWithoutConstructor(); foreach ($data as $key => $value) { $property = $reflection->getProperty($key);
php
{ "resource": "" }
q264927
ExplicitNormalizer.supportsDenormalization
test
public function supportsDenormalization($data, $type, $format = null) {
php
{ "resource": "" }
q264928
RulesValidator.validate
test
final public function validate(array $data, $rules, string $type = null) { try { $this->setMessages($rules); } catch (\TypeError $e) { } try { $this->setCustomAttributes($rules); } catch (\TypeError $e) { } try { $validator = app('validator')->make( array_filter($data), $rules->getRules($type), $this->messages,
php
{ "resource": "" }
q264929
RulesValidator.validateModel
test
public function validateModel(Model $model, Validation\Rules $rules, string $type = null) { try { $this->setModel($rules, $model);
php
{ "resource": "" }
q264930
MenuItemTrait.getActionAttribute
test
public function getActionAttribute($value) { switch ($this->type) { case MenuItemContract::TYPE_ROUTE: return trans('menu::menu.type.route');
php
{ "resource": "" }
q264931
MenuItemTrait.getUrlAttribute
test
public function getUrlAttribute($value) { if ($this->hasChildren()) { return MenuItemContract::URL_EMPTY; } switch ($this->type) {
php
{ "resource": "" }
q264932
EasyFormWizard.goNext
test
public function goNext($commit=false) { // call ValidateForm() $recArr = $this->readInputRecord(); $this->setActiveRecord($recArr); try { if ($this->ValidateForm() == false) return; }catch (Openbizx\Validation\Exception $e) { $this->processFormObjError($e->errors);
php
{ "resource": "" }
q264933
EasyFormWizard.skip
test
public function skip() { $viewObj = $this->getWebpageObject(); // get the step if($viewObj->getCurrentStep()){ $step = $viewObj->getCurrentStep(); }else{ $step = $_GET['step'];
php
{ "resource": "" }
q264934
EasyFormWizard.goBack
test
public function goBack() { $recArr = $this->readInputRecord(); $this->setActiveRecord($recArr); $this->activeRecord = $this->readInputRecord(); $viewObj = $this->getWebpageObject(); // get the step if($viewObj->getCurrentStep()){
php
{ "resource": "" }
q264935
EasyFormWizard.doFinish
test
public function doFinish() //- call FinishWizard() by default { // call ValidateForm() $recArr = $this->readInputRecord(); $this->setActiveRecord($recArr); $this->setFormInputs($this->formInputs); try { if ($this->ValidateForm() == false) return; }catch (Openbizx\Validation\Exception $e) { $this->processFormObjError($e->errors);
php
{ "resource": "" }
q264936
EasyFormWizard.cancel
test
public function cancel() { // clean the session record $this->dropSession = true;
php
{ "resource": "" }
q264937
EasyFormWizard.render
test
public function render() { $viewobj = $this->getWebpageObject(); $viewobj->setFormState($this->objectName,
php
{ "resource": "" }
q264938
TOTPKeyGenerator.generate
test
public static function generate($length = null) { if ($length === null) { $length = self::DEFAULT_LENGTH; } $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
php
{ "resource": "" }
q264939
ExpressionUtil.isEmpty
test
public static function isEmpty(callable $callback, Context $context): bool { $policy = $context->setAccessPolicy(Context::ACCESS_POLICY_RETURN_NULL); try { $val = $callback($context); } finally {
php
{ "resource": "" }
q264940
ExpressionUtil.ternaryShortcut
test
public static function ternaryShortcut(callable $a, callable $b, Context $context) { $policy = $context->setAccessPolicy(Context::ACCESS_POLICY_RETURN_NULL); try { $val = $a($context);
php
{ "resource": "" }
q264941
ExpressionUtil.contains
test
public static function contains($container, $val): bool { if (\is_array($container)) { return \in_array($val, $container, true); } if ($container instanceof \Traversable) { foreach ($container as $tmp) {
php
{ "resource": "" }
q264942
MetaIterator.merge
test
public function merge(&$anotherMIObj) { $old_varValue = $this->varValue; $this->varValue = array(); foreach ($anotherMIObj as $key => $value) { if (!$old_varValue[$key]) { $this->varValue[$key] = $value; } else { $this->varValue[$key] = $old_varValue[$key]; } }
php
{ "resource": "" }
q264943
AppFactory.create
test
public static function create( $containerConfig = null, ?RouterInterface $router = null, ?DispatcherInterface $dispatcher = null, ?ResponseInterface $defaultResponse = null ): App { $container = self::buildContainer($containerConfig); $dispatcher = $dispatcher ?: new Dispatcher(); $defaultResponse = $defaultResponse ?: new Response(); $router = $router ?: new Router( [], ($container->has('router.options') ? $container->get('router.options') : []) ); if ($container->has('router.routes') && is_array($container->get('router.routes'))) { $router->addRoutes($container->get('router.routes')); } $container->set(Dispatcher::class, $dispatcher); $container->set(Router::class, $router);
php
{ "resource": "" }
q264944
GenericDocumentManager.dispatch
test
public function dispatch($key, $arguments) { $event = new GenericEvent( $key, $arguments );
php
{ "resource": "" }
q264945
GenericDocumentManager.countByGroup
test
public function countByGroup($fieldGroup, $match = [], $query = null, $sort = null, $limit = null) { $group = [ '_id' => '$'.$fieldGroup, 'count' => [ '$sum' => 1]
php
{ "resource": "" }
q264946
GenericDocumentManager.aggregateGroup
test
public function aggregateGroup($group, $match = [], $query = null, $sort = null, $limit = null) { $query = $this->getDefault('query', $query); $collection = $this->dm->getDocumentCollection($this->document); $pipeline = []; if ($query) { $query = $this->addNativeQuery($this->queryFields, $query); $match = array_merge($match, $query);
php
{ "resource": "" }
q264947
GenericDocumentManager.find
test
public function find($id, array $filters = []) { $qb = $this->dm->createQueryBuilder($this->document); if (count($filters)) {
php
{ "resource": "" }
q264948
GenericDocumentManager.getMongoIds
test
public function getMongoIds($objects) { $ids = []; foreach ($objects as $object) { $ids[] =
php
{ "resource": "" }
q264949
GenericDocumentManager.normalizeDate
test
public function normalizeDate($date) { if ($date instanceof \DateTime) { return $date; }
php
{ "resource": "" }
q264950
WebPage.isInFormRefLibs
test
public function isInFormRefLibs($formName) { if ($this->formRefLibs) { $this->formRefLibs->rewind(); while ($this->formRefLibs->valid()) { $reference = $this->formRefLibs->current(); if ($reference->objectName == $formName) {
php
{ "resource": "" }
q264951
WebPage.render
test
public function render() { if (!$this->allowAccess()) { $accessDenyWebpage = Openbizx::getObject(OPENBIZ_ACCESS_DENIED_WEBPAGE); return $accessDenyWebpage->render(); } $this->initAllForms();
php
{ "resource": "" }
q264952
WebPage.getCurrentPageUrl
test
public function getCurrentPageUrl() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") { $pageURL .= "s"; } $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .=
php
{ "resource": "" }
q264953
WebPage.initAllForms
test
protected function initAllForms() { foreach ($this->formRefs as $formRef) { $formRef->setViewName($this->objectName); $formName = $formRef->objectName;
php
{ "resource": "" }
q264954
PhpSettingCheck.compareIntegers
test
public static function compareIntegers($value, $setting_value) { $okay = false; $actual = self::getIntegerValue($value); $operator = self::getOperator($setting_value); $expected = self::getIntegerValue($setting_value); switch ($operator) { case '>': $okay = $actual > $expected; break; case '>=': $okay = $actual >= $expected; break; case '<': $okay = $actual < $expected; break; case '<=':
php
{ "resource": "" }
q264955
PhpSettingCheck.getIntegerValue
test
public static function getIntegerValue($value) { if (!is_numeric($value)) { // strip excessive whitespace $value = trim($value); // strip comparison operator $value = ltrim($value, '<>!='); // remove the K|M|G suffix if necessary $len = strlen($value); if (!is_numeric($value)) { $quantity = substr($value, 0, $len - 1); // we need this, as PHP sets a memory_limit of 0 if the ini value is 0.25M // another example: 2.75M will be 2M for PHP (e.g. on post_max_size) $quantity = intval($quantity); } else { $quantity = $value; } // get unit if this string represents a byte value $unit = strtolower(substr($value, $len - 1));
php
{ "resource": "" }
q264956
Autoloader.findSourceFiles
test
public static function findSourceFiles(string $path) { $result = array(); $reader = dir($path); while ($file = $reader->read()) { if ($file === '.' || $file === '..') continue; $file = $path . '/' . $file; if (substr($file, -4) === ".php") { $result[] = $file;
php
{ "resource": "" }
q264957
Autoloader.registerNS
test
public function registerNS(string $ns, string $path, $standard = Autoloader::PSR4) { if (!file_exists($path) || !is_dir($path) || !is_readable($path)) throw new \InvalidArgumentException("Path $path is not readable"); if ($standard !== Autoloader::PSR0 && $standard !== Autoloader::PSR4 && !is_callable($standard)) throw new \InvalidArgumentException("Invalid standard: $standard"); // Strip a leading namespace separator $ns = trim($ns, '\\');
php
{ "resource": "" }
q264958
Autoloader.buildCache
test
public function buildCache() { if ($this->cache === null) throw new \LogicException("Cannot build cache without a cache instance"); $this->cache->set('cache_built', false); $this->cache->set('classpaths', array()); $stack = array($this->root_namespace); while (!empty($stack)) { $ref = array_pop($stack); foreach ($ref['loaders'] as $loader) { if ($loader['std'] !== Autoloader::PSR4) throw new \LogicException("Cache builder only works with pure PSR4-based namespaces"); $class_count = 0; $root = $loader['path'] . DIRECTORY_SEPARATOR; $ns = $loader['ns']; $php_files = self::findSourceFiles($loader['path']); foreach ($php_files as $file) {
php
{ "resource": "" }
q264959
Autoloader.findComposerAutoloader
test
public static function findComposerAutoloader() { // Find the Composer Autoloader class using its (generated) name $list = get_declared_classes(); foreach ($list as $cl) if (substr($cl, 0, 18) === "ComposerAutoloader")
php
{ "resource": "" }
q264960
Autoloader.findComposerAutoloaderVendorDir
test
public static function findComposerAutoloaderVendorDir(string $composer_loader_class) { $ref = new \ReflectionClass($composer_loader_class);
php
{ "resource": "" }
q264961
Autoloader.getClassLoaders
test
public function getClassLoaders(string $class) { $parts = explode("\\", $class); $result = array(); $ref = &$this->root_namespace; $sub_ns = ""; foreach ($parts as $part) { foreach ($ref['loaders'] as $loader) $result[] = $loader; if (!isset($ref['sub_ns'][$part])) break; $ref = &$ref['sub_ns'][$part];
php
{ "resource": "" }
q264962
HasAttrWithMiddleware.getMiddlewareOrFallback
test
public function getMiddlewareOrFallback(string $name, $middleMan, $result = null) { // asserts instead of type-hints because this is a trait and another trait uses it. assert($middleMan instanceof MiddlewareDispatcher); if (! $middleMan->groupIsEmpty('getters')) { $result = $middleMan->callGetters($name, $result);
php
{ "resource": "" }
q264963
HasAttrWithMiddleware.setMiddlewareOrFallback
test
public function setMiddlewareOrFallback(string $name, $value, $middleMan, $result = null) { // asserts instead of type-hints because this is a trait and another trait uses it. assert($middleMan instanceof MiddlewareDispatcher); if (! $middleMan->groupIsEmpty('setters')) { $result = $middleMan->callSetters($name, $value, $result);
php
{ "resource": "" }
q264964
Printable.withStringLimit
test
public function withStringLimit(int $strlim): Printable { return
php
{ "resource": "" }
q264965
Printable.withArrayLimit
test
public function withArrayLimit(int $arrlim): Printable { return
php
{ "resource": "" }
q264966
Printable.string
test
private function string(string $value): string { if ($this->callable && is_callable($value)) { return sprintf('function %s()', $value); } return strlen($value) > $this->strlim
php
{ "resource": "" }
q264967
Printable.array
test
private function array(array $value): string { if ($this->callable && is_callable($value)) { $class = ! is_string($value[0]) ? $this->classname($value[0]) : $value[0]; $method = $value[1]; return sprintf('function %s::%s()', $class, $method); } $slice = array_slice($value, 0, $this->arrlim, true);
php
{ "resource": "" }
q264968
Printable.arrayPair
test
private function arrayPair($key, $val): string { $key_str = is_int($key) ? $key : $this->quoted($key);
php
{ "resource": "" }
q264969
Printable.arrayValue
test
private function arrayValue($val): string { return ! is_array($val)
php
{ "resource": "" }
q264970
Printable.object
test
private function object($value): string { $class = $this->classname($value); if ($class == \Closure::class) {
php
{ "resource": "" }
q264971
NewrelicBackgroundTransaction.reject
test
public function reject(RejectEnvelopeEvent $event) { if (!function_exists('newrelic_end_transaction')) {
php
{ "resource": "" }
q264972
LaravelcpServiceProvider.boot
test
public function boot(\Illuminate\Routing\Router $router) { Config::set('auth.model', 'Askedio\Laravelcp\Models\User'); Config::set('auth.password.email', 'lcp::emails.password'); $router->middleware('auth', 'Askedio\Laravelcp\Http\Middleware\Authenticate'); $router->middleware('auth.basic', 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth'); $router->middleware('guest', 'Askedio\Laravelcp\Http\Middleware\RedirectIfAuthenticated'); $router->middleware('role', 'Askedio\Laravelcp\Http\Middleware\VerifyRole'); $router->middleware('permission', 'Askedio\Laravelcp\Http\Middleware\VerifyPermission'); $loader = \Illuminate\Foundation\AliasLoader::getInstance(); $loader->alias('Nav', 'Askedio\Laravelcp\Helpers\NavigationHelper'); $loader->alias('Hook', 'Askedio\Laravelcp\Helpers\HookHelper'); $loader->alias('Search', 'Askedio\Laravelcp\Helpers\SearchHelper'); NavigationHelper::Initialize(); HookHelper::Initialize(); SearchHelper::Initialize(); if (! $this->app->routesAreCached()) { require realpath(__DIR__.'/../Http/routes.php'); } $this->loadTranslationsFrom(realpath(__DIR__.'/../Resources/Lang'), 'lcp'); $this->loadViewsFrom(realpath(__DIR__.'/../Resources/Views'), 'lcp'); NavigationHelper::Add(['nav' => 'main', 'sort' =>
php
{ "resource": "" }
q264973
ViewRenderer.render
test
static public function render($webpage) { $tplEngine = $webpage->templateEngine; $tplAttributes = ViewRenderer::buildTemplateAttributes($webpage); ob_start(); if ($tplEngine == "Smarty" || $tplEngine == null) { ViewRenderer::renderSmarty($webpage, $tplAttributes); } else { ViewRenderer::renderPHP($webpage, $tplAttributes);
php
{ "resource": "" }
q264974
ViewRenderer.renderSmarty
test
static protected function renderSmarty($webpage, $tplAttributes = Array()) { $smarty = TemplateHelper::getSmartyTemplate(); $viewOutput = $webpage->outputAttrs(); foreach ($viewOutput as $k => $v) { $smarty->assign($k, $v); } // render the formobj attributes $smarty->assign("view", $viewOutput); //Translate Array of template variables to \Zend template object foreach ($tplAttributes as $key => $value) { $smarty->assign($key, $value); } self::registerSmartyPlugin($smarty);
php
{ "resource": "" }
q264975
ViewRenderer.renderPHP
test
static protected function renderPHP($viewObj, $tplAttributes = Array()) { $view = TemplateHelper::getZendTemplate(); $tplFile = TemplateHelper::getTplFileWithPath($viewObj->templateFile, $viewObj->package); $view->addScriptPath(dirname($tplFile)); //Translate Array of template variables to \Zend template object foreach ($tplAttributes as $key => $value) { if ($value == NULL) { $view->$key = ''; } else
php
{ "resource": "" }
q264976
ViewRenderer.setHeaders
test
static protected function setHeaders($viewObj) { // get the cache attribute // if cache = browser, set the cache control in headers header('Pragma:',
php
{ "resource": "" }
q264977
CommentFactory.create
test
public function create(IssueInterface $issue, UserInterface $user) { $comment = new $this->className(); return $comment
php
{ "resource": "" }
q264978
Router.listDir
test
public static function listDir(string $dir, bool $recursive = true) { $contents = array(); $subdirs = array(); $reader = dir($dir); while ($entry = $reader->read()) { if ($entry === "." || $entry === "..") continue; $entry = $dir . DIRECTORY_SEPARATOR . $entry; if (substr($entry, -4) === ".php") { $contents[] = $entry; } elseif (is_dir($entry) && $recursive) { $subdirs = array_merge($subdirs, self::listDir($entry)); } } // Sort the direct contents of the directory so that index.php comes first usort($contents, function ($a, $b) { $sla = strlen($a); $slb = strlen($b); //
php
{ "resource": "" }
q264979
Router.sortModules
test
protected function sortModules() { parent::sortModules(); if ($this->root !== null && $this->root_search_path !== $this->search_path) {
php
{ "resource": "" }
q264980
Router.getRoutes
test
public function getRoutes() { if (!$this->sorted) $this->sortModules(); $cache = $this->getCachedData(); if ($cache !== null && $this->root === null) { $root = $cache->get('data'); if ($root instanceof Route) { $this->root = $root; $this->root_search_path = $cache->get('search_path'); } } if ($this->root !== null) return $this->root; $this->root = new Route('/', 0); $this->root_search_path = $this->search_path; foreach ($this->search_path as $module => $info) { $app_path = $info['path']; $files = self::listDir($app_path); foreach ($files as $path) { $file = str_replace($app_path, "", $path); $parts = array_filter(explode("/", $file)); $ptr = $this->root; $cnt = 0; $l = count($parts); foreach ($parts as $part) { $last = $cnt === $l - 1; if ($last) { if ($part === "index.php") { // Only store if empty - $ptr->addApp($path, '', $module); }
php
{ "resource": "" }
q264981
HTMLMenus.renderMenuItems
test
protected function renderMenuItems(&$menuItemArray) { $sHTML = ""; if (isset($menuItemArray["ATTRIBUTES"])) { $sHTML .= $this->renderSingleMenuItem($menuItemArray);
php
{ "resource": "" }
q264982
HTMLMenus.renderSingleMenuItem
test
protected function renderSingleMenuItem(&$menuItem) { $profile = Openbizx::$app->getUserProfile(); $svcobj = Openbizx::getService(ACCESS_SERVICE); $role = isset($profile["ROLE"]) ? $profile["ROLE"] : null; if ( isset($menuItem["ATTRIBUTES"]['URL']) ) { $url = $menuItem["ATTRIBUTES"]["URL"]; } elseif ( isset($menuItem["ATTRIBUTES"]['VIEW']) ) { $view = $menuItem["ATTRIBUTES"]["VIEW"]; // menuitem's containing VIEW attribute is renderd if access is granted in accessservice.xml // menuitem's are rendered if no definition is found in accessservice.xml (default) if ($svcobj->allowViewAccess($view, $role)) { $url = "javascript:GoToView('" . $view . "')"; } else { return ''; } } $caption = $this->translate($menuItem["ATTRIBUTES"]["CAPTION"]); $target = $menuItem["ATTRIBUTES"]["TARGET"]; $icon = $menuItem["ATTRIBUTES"]["ICON"]; $img = $icon ? "<img src='" . Openbizx::$app->getImageUrl() . "/$icon' class=menu_img> " : "";
php
{ "resource": "" }
q264983
TempFile.writeCsv
test
public function writeCsv(array $data): self { fputcsv($this->handler, $data, $this->delimiter,
php
{ "resource": "" }
q264984
CheckCommand.configure
test
protected function configure() { parent::configure(); $this->setName('check'); $this->addOption( 'config', 'c', InputOption::VALUE_OPTIONAL, 'Path to config file that defines the checks to process.' ); $this->addOption( 'config-handler', null, InputOption::VALUE_OPTIONAL, 'Classname of a custom config handler implementing Environaut\Config\IConfigHandler.' ); $this->addOption( 'cache-location', null, InputOption::VALUE_OPTIONAL, 'File path and name for the cache location to read from. Overrides
php
{ "resource": "" }
q264985
CheckCommand.readConfig
test
protected function readConfig() { $this->config = $this->getConfigHandler()->getConfig(); if ($this->config->has('introduction')) {
php
{ "resource": "" }
q264986
CheckCommand.runChecks
test
protected function runChecks() { $runner_impl = $this->config->getRunnerImplementor(); $runner = new $runner_impl(); if (!$runner instanceof IRunner) { throw new \InvalidArgumentException('The given runner "' . $runner_impl . '" must implement IRunner.'); } $runner->setConfig($this->config); $runner->setCommand($this);
php
{ "resource": "" }
q264987
CheckCommand.runExport
test
protected function runExport() { $export_impl = $this->config->getExportImplementor(); $exporter = new $export_impl(); if (!$exporter instanceof IExport) { throw new \InvalidArgumentException('The given exporter "' . $export_impl . '" must implement IExport.'); } $exporter->setCommand($this);
php
{ "resource": "" }
q264988
CheckCommand.writeCache
test
protected function writeCache($run_was_successful) { $disable_caching = $this->input->getOption('no-cache'); if (!empty($disable_caching)) { return; } $cache_implementor = $this->config->getCacheImplementor(); $cache = new $cache_implementor(); if (!$cache instanceof ICache) { throw new \InvalidArgumentException( 'The given cache class "' . $cache_implementor . '" does not implement ICache.' ); } $cache_params = new Parameters($this->config->get('cache', array())); $cache->setParameters($cache_params); // TODO use something like getenv('ENVIRONAUT_CACHE_DIR')? $cache_location = $this->input->getOption('cache-location'); if (!empty($cache_location)) { $cache->setLocation($cache_location); } $cache->addAll(
php
{ "resource": "" }
q264989
CheckCommand.getLoadedCache
test
protected function getLoadedCache() { if ($this->input->getOption('no-cache')) { $this->readonly_cache = new ReadOnlyCache(); return $this->readonly_cache; } $cache_implementor = $this->config->getReadOnlyCacheImplementor(); $cache = new $cache_implementor(); if (!$cache instanceof IReadOnlyCache) { throw new \InvalidArgumentException( 'The given cache class "' . $cache_implementor . '" does not implement IReadOnlyCache.' ); } $cache_params = new Parameters($this->config->get('cache', array()));
php
{ "resource": "" }
q264990
CheckCommand.initialize
test
protected function initialize(InputInterface $input, OutputInterface $output) { parent::initialize($input, $output); // necessary to register autoloader $config = $input->getOption('config'); if (!empty($config)) { if (!is_readable($config)) { throw new \InvalidArgumentException('Config file path "' . $config . '" is not readable.'); } $this->config_path = $config; if ($input->getOption('verbose')) { $output->writeln('<comment>Config file path specified: ' . $this->config_path . '</comment>'); } } else { $this->config_path = $this->getCurrentWorkingDirectory(); if ($input->getOption('verbose')) { $output->writeln( '<comment>Config file path not specified, using "' . $this->config_path . '" as default lookup location.</comment>' );
php
{ "resource": "" }
q264991
Executor.read
test
public function read($command, $eol = PHP_EOL) {
php
{ "resource": "" }
q264992
Executor.flush
test
public function flush( $command, array $streams, array &$pipes = [], $cwd = null, array $env = null, array $options = []
php
{ "resource": "" }
q264993
ChainsResults.valueIsChainable
test
protected function valueIsChainable($value): bool { $chainableObjects = $this->getChainableObjects(); if (! is_object($value)) { return false; } elseif (in_array('object', $chainableObjects)) { return true; } else {
php
{ "resource": "" }
q264994
InputForm.validateForm
test
protected function validateForm($cleanError = true) { if($cleanError == true) { $this->validateErrors = array(); } $this->dataPanel->rewind(); while($this->dataPanel->valid()) { /* @var $element Element */ $element = $this->dataPanel->current(); if($element->label) { $elementName = $element->label; } else { $elementName = $element->text; } if ($element->checkRequired() === true && ($element->value==null || $element->value == "")) { $errorMessage = $this->getMessage("FORM_ELEMENT_REQUIRED",array($elementName)); $this->validateErrors[$element->objectName] = $errorMessage; //return false; } elseif ($element->value!==null && $element->Validate() == false) { $validateService = Openbizx::getService(VALIDATE_SERVICE); $errorMessage = $this->getMessage("FORM_ELEMENT_INVALID_INPUT",array($elementName,$value,$element->validator));
php
{ "resource": "" }
q264995
GroupSpecificationEq.isSatisfiedBy
test
public function isSatisfiedBy(GroupItem $item) { $field_name = $this->field_name; if(in_array($item->$field_name, $this->val)){
php
{ "resource": "" }
q264996
ClientCredentialsGrant.completeFlow
test
public function completeFlow(ClientEntity $client) { // Validate any scopes that are in the request $scopeParam = $this->server->getRequestHandler()->getParam('scope'); $scopes = $this->validateScopes($scopeParam, $client); // Create a new session $session = new SessionEntity($this->server); $session->setOwner('client', $client->getId()); $session->associateClient($client); // Generate an access token $accessToken = new AccessTokenEntity($this->server); $accessToken->setId(); $accessToken->setExpireTime($this->getAccessTokenTTL() + time()); // Associate scopes with the session and access token foreach ($scopes as $scope) { $session->associateScope($scope); }
php
{ "resource": "" }
q264997
BizField.getSqlValue
test
public function getSqlValue($input = null) { $value = ($input !== null) ? $input : $this->value; if ($value === null) { return ""; } /* if ($this->type != 'Number') {
php
{ "resource": "" }
q264998
BizField.getValue
test
public function getValue($formatted = true) { // need to ensure that value are retrieved from source/cache //if ($this->getDataObj()->CheckDataRetrieved() == false) //$this->getDataObj()->getActiveRecord(); if ($this->_prevValue == $this->value) { return $this->_getValueCache; } //$value = stripcslashes($this->value);
php
{ "resource": "" }
q264999
BizField.saveOldValue
test
public function saveOldValue($value = null) { if ($value) { $this->oldValue = $value;
php
{ "resource": "" }