_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q266300
PEAR_Command_Common.PEAR_Command_Common
test
function PEAR_Command_Common(&$ui, &$config) { parent::PEAR(); $this->config = &$config; $this->ui = &$ui; }
php
{ "resource": "" }
q266301
PEAR_Command_Common.getCommands
test
function getCommands() { $ret = array(); foreach (array_keys($this->commands) as $command) { $ret[$command] = $this->commands[$command]['summary']; } return $ret; }
php
{ "resource": "" }
q266302
PEAR_Command_Common.getShortcuts
test
function getShortcuts() { $ret = array(); foreach (array_keys($this->commands) as $command) { if (isset($this->commands[$command]['shortcut'])) { $ret[$this->commands[$command]['shortcut']] = $command; } } return $ret; }
php
{ "resource": "" }
q266303
PEAR_Command_Common.getHelp
test
function getHelp($command) { $config = &PEAR_Config::singleton(); if (!isset($this->commands[$command])) { return "No such command \"$command\""; } $help = null; if (isset($this->commands[$command]['doc'])) { $help = $this->commands[$command]['doc']; } if (empty($help)) { // XXX (cox) Fallback to summary if there is no doc (show both?) if (!isset($this->commands[$command]['summary'])) { return "No help for command \"$command\""; } $help = $this->commands[$command]['summary']; } if (preg_match_all('/{config\s+([^\}]+)}/e', $help, $matches)) { foreach($matches[0] as $k => $v) { $help = preg_replace("/$v/", $config->get($matches[1][$k]), $help); } } return array($help, $this->getHelpArgs($command)); }
php
{ "resource": "" }
q266304
PEAR_Command_Common.getHelpArgs
test
function getHelpArgs($command) { if (isset($this->commands[$command]['options']) && count($this->commands[$command]['options'])) { $help = "Options:\n"; foreach ($this->commands[$command]['options'] as $k => $v) { if (isset($v['arg'])) { if ($v['arg'][0] == '(') { $arg = substr($v['arg'], 1, -1); $sapp = " [$arg]"; $lapp = "[=$arg]"; } else { $sapp = " $v[arg]"; $lapp = "=$v[arg]"; } } else { $sapp = $lapp = ""; } if (isset($v['shortopt'])) { $s = $v['shortopt']; $help .= " -$s$sapp, --$k$lapp\n"; } else { $help .= " --$k$lapp\n"; } $p = " "; $doc = rtrim(str_replace("\n", "\n$p", $v['doc'])); $help .= " $doc\n"; } return $help; } return null; }
php
{ "resource": "" }
q266305
Plugin.onPostPackageEvent
test
public function onPostPackageEvent(PackageEvent $event) { $package = $this->getOpenBizPackage($event->getOperation()); if ($package) { // By explicitly setting the package, the onPostCmdEvent() will // process the update automatically. $this->OpenBizPackage = $package; } }
php
{ "resource": "" }
q266306
BaseDBAdapter.compileDSN
test
static public function compileDSN(&$params) { $dsn = ''; if (!isset($params['user'])) $params['user'] = 'root'; if (!isset($params['pass'])) $params['pass'] = null; if (!isset($params['type'])) $params['type'] = 'mysql'; if (!isset($params['host'])) $params['host'] = '127.0.0.1'; if (!empty($params['dsn'])) { $dsn = $params['dsn']; } else { $dsn = $params['type'] . ':host='.$params['host']; } return $dsn; }
php
{ "resource": "" }
q266307
BaseDBAdapter.escape
test
public function escape($value) { if (is_array($value)) { $res = ''; if (count($value) == 0) return 'null'; foreach($value as $val) { $res .= $this->escapeOne($val).','; } $res = substr($res, 0, -1); return $res; } else { return $this->escapeOne($value); } }
php
{ "resource": "" }
q266308
TemplatingViewModule.addTemplateRoot
test
public static function addTemplateRoot( array &$globalConfig, string $directory, string $trim, string $referenceName = '' ) { if (!isset($globalConfig['view'])) { $globalConfig['view'] = []; } if (!isset($globalConfig['view'][self::CONFIG_TEMPLATE_ROOTS])) { $globalConfig['view'][self::CONFIG_TEMPLATE_ROOTS] = []; } $globalConfig['view'][self::CONFIG_TEMPLATE_ROOTS][] = [ 'directory' => $directory, 'trim' => $trim, 'name' => $referenceName, ]; }
php
{ "resource": "" }
q266309
DoctrinePresenceVerifier.getCount
test
public function getCount($collection, $column, $value, $excludeId = null, $idColumn = null, array $extra = []) { $idColumn = $idColumn !== null ? $idColumn : 'id'; $qb = $this->createCountQuery($collection) ->where('o.' . $column . ' = :value') ->setParameter('value', $value); if (!is_null($excludeId) && $excludeId != 'NULL') { $qb->andWhere('o.' . $idColumn .' <> :excludeId') ->setParameter('excludeId', $excludeId); } foreach($extra as $key => $extraValue) { $this->addWhere($qb, $key, $extraValue); } return (int) $qb->getQuery()->getSingleScalarResult(); }
php
{ "resource": "" }
q266310
DoctrinePresenceVerifier.getMultiCount
test
public function getMultiCount($collection, $column, array $values, array $extra = []) { $qb = $this->createCountQuery($collection) ->where('o.', $column . ' IN (:values)') ->setParameter('values', array_values($values)); foreach($extra as $key => $extraValue) { $this->addWhere($qb, $key, $extraValue); } return (int) $qb->getQuery()->getSingleScalarResult(); }
php
{ "resource": "" }
q266311
DoctrinePresenceVerifier.createCountQuery
test
protected function createCountQuery($collection, $alias = 'o') { return $this->getEntityManager()->createQueryBuilder() ->select('COUNT(' . $alias . ')') ->from($collection, $alias); }
php
{ "resource": "" }
q266312
DoctrinePresenceVerifier.getEntityManager
test
protected function getEntityManager() { if($this->entities === null) { $callable = $this->factory; $this->entities = $callable(); } return $this->entities; }
php
{ "resource": "" }
q266313
Url.getCurrentPath
test
protected static function getCurrentPath(RequestApplicationInterface $app, $onlyStaticPart = false) { $route = $app->getRoute(); return $route ? $route->getRoutePath($onlyStaticPart) : null; }
php
{ "resource": "" }
q266314
Container.load
test
public function load($name, array $params = array(), $object_loader = null, $force_overload = false) { $config = $this->get('config')->get($name, \CarteBlanche\App\Config::NOT_FOUND_GRACEFULLY, array()); $factory = \Library\Factory::create() ->factoryName(__CLASS__) ->mustImplement(Kernel::DEPENDENCY_LOADER_INTERFACE) ->defaultNamespace(array( Kernel::DEPENDENCY_LOADER_DEFAULT_NAMESPACE, Kernel::CARTE_BLANCHE_NAMESPACE.Kernel::DEPENDENCY_LOADER_DEFAULT_NAMESPACE )) ->classNameMask(array('%s', '%s'.Kernel::DEPENDENCY_LOADER_SUFFIX)) ->callMethod('load') ; if (!isset($params['config'])) { $params['config'] = $config; } if (!isset($params['options'])) { $params['options'] = $config; } if (!isset($params['container'])) { $params['container'] = $this; } $object = $factory->build(empty($object_loader) ? $name : $object_loader, $params); /* if (empty($object_loader)) { $object_loader = Kernel::DEPENDENCY_LOADER_DEFAULT_NAMESPACE .ucfirst(TextHelper::toCamelCase($name)); if (!class_exists($object_loader)) { $object_loader .= Kernel::DEPENDENCY_LOADER_SUFFIX; } } if (!class_exists($object_loader)) { throw new \RuntimeException( sprintf('Unknown dependency loader for reference "%s"!', $name) ); } elseif (!CodeHelper::impelementsInterface($object_loader, Kernel::DEPENDENCY_LOADER_INTERFACE)) { throw new \DomainException( sprintf('Dependency loader "%s" doesn\'t implement the "%s" interface!', $object_loader, Kernel::DEPENDENCY_LOADER_INTERFACE) ); } $loader = new $object_loader; $config = $this->get('config')->get($name, \CarteBlanche\App\Config::NOT_FOUND_GRACEFULLY, array()); $object = $loader->load($config, $this); */ return $this->set($name, $object, $force_overload); }
php
{ "resource": "" }
q266315
Container.clear
test
public function clear($name) { if (true===$this->instances->isEntry($name)) { $this->instances->setEntry($name, null); } }
php
{ "resource": "" }
q266316
Container.getBundle
test
public function getBundle($name) { if (true===$this->instances->isEntry($name,'bundles')) { return $this->instances->getEntry($name,'bundles'); } return null; }
php
{ "resource": "" }
q266317
Container.setBundle
test
public function setBundle($name = null, $val = null, $force_overload = false) { if (!is_object($val)) { throw new DomainException( sprintf('A bundle entry must be an object (got "%s" for bundle "%s")!', gettype($val), $name) ); } if (!CodeHelper::isClassInstance($val, Kernel::BUNDLE_CLASS)) { throw new DomainException( sprintf('A bundle entry must be a "%s" instance (for "%s")!', Kernel::BUNDLE_CLASS, $name) ); } if (true===$this->instances->isEntry($name, 'bundles') && true!==$force_overload) { throw new InvalidArgumentException( sprintf('You can not over-write a container bundle (for "%s")!', $name) ); } return $this->instances->setEntry($name,$val,'bundles'); }
php
{ "resource": "" }
q266318
Container.clearBundle
test
public function clearBundle($name) { if (true===$this->instances->isEntry($name,'bundles')) { $this->instances->setEntry($name,null,'bundles'); } }
php
{ "resource": "" }
q266319
CacheInvalidationSubscriber.invalidate
test
public function invalidate(EntityManager $em, $entity) { $this->log->info('Invalidating entity of class ' . get_class($entity) . ' with ID ' . $entity->getId()); $this->events->fire('oxygen.entity.cache.invalidated', [$entity]); // if the cache depends on any entities of a given type foreach($this->cacheSettings->get(get_class($entity)) as $entity) { $this->invalidate($em, $this->find($em, $entity)); } // if the cache depends on a specific entity if($entity instanceof CacheInvalidatorInterface) { foreach($entity->getEntitiesToBeInvalidated() as $entity) { $this->invalidate($em, $this->find($em, $entity)); } } }
php
{ "resource": "" }
q266320
PEAR_DependencyDB.assertDepsDB
test
function assertDepsDB() { if (!is_file($this->_depdb)) { $this->rebuildDB(); return; } $depdb = $this->_getDepDB(); // Datatype format has been changed, rebuild the Deps DB if ($depdb['_version'] < $this->_version) { $this->rebuildDB(); } if ($depdb['_version']{0} > $this->_version{0}) { return PEAR::raiseError('Dependency database is version ' . $depdb['_version'] . ', and we are version ' . $this->_version . ', cannot continue'); } }
php
{ "resource": "" }
q266321
PEAR_DependencyDB.getDependentPackageDependencies
test
function getDependentPackageDependencies(&$pkg) { $data = $this->_getDepDB(); if (is_object($pkg)) { $channel = strtolower($pkg->getChannel()); $package = strtolower($pkg->getPackage()); } else { $channel = strtolower($pkg['channel']); $package = strtolower($pkg['package']); } $depend = $this->getDependentPackages($pkg); if (!$depend) { return false; } $dependencies = array(); foreach ($depend as $info) { $temp = $this->getDependencies($info); foreach ($temp as $dep) { if ( isset($dep['dep'], $dep['dep']['channel'], $dep['dep']['name']) && strtolower($dep['dep']['channel']) == $channel && strtolower($dep['dep']['name']) == $package ) { if (!isset($dependencies[$info['channel']])) { $dependencies[$info['channel']] = array(); } if (!isset($dependencies[$info['channel']][$info['package']])) { $dependencies[$info['channel']][$info['package']] = array(); } $dependencies[$info['channel']][$info['package']][] = $dep; } } } return $dependencies; }
php
{ "resource": "" }
q266322
PEAR_DependencyDB.getDependencies
test
function getDependencies(&$pkg) { if (is_object($pkg)) { $channel = strtolower($pkg->getChannel()); $package = strtolower($pkg->getPackage()); } else { $channel = strtolower($pkg['channel']); $package = strtolower($pkg['package']); } $data = $this->_getDepDB(); if (isset($data['dependencies'][$channel][$package])) { return $data['dependencies'][$channel][$package]; } return false; }
php
{ "resource": "" }
q266323
PEAR_DependencyDB.installPackage
test
function installPackage(&$package) { $data = $this->_getDepDB(); unset($this->_cache); $this->_setPackageDeps($data, $package); $this->_writeDepDB($data); }
php
{ "resource": "" }
q266324
PEAR_DependencyDB.uninstallPackage
test
function uninstallPackage(&$pkg) { $data = $this->_getDepDB(); unset($this->_cache); if (is_object($pkg)) { $channel = strtolower($pkg->getChannel()); $package = strtolower($pkg->getPackage()); } else { $channel = strtolower($pkg['channel']); $package = strtolower($pkg['package']); } if (!isset($data['dependencies'][$channel][$package])) { return true; } foreach ($data['dependencies'][$channel][$package] as $dep) { $found = false; $depchannel = isset($dep['dep']['uri']) ? '__uri' : strtolower($dep['dep']['channel']); $depname = strtolower($dep['dep']['name']); if (isset($data['packages'][$depchannel][$depname])) { foreach ($data['packages'][$depchannel][$depname] as $i => $info) { if ($info['channel'] == $channel && $info['package'] == $package) { $found = true; break; } } } if ($found) { unset($data['packages'][$depchannel][$depname][$i]); if (!count($data['packages'][$depchannel][$depname])) { unset($data['packages'][$depchannel][$depname]); if (!count($data['packages'][$depchannel])) { unset($data['packages'][$depchannel]); } } else { $data['packages'][$depchannel][$depname] = array_values($data['packages'][$depchannel][$depname]); } } } unset($data['dependencies'][$channel][$package]); if (!count($data['dependencies'][$channel])) { unset($data['dependencies'][$channel]); } if (!count($data['dependencies'])) { unset($data['dependencies']); } if (!count($data['packages'])) { unset($data['packages']); } $this->_writeDepDB($data); }
php
{ "resource": "" }
q266325
PEAR_DependencyDB.rebuildDB
test
function rebuildDB() { $depdb = array('_version' => $this->_version); if (!$this->hasWriteAccess()) { // allow startup for read-only with older Registry return $depdb; } $packages = $this->_registry->listAllPackages(); if (PEAR::isError($packages)) { return $packages; } foreach ($packages as $channel => $ps) { foreach ($ps as $package) { $package = $this->_registry->getPackage($package, $channel); if (PEAR::isError($package)) { return $package; } $this->_setPackageDeps($depdb, $package); } } $error = $this->_writeDepDB($depdb); if (PEAR::isError($error)) { return $error; } $this->_cache = $depdb; return true; }
php
{ "resource": "" }
q266326
PEAR_DependencyDB._lock
test
function _lock($mode = LOCK_EX) { if (stristr(php_uname(), 'Windows 9')) { return true; } if ($mode != LOCK_UN && is_resource($this->_lockFp)) { // XXX does not check type of lock (LOCK_SH/LOCK_EX) return true; } $open_mode = 'w'; // XXX People reported problems with LOCK_SH and 'w' if ($mode === LOCK_SH) { if (!file_exists($this->_lockfile)) { touch($this->_lockfile); } elseif (!is_file($this->_lockfile)) { return PEAR::raiseError('could not create Dependency lock file, ' . 'it exists and is not a regular file'); } $open_mode = 'r'; } if (!is_resource($this->_lockFp)) { $this->_lockFp = @fopen($this->_lockfile, $open_mode); } if (!is_resource($this->_lockFp)) { return PEAR::raiseError("could not create Dependency lock file" . (isset($php_errormsg) ? ": " . $php_errormsg : "")); } if (!(int)flock($this->_lockFp, $mode)) { switch ($mode) { case LOCK_SH: $str = 'shared'; break; case LOCK_EX: $str = 'exclusive'; break; case LOCK_UN: $str = 'unlock'; break; default: $str = 'unknown'; break; } return PEAR::raiseError("could not acquire $str lock ($this->_lockfile)"); } return true; }
php
{ "resource": "" }
q266327
PEAR_DependencyDB._unlock
test
function _unlock() { $ret = $this->_lock(LOCK_UN); if (is_resource($this->_lockFp)) { fclose($this->_lockFp); } $this->_lockFp = null; return $ret; }
php
{ "resource": "" }
q266328
PEAR_DependencyDB._getDepDB
test
function _getDepDB() { if (!$this->hasWriteAccess()) { return array('_version' => $this->_version); } if (isset($this->_cache)) { return $this->_cache; } if (!$fp = fopen($this->_depdb, 'r')) { $err = PEAR::raiseError("Could not open dependencies file `".$this->_depdb."'"); return $err; } $rt = get_magic_quotes_runtime(); set_magic_quotes_runtime(0); clearstatcache(); fclose($fp); $data = unserialize(file_get_contents($this->_depdb)); set_magic_quotes_runtime($rt); $this->_cache = $data; return $data; }
php
{ "resource": "" }
q266329
PEAR_DependencyDB._writeDepDB
test
function _writeDepDB(&$deps) { if (PEAR::isError($e = $this->_lock(LOCK_EX))) { return $e; } if (!$fp = fopen($this->_depdb, 'wb')) { $this->_unlock(); return PEAR::raiseError("Could not open dependencies file `".$this->_depdb."' for writing"); } $rt = get_magic_quotes_runtime(); set_magic_quotes_runtime(0); fwrite($fp, serialize($deps)); set_magic_quotes_runtime($rt); fclose($fp); $this->_unlock(); $this->_cache = $deps; return true; }
php
{ "resource": "" }
q266330
Theme.autoLoadModules
test
protected function autoLoadModules() { $extDirectory = __DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR; $extDirectories = glob($extDirectory . "*", GLOB_ONLYDIR); foreach ($extDirectories as $directory): if (basename($directory) === "core"): continue; endif; # Get className and classPath $className = substr(basename(glob($directory . "*/Theme*.php")[0]), 0, -4); $classPath = '\\NetLimeTheme\\Extensions\\' . $className; $this->registerModule($className, new $classPath()); endforeach; }
php
{ "resource": "" }
q266331
Theme.registerModule
test
public function registerModule($key, $instance) { do_action("before_theme_module_register"); apply_filters("before_theme_module_init", $key, $instance); $this->modules[$key] = $instance; $this->module($key)->init(); apply_filters("after_theme_module_init", $key, $instance); do_action("after_theme_module_register"); }
php
{ "resource": "" }
q266332
Theme.getContent
test
public function getContent($location) { do_action("before_theme_get_content"); apply_filters("before_theme_get_content", $location); foreach ($this->sections as $section_data): # Skip if section is not in given location if ($section_data[1] !== $location): continue; endif; # Render it $this->renderSection($section_data[0]); endforeach; apply_filters("after_theme_get_content", $location); do_action("after_theme_get_content"); }
php
{ "resource": "" }
q266333
ErrorController.actionError
test
public function actionError(RequestApplicationInterface $app, \Throwable $exception) { return $this->render($app, 'view', [ 'exception' => $exception, 'exceptionName' => $this->getExceptionName($exception), ], true); }
php
{ "resource": "" }
q266334
NativeOutputFormatter.setForeground
test
public function setForeground(FormatForeground $foreground = null): void { if (null === $foreground) { $this->foreground = null; return; } $this->foreground = $foreground->getValue(); }
php
{ "resource": "" }
q266335
NativeOutputFormatter.setBackground
test
public function setBackground(FormatBackground $background = null): void { if (null === $background) { $this->background = null; return; } $this->background = $background->getValue(); }
php
{ "resource": "" }
q266336
NativeOutputFormatter.black
test
public function black(bool $background = null): void { $this->setColor( $background ? FormatBackground::BLACK : FormatForeground::BLACK, $background ); }
php
{ "resource": "" }
q266337
NativeOutputFormatter.red
test
public function red(bool $background = null): void { $this->setColor( $background ? FormatBackground::RED : FormatForeground::RED, $background ); }
php
{ "resource": "" }
q266338
NativeOutputFormatter.green
test
public function green(bool $background = null): void { $this->setColor( $background ? FormatBackground::GREEN : FormatForeground::GREEN, $background ); }
php
{ "resource": "" }
q266339
NativeOutputFormatter.yellow
test
public function yellow(bool $background = null): void { $this->setColor( $background ? FormatBackground::YELLOW : FormatForeground::YELLOW, $background ); }
php
{ "resource": "" }
q266340
NativeOutputFormatter.blue
test
public function blue(bool $background = null): void { $this->setColor( $background ? FormatBackground::BLUE : FormatForeground::BLUE, $background ); }
php
{ "resource": "" }
q266341
NativeOutputFormatter.magenta
test
public function magenta(bool $background = null): void { $this->setColor( $background ? FormatBackground::MAGENTA : FormatForeground::MAGENTA, $background ); }
php
{ "resource": "" }
q266342
NativeOutputFormatter.cyan
test
public function cyan(bool $background = null): void { $this->setColor( $background ? FormatBackground::CYAN : FormatForeground::CYAN, $background ); }
php
{ "resource": "" }
q266343
NativeOutputFormatter.white
test
public function white(bool $background = null): void { $this->setColor( $background ? FormatBackground::WHITE : FormatForeground::WHITE, $background ); }
php
{ "resource": "" }
q266344
NativeOutputFormatter.resetColor
test
public function resetColor(bool $background = null): void { $this->setColor( $background ? FormatBackground::DEFAULT : FormatForeground::DEFAULT, $background ); }
php
{ "resource": "" }
q266345
NativeOutputFormatter.setColor
test
protected function setColor(int $color, bool $background = null): void { if (null !== $background) { $this->background = $color; return; } $this->foreground = $color; }
php
{ "resource": "" }
q266346
NativeOutputFormatter.removeOption
test
public function removeOption(FormatOption $option): void { if ($this->hasOption($option)) { unset($this->options[$option->getValue()]); } }
php
{ "resource": "" }
q266347
NativeOutputFormatter.format
test
public function format(string $message): string { $set = []; $unset = []; // Check if a foreground was specified if (null !== $this->foreground) { $set[] = $this->foreground; $unset[] = FormatForeground::DEFAULT; } // Check if a background was specified if (null !== $this->background) { $set[] = $this->background; $unset[] = FormatBackground::DEFAULT; } // Check if options were specified if (\count($this->options)) { // Iterate through all the options foreach ($this->options as $option) { $set[] = $option; $unset[] = FormatOption::DEFAULT[$option]; } } // No need to format if there's nothing to set if (0 === \count($set)) { return $message; } return sprintf( "\033[%sm%s\033[%sm", implode(';', $set), $message, implode(';', $unset) ); }
php
{ "resource": "" }
q266348
Logger.logCommand
test
public function logCommand($command, $duration, $connection, $error = false) { ++$this->commandCount; if (null !== $this->logger) { $this->commands[] = [ 'cmd' => $command, 'executionMS' => $duration, 'conn' => $connection, 'error' => $error ]; if ($error) { $this->logger->error('Command "' . $command . '" failed (' . $error . ')'); } else { $this->logger->debug('Executing command "' . $command . '"'); } } }
php
{ "resource": "" }
q266349
ServerRequest.getUploadedFileLeaves
test
private static function getUploadedFileLeaves(array $uploaded_files) { $new_file = []; if (isset($uploaded_files['tmp_name']) && !is_array($uploaded_files['tmp_name'])) { $new_file = new UploadedFile( $uploaded_files['name'] ?? null, $uploaded_files['type'] ?? null, $uploaded_files['tmp_name'] ?? null, $uploaded_files['error'] ?? null, $uploaded_files['size'] ?? null, true ); } elseif (isset($uploaded_files['tmp_name'][0])) { foreach ($uploaded_files['tmp_name'] as $key => $value) { $new_file[$key] = new UploadedFile( $uploaded_files['name'][$key] ?? null, $uploaded_files['name'][$key] ?? null, $uploaded_files['tmp_name'][$key] ?? null, $uploaded_files['error'][$key] ?? null, $uploaded_files['size'][$key] ?? null, true ); } } else { foreach (array_keys($uploaded_files['tmp_name']) as $index) { $new_array = array_combine( array_keys($uploaded_files), array_column($uploaded_files, $index) ); $new_file[$index] = static::getUploadedFileLeaves($new_array); } } return $new_file; }
php
{ "resource": "" }
q266350
PEAR_PackageFile_v2.setRawState
test
function setRawState($state) { if (!isset($this->_packageInfo['stability'])) { $this->_packageInfo['stability'] = array(); } $this->_packageInfo['stability']['release'] = $state; }
php
{ "resource": "" }
q266351
PEAR_PackageFile_v2.listPostinstallScripts
test
function listPostinstallScripts() { $filelist = $this->getFilelist(); $contents = $this->getContents(); $contents = $contents['dir']['file']; if (!is_array($contents) || !isset($contents[0])) { $contents = array($contents); } $taskfiles = array(); foreach ($contents as $file) { $atts = $file['attribs']; unset($file['attribs']); if (count($file)) { $taskfiles[$atts['name']] = $file; } } $common = new PEAR_Common; $common->debug = $this->_config->get('verbose'); $this->_scripts = array(); $ret = array(); foreach ($taskfiles as $name => $tasks) { if (!isset($filelist[$name])) { // ignored files will not be in the filelist continue; } $atts = $filelist[$name]; foreach ($tasks as $tag => $raw) { $task = $this->getTask($tag); $task = &new $task($this->_config, $common, PEAR_TASK_INSTALL); if ($task->isScript()) { $ret[] = $filelist[$name]['installed_as']; } } } if (count($ret)) { return $ret; } return false; }
php
{ "resource": "" }
q266352
PEAR_PackageFile_v2.initPostinstallScripts
test
function initPostinstallScripts() { $filelist = $this->getFilelist(); $contents = $this->getContents(); $contents = $contents['dir']['file']; if (!is_array($contents) || !isset($contents[0])) { $contents = array($contents); } $taskfiles = array(); foreach ($contents as $file) { $atts = $file['attribs']; unset($file['attribs']); if (count($file)) { $taskfiles[$atts['name']] = $file; } } $common = new PEAR_Common; $common->debug = $this->_config->get('verbose'); $this->_scripts = array(); foreach ($taskfiles as $name => $tasks) { if (!isset($filelist[$name])) { // file was not installed due to installconditions continue; } $atts = $filelist[$name]; foreach ($tasks as $tag => $raw) { $taskname = $this->getTask($tag); $task = &new $taskname($this->_config, $common, PEAR_TASK_INSTALL); if (!$task->isScript()) { continue; // scripts are only handled after installation } $lastversion = isset($this->_packageInfo['_lastversion']) ? $this->_packageInfo['_lastversion'] : null; $task->init($raw, $atts, $lastversion); $res = $task->startSession($this, $atts['installed_as']); if (!$res) { continue; // skip this file } if (PEAR::isError($res)) { return $res; } $assign = &$task; $this->_scripts[] = &$assign; } } if (count($this->_scripts)) { return true; } return false; }
php
{ "resource": "" }
q266353
PEAR_PackageFile_v2.fromArray
test
function fromArray($pinfo) { unset($pinfo['old']); unset($pinfo['xsdversion']); // If the changelog isn't an array then it was passed in as an empty tag if (isset($pinfo['changelog']) && !is_array($pinfo['changelog'])) { unset($pinfo['changelog']); } $this->_incomplete = false; $this->_packageInfo = $pinfo; }
php
{ "resource": "" }
q266354
PEAR_PackageFile_v2.getFilelist
test
function getFilelist($preserve = false) { if (isset($this->_packageInfo['filelist']) && !$preserve) { return $this->_packageInfo['filelist']; } $this->flattenFilelist(); if ($contents = $this->getContents()) { $ret = array(); if (!isset($contents['dir'])) { return false; } if (!isset($contents['dir']['file'][0])) { $contents['dir']['file'] = array($contents['dir']['file']); } foreach ($contents['dir']['file'] as $file) { $name = $file['attribs']['name']; if (!$preserve) { $file = $file['attribs']; } $ret[$name] = $file; } if (!$preserve) { $this->_packageInfo['filelist'] = $ret; } return $ret; } return false; }
php
{ "resource": "" }
q266355
PEAR_PackageFile_v2.getConfigureOptions
test
function getConfigureOptions() { if ($this->getPackageType() != 'extsrc' && $this->getPackageType() != 'zendextsrc') { return false; } $releases = $this->getReleases(); if (isset($releases[0])) { $releases = $releases[0]; } if (isset($releases['configureoption'])) { if (!isset($releases['configureoption'][0])) { $releases['configureoption'] = array($releases['configureoption']); } for ($i = 0; $i < count($releases['configureoption']); $i++) { $releases['configureoption'][$i] = $releases['configureoption'][$i]['attribs']; } return $releases['configureoption']; } return false; }
php
{ "resource": "" }
q266356
PEAR_PackageFile_v2.isCompatible
test
function isCompatible($pf) { if (!isset($this->_packageInfo['compatible'])) { return false; } if (!isset($this->_packageInfo['channel'])) { return false; } $me = $pf->getVersion(); $compatible = $this->_packageInfo['compatible']; if (!isset($compatible[0])) { $compatible = array($compatible); } $found = false; foreach ($compatible as $info) { if (strtolower($info['name']) == strtolower($pf->getPackage())) { if (strtolower($info['channel']) == strtolower($pf->getChannel())) { $found = true; break; } } } if (!$found) { return false; } if (isset($info['exclude'])) { if (!isset($info['exclude'][0])) { $info['exclude'] = array($info['exclude']); } foreach ($info['exclude'] as $exclude) { if (version_compare($me, $exclude, '==')) { return false; } } } if (version_compare($me, $info['min'], '>=') && version_compare($me, $info['max'], '<=')) { return true; } return false; }
php
{ "resource": "" }
q266357
PEAR_PackageFile_v2.isSubpackage
test
function isSubpackage($p) { $sub = array(); if (isset($this->_packageInfo['dependencies']['required']['subpackage'])) { $sub = $this->_packageInfo['dependencies']['required']['subpackage']; if (!isset($sub[0])) { $sub = array($sub); } } if (isset($this->_packageInfo['dependencies']['optional']['subpackage'])) { $sub1 = $this->_packageInfo['dependencies']['optional']['subpackage']; if (!isset($sub1[0])) { $sub1 = array($sub1); } $sub = array_merge($sub, $sub1); } if (isset($this->_packageInfo['dependencies']['group'])) { $group = $this->_packageInfo['dependencies']['group']; if (!isset($group[0])) { $group = array($group); } foreach ($group as $deps) { if (isset($deps['subpackage'])) { $sub2 = $deps['subpackage']; if (!isset($sub2[0])) { $sub2 = array($sub2); } $sub = array_merge($sub, $sub2); } } } foreach ($sub as $dep) { if (strtolower($dep['name']) == strtolower($p->getPackage())) { if (isset($dep['channel'])) { if (strtolower($dep['channel']) == strtolower($p->getChannel())) { return true; } } else { if ($dep['uri'] == $p->getURI()) { return true; } } } } return false; }
php
{ "resource": "" }
q266358
PEAR_PackageFile_v2.getDependencyGroup
test
function getDependencyGroup($name) { $name = strtolower($name); if (!isset($this->_packageInfo['dependencies']['group'])) { return false; } $groups = $this->_packageInfo['dependencies']['group']; if (!isset($groups[0])) { $groups = array($groups); } foreach ($groups as $group) { if (strtolower($group['attribs']['name']) == $name) { return $group; } } return false; }
php
{ "resource": "" }
q266359
PEAR_PackageFile_v2._ksplice
test
function _ksplice($array, $key, $value, $newkey) { $offset = array_search($key, array_keys($array)); $after = array_slice($array, $offset); $before = array_slice($array, 0, $offset); $before[$newkey] = $value; return array_merge($before, $after); }
php
{ "resource": "" }
q266360
CSDTCollectionsBundle.build
test
public function build(ContainerBuilder $container) { parent::build($container); $container->addCompilerPass(new ManagerCompiler()); $container->addCompilerPass(new HelperCompiler()); }
php
{ "resource": "" }
q266361
Helper.modulo
test
public static function modulo($a, $b) { if (abs($b)>abs($a)) { return $a; } if ($a>0 && $b>0) { return ($a%$b); } return self::getModuloFromEntirePart($a, $b); }
php
{ "resource": "" }
q266362
Helper.getModuloFromEntirePart
test
public static function getModuloFromEntirePart($a, $b) { $div = round($a/$b, 0, (($a/$b)>=0 ? PHP_ROUND_HALF_DOWN : PHP_ROUND_HALF_UP)); $a = round($a, 0, ($a>=0 ? PHP_ROUND_HALF_DOWN : PHP_ROUND_HALF_UP)); $b = round($b, 0, ($b>=0 ? PHP_ROUND_HALF_DOWN : PHP_ROUND_HALF_UP)); return ($a - ($div * $b)); }
php
{ "resource": "" }
q266363
HTTP_Request2_Observer_Log.update
test
public function update(SplSubject $subject) { $event = $subject->getLastEvent(); if (!in_array($event['name'], $this->events)) { return; } switch ($event['name']) { case 'connect': $this->log('* Connected to ' . $event['data']); break; case 'sentHeaders': $headers = explode("\r\n", $event['data']); array_pop($headers); foreach ($headers as $header) { $this->log('> ' . $header); } break; case 'sentBody': $this->log('> ' . $event['data'] . ' byte(s) sent'); break; case 'receivedHeaders': $this->log(sprintf( '< HTTP/%s %s %s', $event['data']->getVersion(), $event['data']->getStatus(), $event['data']->getReasonPhrase() )); $headers = $event['data']->getHeader(); foreach ($headers as $key => $val) { $this->log('< ' . $key . ': ' . $val); } $this->log('< '); break; case 'receivedBody': $this->log($event['data']->getBody()); break; case 'disconnect': $this->log('* Disconnected'); break; } }
php
{ "resource": "" }
q266364
HTTP_Request2_Observer_Log.log
test
protected function log($message) { if ($this->target instanceof Log) { $this->target->debug($message); } elseif (is_resource($this->target)) { fwrite($this->target, $message . "\r\n"); } }
php
{ "resource": "" }
q266365
EntityQueryBuilder.selectFromRepositoryEntity
test
public function selectFromRepositoryEntity($alias = null, $indexBy = null) { if ($alias) { $this->entityAlias = $alias; } if (!$alias) { $alias = $this->getEntityAlias(); } $this->select($alias)->from($this->getEntityClassName(), $alias, $indexBy); return $this; }
php
{ "resource": "" }
q266366
EntityQueryBuilder.getEntityAlias
test
public function getEntityAlias() { if (!$this->entityAlias) { $className = $this->getEntityClassName(); $reflectionCLass = new ReflectionClass($className); if (is_string($reflectionCLass->getConstant('ALIAS_NAME'))) { $this->entityAlias = $reflectionCLass->getConstant('ALIAS_NAME'); } else { if (method_exists($this->getRepository(), 'getEntityAlias')) { $this->entityAlias = $this->getRepository()->getEntityAlias(); } else { $this->entityAlias = end(explode('\\', $className)); } } $this->entityAlias = str_replace('.', '', $this->entityAlias); } return $this->entityAlias; }
php
{ "resource": "" }
q266367
EntityQueryBuilder.delete
test
public function delete($delete = null, $alias = null) { if ($delete === null) { $delete = $this->getEntityClassName(); if ($alias === null) { $alias = $this->getEntityAlias(); } } parent::delete($delete, $alias); return $this; }
php
{ "resource": "" }
q266368
EntityQueryBuilder.update
test
public function update($update = null, $alias = null) { if ($update === null) { $update = $this->getEntityClassName(); if ($alias === null) { $alias = $this->getEntityAlias(); } } parent::update($update, $alias); return $this; }
php
{ "resource": "" }
q266369
EntityQueryBuilder.from
test
public function from($from = null, $alias = null, $indexBy = null) { if ($from === null) { $from = $this->getEntityClassName(); if ($alias === null) { $alias = $this->getEntityAlias(); } } parent::from($from, $alias, $indexBy = null); return $this; }
php
{ "resource": "" }
q266370
EntityQueryBuilder.set
test
public function set($key, $value) { parent::set($this->alias($key), $value); return $this; }
php
{ "resource": "" }
q266371
EntityQueryBuilder.groupBy
test
public function groupBy($groupBy) { /** @var array $groupFields */ $groupFields = func_get_args(); if (count($groupFields) > 0) { parent::groupBy($this->alias(array_shift($groupFields))); foreach ($groupFields as $group) { $this->addGroupBy($group); } } return $this; }
php
{ "resource": "" }
q266372
EntityQueryBuilder.addGroupBy
test
public function addGroupBy($groupBy) { /** @var array $groupFields */ $groupFields = func_get_args(); foreach ($groupFields as $group) { parent::addGroupBy($this->alias($group)); } return $this; }
php
{ "resource": "" }
q266373
EntityQueryBuilder.orderBy
test
public function orderBy($sort, $order = null) { if (is_string($sort)) { $sort = $this->alias($sort); } parent::orderBy($sort, $order); return $this; }
php
{ "resource": "" }
q266374
EntityQueryBuilder.addOrderBy
test
public function addOrderBy($sort, $order = null) { if (is_string($sort)) { $sort = $this->alias($sort); } parent::addOrderBy($sort, $order); return $this; }
php
{ "resource": "" }
q266375
EntityQueryBuilder.limit
test
public function limit($maxResults, $offset = null) { if (!is_int($maxResults)) { throw new Exception\InvalidArgumentException('Incorrect argument $maxResults. Only number allowed.'); } if ($maxResults < 1) { throw new Exception\InvalidArgumentException( sprintf('Incorrect maximum results: %d. Only positive number allowed.', $maxResults) ); } $this->setMaxResults($maxResults); if ($offset !== null) { if (!is_int($offset)) { throw new Exception\InvalidArgumentException('Incorrect argument $offset. Only number allowed.'); } if ($offset < 0) { throw new Exception\InvalidArgumentException( sprintf('Incorrect offset: %d. Only positive number allowed.', $offset) ); } $this->setFirstResult($offset); } return $this; }
php
{ "resource": "" }
q266376
EntityQueryBuilder.paginate
test
public function paginate($page = 1, $itemsPerPage = 10) { if (!is_int($page) || !is_int($itemsPerPage)) { throw new Exception\InvalidArgumentException( sprintf( 'Incorrect argument %s. Only number allowed.', is_int($page) ? '$itemsPerPage' : '$page' ) ); } if ($page < 1) { throw new Exception\InvalidArgumentException( sprintf('Incorrect page number: %d. Only positive number allowed.', $page) ); } if ($itemsPerPage < 1) { throw new Exception\InvalidArgumentException( sprintf('Incorrect items per page: %d. Only positive number allowed.', $page) ); } return $this->limit($itemsPerPage, ($page - 1) * $itemsPerPage); }
php
{ "resource": "" }
q266377
EntityQueryBuilder.fetchOne
test
public function fetchOne(array $parameters = [], $hydrationMode = null) { $this->appendParameters($parameters); $this->limit(1, 0); return $this->getQuery()->getOneOrNullResult($hydrationMode); }
php
{ "resource": "" }
q266378
EntityQueryBuilder.fetchSingle
test
public function fetchSingle(array $parameters = [], $hydrationMode = null) { $this->appendParameters($parameters); $this->limit(1, 0); return $this->getQuery()->getSingleResult($hydrationMode); }
php
{ "resource": "" }
q266379
EntityQueryBuilder.fetchAll
test
public function fetchAll(array $parameters = [], $hydrationMode = DoctrineQuery::HYDRATE_OBJECT) { $this->appendParameters($parameters); return $this->getQuery()->getResult($hydrationMode); }
php
{ "resource": "" }
q266380
EntityQueryBuilder.param
test
public function param($value, $type = null, $columnName = 'p') { $parameterName = $this->findUnusedParameterName($columnName); if ($type) { $this->appendParameters( [ $parameterName => [ $value, $type ] ] ); } else { $this->appendParameters([$parameterName => $value]); } return sprintf(':%s', $parameterName); }
php
{ "resource": "" }
q266381
EntityQueryBuilder.findUnusedParameterName
test
protected function findUnusedParameterName($columnName = 'p') { $parameters = $this->getParameters()->map( function($parameter) { /** @var Parameter $parameter */ return $parameter->getName(); } ); $index = 0; do { $parameterName = $columnName . $index; $index++; } while ($parameters->contains($parameterName)); return $parameterName; }
php
{ "resource": "" }
q266382
EntityQueryBuilder.parseCallMethods
test
protected function parseCallMethods($method, array $lists, array $arguments, $prefix = true) { $condition = null; $fieldName = null; $methodName = null; foreach ($lists as $name => $requireArgs) { if (strpos($method, 'and') === 0) { $method = lcfirst(substr($method, 3)); $condition = 'and'; } elseif (strpos($method, 'or') === 0) { $method = lcfirst(substr($method, 2)); $condition = 'or'; } if (strlen($method) < strlen($name)) { continue; } $position = false; if ($prefix && strpos($method, $name) === 0) { $position = 0; } elseif (!$prefix) { $position = strpos($method, $name, strlen($name)); } if ($position !== false) { /** @noinspection IsEmptyFunctionUsageInspection */ if ($requireArgs && empty($arguments)) { throw ORMException::findByRequiresParameter(sprintf('%s::%s', static::class, $method)); } if ($prefix) { $fieldName = substr($method, strlen($name)); $methodName = $name; } elseif (!$prefix) { $fieldName = substr($method, 0, $position); $methodName = $name; } break; } } if ($fieldName && $methodName) { $fieldName = lcfirst(Inflector::classify($fieldName)); $className = $this->getEntityClassName(); $classMetadata = $this->getEntityManager()->getClassMetadata($className); if (!$classMetadata->hasField($fieldName) && !$classMetadata->hasAssociation($fieldName)) { throw ORMException::invalidFindByCall($className, $fieldName, $method); } } return [ 'condition' => $condition, 'fieldName' => $fieldName, 'methodName' => $methodName ]; }
php
{ "resource": "" }
q266383
EntityQueryBuilder.callFunctionalityFields
test
private function callFunctionalityFields($fieldName, $methodName, array $arguments = [], $condition = null) { switch ($methodName) { case 'where': case 'filterBy': if ($condition === 'or') { $this->orWhere(sprintf('%s = %s', $this->alias($fieldName), $arguments[0])); } else { $this->andWhere(sprintf('%s = %s', $this->alias($fieldName), $arguments[0])); } break; case 'orderBy': case 'orderAscBy': case 'orderDescBy': if ($methodName === 'orderAscBy') { $arguments = ['ASC']; } elseif ($methodName === 'orderDescBy') { $arguments = ['DESC']; } if (count($arguments) === 1) { $this->orderBy($fieldName, $arguments[0]); } else { $this->orderBy($fieldName); } break; case 'addOrderBy': case 'addOrderAscBy': case 'addOrderDescBy': if ($methodName === 'addOrderAscBy') { $arguments = ['ASC']; } elseif ($methodName === 'addOrderDescBy') { $arguments = ['DESC']; } if (count($arguments) === 1) { $this->addOrderBy($fieldName, $arguments[0]); } else { $this->addOrderBy($fieldName); } break; case 'groupBy': $this->groupBy($this->alias($fieldName)); break; case 'addGroupBy': $this->addGroupBy($this->alias($fieldName)); break; default: // Do Nothing break; } return $this; }
php
{ "resource": "" }
q266384
IsAssoc.isAssoc
test
public function isAssoc(): bool { if (empty($this->array)) { return false; } return (bool) count(array_filter(array_keys($this->array), 'is_string')); }
php
{ "resource": "" }
q266385
DescriptionFactory.describe
test
public function describe(Subject $subject): DescriptionInterface { $description = $this->createDescription(); foreach ($this->resolvers as $resolver) { $subject = $resolver->resolve($subject); } foreach ($this->enhancers as $enhancer) { if (false === $enhancer->supports($subject)) { continue; } $enhancer->enhanceFromClass($description, $subject->getClass()); if ($subject->hasObject()) { $enhancer->enhanceFromObject($description, $subject); } } return $description; }
php
{ "resource": "" }
q266386
CLog.timestamp
test
public function timestamp($domain, $where, $comment = null) { $now = microtime(true); $this->timestamp[] = array( 'domain' => $domain, 'where' => $where, 'comment' => $comment, 'when' => $now, 'memory' => memory_get_usage(true), 'duration'=> 0, ); if ($this->pos > 0) { $this->timestamp[$this->pos - 1]['memory-peak'] = memory_get_peak_usage(true); $this->timestamp[$this->pos - 1]['duration'] = $now - $this->timestamp[$this->pos - 1]['when']; } $this->pos++; }
php
{ "resource": "" }
q266387
CLog.timestampAsTable
test
public function timestampAsTable() { // Set up the table $first = $this->timestamp[0]['when']; $last = $this->timestamp[count($this->timestamp) - 1]['when']; $html = "<table class='logtable'><caption>Timestamps</caption><tr><th>Domain</th><th>Where</th><th>When (sec)</th><th>Duration (sec)</th><th>Percent</th><th>Memory (MB)</th><th>Memory peak (MB)</th><th>Comment</th></tr>"; $right = ' style="text-align: right;"'; $total = array('domain' => array(), 'where' => array()); $totalDuration = $last - $first; // Create the main table foreach ($this->timestamp as $val) { $when = $val['when'] - $first; $duration = round($val['duration'], $this->precision); $percent = round(($when) / $totalDuration * 100); $memory = round($val['memory'] / 1024 / 1024, 2); $peak = isset($val['memory-peak']) ? round($val['memory-peak'] / 1024 / 1024, 2): 0; $when = round($when, $this->precision); $html .= "<tr><td>{$val['domain']}</td><td>{$val['where']}</td><td{$right}>{$when}</td><td{$right}>{$duration}</td><td{$right}>{$percent}</td><td{$right}>{$memory}</td><td{$right}>{$peak}</td><td>{$val['comment']}</td></tr>"; @$total['domain'][$val['domain']] += $val['duration']; @$total['where'][$val['where']] += $val['duration']; } $html .= "</table><br><table class='logtable'><caption>Duration per domain</caption><tr><th>Domain</th><th>Duration</th><th>Percent</th></tr>"; // Create the table grouped by domain arsort($total['domain']); foreach ($total['domain'] as $key => $val) { if ($totalDuration != 0) { $percent = round($val / $totalDuration * 100, 1); } else { $percent = 100; } $roundedDuration = round($val, $this->precision); $html .= "<tr><td>{$key}</td><td>{$roundedDuration}</td><td>{$percent}</td></tr>"; } $html .= "</table><br><table class='logtable'><caption>Duration per area</caption><tr><th>Area</th><th>Duration</th><th>Percent</th></tr>"; // Create the table grouped by area arsort($total['where']); foreach ($total['where'] as $key => $val) { if ($totalDuration != 0) { $percent = round($val / $totalDuration * 100, 1); } else { $percent = 100; } $roundedDuration = round($val, $this->precision); $html .= "<tr><td>{$key}</td><td>{$roundedDuration}</td><td>{$percent}</td></tr>"; } $html .= "</table>"; return $html; }
php
{ "resource": "" }
q266388
CLog.pageLoadTime
test
public function pageLoadTime() { $first = $this->timestamp[0]['when']; $last = $this->timestamp[count($this->timestamp) - 1]['when']; $loadtime = round($last - $first, 3); return $loadtime; }
php
{ "resource": "" }
q266389
CLog.mostTimeConsumingDomain
test
public function mostTimeConsumingDomain() { $total = array(); // Gather total duration data of each domain foreach ($this->timestamp as $val) { $duration = round($val['duration'], $this->precision); @$total[$val['domain']] += $duration; } // Get the key of the most time consuming element $mostConsumingTime = 0; $mostConsumingDomain = ""; foreach ($total as $key => $val) { if ($val >= $mostConsumingTime) { $mostConsumingDomain = $key; $mostConsumingTime = $val; } } return $mostConsumingDomain; }
php
{ "resource": "" }
q266390
Card.renderHeader
test
protected function renderHeader() { if (!isset($this->header)) { return ''; } if (isset($this->headerOptions)) { Html::addCssClass($this->headerOptions, ['widget' => 'card-header']); $tag = ArrayHelper::remove($this->headerOptions, 'tag', 'div'); $header = Html::tag($tag, $this->header, $this->headerOptions); } else { $header = $this->header; } return $header; }
php
{ "resource": "" }
q266391
Card.renderHeaderImage
test
protected function renderHeaderImage() { if (!isset($this->headerImage)) { return ''; } Html::addCssClass($this->headerImageOptions, ['widget' => 'card-img-top']); return $this->htmlHlp->img($this->headerImage, $this->headerImageOptions); }
php
{ "resource": "" }
q266392
Card.renderBody
test
protected function renderBody($body = null, $includeOb = false) { $body = isset($body) ? $body : $this->body; $bodyContent = ''; $bodyTag = 'div'; if (is_array($body)) { $bodyRows = []; foreach ($body as $bodyRow) { $bodyRowContent = $this->renderBody($bodyRow); if (empty($bodyRowContent)) { continue; } $bodyRows[] = $bodyRowContent; } $bodyContent = implode("\n", $bodyRows); } else { if (isset($this->bodyOptions)) { if (isset($this->overlayImage)) { Html::addCssClass($this->bodyOptions, ['widget' => 'card-img-overlay']); } else { Html::addCssClass($this->bodyOptions, ['widget' => 'card-body']); } $bodyTag = ArrayHelper::remove($this->bodyOptions, 'tag', 'div'); $bodyOptions = $this->bodyOptions; } if (isset($body)) { $bodyContent .= $body; } } if ($includeOb) { $bodyContent .= ob_get_clean(); } return isset($bodyOptions) ? $this->htmlHlp->tag($bodyTag, $bodyContent, $bodyOptions) : $bodyContent; }
php
{ "resource": "" }
q266393
Card.renderFooter
test
protected function renderFooter() { if (!isset($this->footer)) { return ''; } if (isset($this->footerOptions)) { Html::addCssClass($this->footerOptions, ['widget' => 'card-footer']); $tag = ArrayHelper::remove($this->footerOptions, 'tag', 'div'); $footer = $this->htmlHlp->tag($tag, $this->footer, $this->footerOptions); } else { $footer = $this->footer; } return $footer; }
php
{ "resource": "" }
q266394
Controller.group
test
public function group() { $namespace = \Reaction::$app->router->getRelativeControllerNamespace(static::class); $namespace = substr($namespace, 0, -10); $namespaceArray = explode('\\', $namespace); array_walk($namespaceArray, function(&$value) { $value = Inflector::camel2id($value, '-'); }); return implode('/', $namespaceArray); }
php
{ "resource": "" }
q266395
Controller.getOptionValues
test
public function getOptionValues($actionID = null) { // $actionId might be used in subclasses to provide properties specific to action id $properties = []; foreach ($this->options($actionID) as $property) { $properties[$property] = $this->$property; } return $properties; }
php
{ "resource": "" }
q266396
Controller.getActionArgsHelp
test
public function getActionArgsHelp($actionId) { $methodName = static::getActionMethod($actionId); $method = ReflectionHelper::getMethodReflection($this, $methodName); $tags = ReflectionHelper::getMethodDocTags($method, $this); $params = isset($tags['param']) ? (array)$tags['param'] : []; $args = []; /** @var \ReflectionParameter $reflection */ foreach ($method->getParameters() as $i => $reflection) { if ($reflection->getClass() !== null) { continue; } $name = $reflection->getName(); $tag = isset($params[$i]) ? $params[$i] : ''; if (preg_match('/^(\S+)\s+(\$\w+\s+)?(.*)/s', $tag, $matches)) { $type = $matches[1]; $comment = $matches[3]; } else { $type = null; $comment = $tag; } if ($reflection->isDefaultValueAvailable()) { $args[$name] = [ 'required' => false, 'type' => $type, 'default' => $reflection->getDefaultValue(), 'comment' => $comment, ]; } else { $args[$name] = [ 'required' => true, 'type' => $type, 'default' => null, 'comment' => $comment, ]; } } return $args; }
php
{ "resource": "" }
q266397
Controller.getActionOptionsHelp
test
public function getActionOptionsHelp($actionId) { $optionNames = $this->options($actionId); if (empty($optionNames)) { return []; } $class = ReflectionHelper::getClassReflection($this); $options = []; foreach ($class->getProperties() as $property) { $name = $property->getName(); if (!in_array($name, $optionNames, true)) { continue; } $defaultValue = $property->getValue($this); $tags = ReflectionHelper::getPropertyDocTags($property); // Display camelCase options in kebab-case $name = Inflector::camel2id($name, '-', true); if (isset($tags['var']) || isset($tags['property'])) { $doc = isset($tags['var']) ? $tags['var'] : $tags['property']; if (is_array($doc)) { $doc = reset($doc); } if (preg_match('/^(\S+)(.*)/s', $doc, $matches)) { $type = $matches[1]; $comment = $matches[2]; } else { $type = null; $comment = $doc; } $options[$name] = [ 'type' => $type, 'default' => $defaultValue, 'comment' => $comment, ]; } else { $options[$name] = [ 'type' => null, 'default' => $defaultValue, 'comment' => '', ]; } } return $options; }
php
{ "resource": "" }
q266398
RequestHelper.getHeaders
test
public function getHeaders() { if ($this->_headers === null) { $this->_headers = new HeaderCollection(); $headers = $this->reactRequest->getHeaders(); foreach ($headers as $name => $value) { $this->_headers->add($name, $value); } $this->filterHeaders($this->_headers); } return $this->_headers; }
php
{ "resource": "" }
q266399
RequestHelper.getIsFlash
test
public function getIsFlash() { /** @var string $userAgent */ $userAgent = $this->getHeaders()->get('User-Agent', ''); return stripos($userAgent, 'Shockwave') !== false || stripos($userAgent, 'Flash') !== false; }
php
{ "resource": "" }