_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 33
8k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q266300
|
PEAR_Command_Common.PEAR_Command_Common
|
test
|
function PEAR_Command_Common(&$ui, &$config)
{
parent::PEAR();
|
php
|
{
"resource": ""
}
|
q266301
|
PEAR_Command_Common.getCommands
|
test
|
function getCommands()
{
$ret = array();
foreach (array_keys($this->commands) as
|
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'])) {
|
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\"";
}
|
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 {
|
php
|
{
"resource": ""
}
|
q266305
|
Plugin.onPostPackageEvent
|
test
|
public function onPostPackageEvent(PackageEvent $event)
{
$package = $this->getOpenBizPackage($event->getOperation());
|
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';
|
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).',';
}
|
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] = [];
|
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')
|
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
|
php
|
{
"resource": ""
}
|
q266311
|
DoctrinePresenceVerifier.createCountQuery
|
test
|
protected function createCountQuery($collection, $alias = 'o') {
return $this->getEntityManager()->createQueryBuilder()
|
php
|
{
"resource": ""
}
|
q266312
|
DoctrinePresenceVerifier.getEntityManager
|
test
|
protected function getEntityManager() {
if($this->entities === null) {
$callable = $this->factory;
|
php
|
{
"resource": ""
}
|
q266313
|
Url.getCurrentPath
|
test
|
protected static function getCurrentPath(RequestApplicationInterface $app, $onlyStaticPart = false) {
$route = $app->getRoute();
|
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;
|
php
|
{
"resource": ""
}
|
q266315
|
Container.clear
|
test
|
public function clear($name)
{
if (true===$this->instances->isEntry($name)) {
|
php
|
{
"resource": ""
}
|
q266316
|
Container.getBundle
|
test
|
public function getBundle($name)
{
if (true===$this->instances->isEntry($name,'bundles')) {
|
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)
);
}
|
php
|
{
"resource": ""
}
|
q266318
|
Container.clearBundle
|
test
|
public function clearBundle($name)
{
if (true===$this->instances->isEntry($name,'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
|
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();
}
|
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
) {
|
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']);
}
|
php
|
{
"resource": ""
}
|
q266323
|
PEAR_DependencyDB.installPackage
|
test
|
function installPackage(&$package)
{
$data = $this->_getDepDB();
|
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) {
|
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))
|
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" .
|
php
|
{
"resource": ""
}
|
q266327
|
PEAR_DependencyDB._unlock
|
test
|
function _unlock()
{
$ret = $this->_lock(LOCK_UN);
if (is_resource($this->_lockFp)) {
fclose($this->_lockFp);
|
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;
}
|
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();
|
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
|
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);
|
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
|
php
|
{
"resource": ""
}
|
q266333
|
ErrorController.actionError
|
test
|
public function actionError(RequestApplicationInterface $app, \Throwable $exception) {
return $this->render($app, 'view', [
'exception' => $exception,
|
php
|
{
"resource": ""
}
|
q266334
|
NativeOutputFormatter.setForeground
|
test
|
public function setForeground(FormatForeground $foreground = null): void
{
if (null === $foreground) {
$this->foreground = null;
|
php
|
{
"resource": ""
}
|
q266335
|
NativeOutputFormatter.setBackground
|
test
|
public function setBackground(FormatBackground $background = null): void
{
if (null === $background) {
$this->background = null;
|
php
|
{
"resource": ""
}
|
q266336
|
NativeOutputFormatter.black
|
test
|
public function black(bool $background = null): void
{
$this->setColor(
|
php
|
{
"resource": ""
}
|
q266337
|
NativeOutputFormatter.red
|
test
|
public function red(bool $background = null): void
{
$this->setColor(
|
php
|
{
"resource": ""
}
|
q266338
|
NativeOutputFormatter.green
|
test
|
public function green(bool $background = null): void
{
$this->setColor(
|
php
|
{
"resource": ""
}
|
q266339
|
NativeOutputFormatter.yellow
|
test
|
public function yellow(bool $background = null): void
{
$this->setColor(
|
php
|
{
"resource": ""
}
|
q266340
|
NativeOutputFormatter.blue
|
test
|
public function blue(bool $background = null): void
{
$this->setColor(
|
php
|
{
"resource": ""
}
|
q266341
|
NativeOutputFormatter.magenta
|
test
|
public function magenta(bool $background = null): void
{
$this->setColor(
|
php
|
{
"resource": ""
}
|
q266342
|
NativeOutputFormatter.cyan
|
test
|
public function cyan(bool $background = null): void
{
$this->setColor(
|
php
|
{
"resource": ""
}
|
q266343
|
NativeOutputFormatter.white
|
test
|
public function white(bool $background = null): void
{
$this->setColor(
|
php
|
{
"resource": ""
}
|
q266344
|
NativeOutputFormatter.resetColor
|
test
|
public function resetColor(bool $background = null): void
{
$this->setColor(
|
php
|
{
"resource": ""
}
|
q266345
|
NativeOutputFormatter.setColor
|
test
|
protected function setColor(int $color, bool $background = null): void
{
if (null !== $background) {
$this->background = $color;
|
php
|
{
"resource": ""
}
|
q266346
|
NativeOutputFormatter.removeOption
|
test
|
public function removeOption(FormatOption $option): void
{
if
|
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
|
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) {
|
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,
|
php
|
{
"resource": ""
}
|
q266350
|
PEAR_PackageFile_v2.setRawState
|
test
|
function setRawState($state)
{
if (!isset($this->_packageInfo['stability'])) {
$this->_packageInfo['stability'] = array();
|
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];
|
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
|
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']))
|
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) {
|
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'])) {
|
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;
}
|
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])) {
|
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);
}
|
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,
|
php
|
{
"resource": ""
}
|
q266360
|
CSDTCollectionsBundle.build
|
test
|
public function build(ContainerBuilder $container)
{
parent::build($container);
$container->addCompilerPass(new
|
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
|
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));
|
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()
));
|
php
|
{
"resource": ""
}
|
q266364
|
HTTP_Request2_Observer_Log.log
|
test
|
protected function log($message)
{
if ($this->target instanceof Log) {
$this->target->debug($message);
}
|
php
|
{
"resource": ""
}
|
q266365
|
EntityQueryBuilder.selectFromRepositoryEntity
|
test
|
public function selectFromRepositoryEntity($alias = null, $indexBy = null)
{
if ($alias) {
$this->entityAlias = $alias;
}
if (!$alias) {
$alias = $this->getEntityAlias();
|
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();
|
php
|
{
"resource": ""
}
|
q266367
|
EntityQueryBuilder.delete
|
test
|
public function delete($delete = null, $alias = null)
{
if ($delete === null) {
$delete = $this->getEntityClassName();
if ($alias === null) {
$alias =
|
php
|
{
"resource": ""
}
|
q266368
|
EntityQueryBuilder.update
|
test
|
public function update($update = null, $alias = null)
{
if ($update === null) {
$update = $this->getEntityClassName();
if ($alias === null) {
$alias =
|
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 =
|
php
|
{
"resource": ""
}
|
q266370
|
EntityQueryBuilder.set
|
test
|
public function set($key, $value)
{
parent::set($this->alias($key),
|
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)));
|
php
|
{
"resource": ""
}
|
q266372
|
EntityQueryBuilder.addGroupBy
|
test
|
public function addGroupBy($groupBy)
{
/** @var array $groupFields */
$groupFields = func_get_args();
foreach ($groupFields as $group) {
|
php
|
{
"resource": ""
}
|
q266373
|
EntityQueryBuilder.orderBy
|
test
|
public function orderBy($sort, $order = null)
{
if (is_string($sort)) {
|
php
|
{
"resource": ""
}
|
q266374
|
EntityQueryBuilder.addOrderBy
|
test
|
public function addOrderBy($sort, $order = null)
{
if (is_string($sort)) {
|
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)) {
|
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)
|
php
|
{
"resource": ""
}
|
q266377
|
EntityQueryBuilder.fetchOne
|
test
|
public function fetchOne(array $parameters = [], $hydrationMode = null)
{
$this->appendParameters($parameters);
$this->limit(1, 0);
|
php
|
{
"resource": ""
}
|
q266378
|
EntityQueryBuilder.fetchSingle
|
test
|
public function fetchSingle(array $parameters = [], $hydrationMode = null)
{
$this->appendParameters($parameters);
|
php
|
{
"resource": ""
}
|
q266379
|
EntityQueryBuilder.fetchAll
|
test
|
public function fetchAll(array $parameters = [], $hydrationMode = DoctrineQuery::HYDRATE_OBJECT)
|
php
|
{
"resource": ""
}
|
q266380
|
EntityQueryBuilder.param
|
test
|
public function param($value, $type = null, $columnName = 'p')
{
$parameterName = $this->findUnusedParameterName($columnName);
if ($type) {
$this->appendParameters(
[
$parameterName => [
$value,
|
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 {
|
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;
|
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'];
|
php
|
{
"resource": ""
}
|
q266384
|
IsAssoc.isAssoc
|
test
|
public function isAssoc(): bool
{
if (empty($this->array)) {
return false;
}
|
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) {
|
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,
|
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 =
|
php
|
{
"resource": ""
}
|
q266388
|
CLog.pageLoadTime
|
test
|
public function pageLoadTime()
{
$first = $this->timestamp[0]['when'];
$last = $this->timestamp[count($this->timestamp) - 1]['when'];
|
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;
|
php
|
{
"resource": ""
}
|
q266390
|
Card.renderHeader
|
test
|
protected function renderHeader() {
if (!isset($this->header)) {
return '';
}
if (isset($this->headerOptions)) {
Html::addCssClass($this->headerOptions, ['widget' =>
|
php
|
{
"resource": ""
}
|
q266391
|
Card.renderHeaderImage
|
test
|
protected function renderHeaderImage() {
if (!isset($this->headerImage)) {
return '';
}
Html::addCssClass($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']);
}
|
php
|
{
"resource": ""
}
|
q266393
|
Card.renderFooter
|
test
|
protected function renderFooter() {
if (!isset($this->footer)) {
return '';
}
if (isset($this->footerOptions)) {
Html::addCssClass($this->footerOptions, ['widget' =>
|
php
|
{
"resource": ""
}
|
q266394
|
Controller.group
|
test
|
public function group()
{
$namespace = \Reaction::$app->router->getRelativeControllerNamespace(static::class);
$namespace = substr($namespace, 0, -10);
$namespaceArray = explode('\\', $namespace);
|
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 = [];
|
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;
}
|
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];
|
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,
|
php
|
{
"resource": ""
}
|
q266399
|
RequestHelper.getIsFlash
|
test
|
public function getIsFlash()
{
/** @var string $userAgent */
$userAgent = $this->getHeaders()->get('User-Agent', '');
|
php
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.