_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q267400
RbacMigration.init
test
public function init() { parent::init(); $this->authManager = Yii::$app->getAuthManager(); if (!$this->authManager instanceof DbManager) { throw new InvalidConfigException('You should configure "authManager" component to use database before executing this migration.'); }...
php
{ "resource": "" }
q267401
RbacMigration.createRole
test
function createRole($name, $description) { if ($user = $this->authManager->getRole($name)) { echo "{$name} role already exists\n"; } else { $user = $this->authManager->createRole($name); $user->description = $description; $this->authManager->add($use...
php
{ "resource": "" }
q267402
RbacMigration.assignChildRole
test
function assignChildRole($parent, $child) { if (!$this->authManager->hasChild($parent, $child)) { $this->authManager->addChild($parent, $child); echo "New child '{$child->name}' added to '{$parent->name}'\n"; } else { echo "Role '{$child->name}' was already added...
php
{ "resource": "" }
q267403
MockRegistry.register
test
public function register(FunctionProphecy $prophecy) { $name = $prophecy->getFQName(); if ($this->has($name)) { throw new \Exception(); } if (! function_exists($name)) { Generator::generate($prophecy); } $this->mocks[$name] = $prophecy->getN...
php
{ "resource": "" }
q267404
MockRegistry.call
test
public function call($name, $uqfn, array $args) { if (! $this->has($name)) { throw new \Exception(); } return $this->mocks[$name]->call($uqfn, $args); }
php
{ "resource": "" }
q267405
ParameterBag.get
test
public function get($key) { $key = strtolower($key); if (!array_key_exists($key, $this->parameters)) { throw new ParameterNotFoundException($key); } return $this->parameters[$key]; }
php
{ "resource": "" }
q267406
ParameterBag.resolveString
test
public function resolveString($value, array $resolving = array()) { $parts = explode('%', $value); $keyOnly = (bool) preg_match('/^%([^%\s]+)%$/', $value); $return = $parts[0]; for ($i = 1, $last = count($parts) - 1; $i <= $last; ++$i) { $part = $parts[$i]; $...
php
{ "resource": "" }
q267407
Twitter.queryToMeta
test
protected function queryToMeta($query) { $query = str_replace(' ', '+', $query); if (preg_match('~^(?:hashtag:|#)(\w+)$~i', $query, $matches)) { $type = 'hashtag'; $url = 'https://twitter.com/hashtag/' . $matches[1] . '?f=tweets'; } elseif (preg_match('~^(?:user:|...
php
{ "resource": "" }
q267408
Twitter.twitter
test
public function twitter($query) { $meta = $this->queryToMeta($query); if (! $page = NoAPI::curl($meta['url'])) return false; return $this->parse($page, $meta); }
php
{ "resource": "" }
q267409
Tabs.renderPanes
test
public function renderPanes($panes) { return $this->renderTabContent ? "\n" . $this->htmlHlp->tag('div', implode("\n", $panes), $this->tabContentOptions) : ''; }
php
{ "resource": "" }
q267410
RegistrationForm.register
test
public function register() { if (!$this->validate()) { return false; } /** @var User $user */ $user = Yii::createObject(User::className()); $user->setScenario('register'); $this->loadAttributes($user); if (!$user->register()) { return fal...
php
{ "resource": "" }
q267411
Zend_Filter_Encrypt_Mcrypt.setVector
test
public function setVector($vector = null) { $cipher = $this->_openCipher(); $size = mcrypt_enc_get_iv_size($cipher); if (empty($vector)) { $this->_srand(); if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && version_compare(PHP_VERSION, '5.3.0', '<')) { ...
php
{ "resource": "" }
q267412
Zend_Filter_Encrypt_Mcrypt._openCipher
test
protected function _openCipher() { $cipher = mcrypt_module_open( $this->_encryption['algorithm'], $this->_encryption['algorithm_directory'], $this->_encryption['mode'], $this->_encryption['mode_directory']); if ($cipher === false) { throw...
php
{ "resource": "" }
q267413
Zend_Filter_Encrypt_Mcrypt._initCipher
test
protected function _initCipher($cipher) { $key = $this->_encryption['key']; $keysizes = mcrypt_enc_get_supported_key_sizes($cipher); if (empty($keysizes) || ($this->_encryption['salt'] == true)) { $this->_srand(); $keysize = mcrypt_enc_get_key_size($cipher); ...
php
{ "resource": "" }
q267414
Auth.connect
test
public static function connect(array $clientCredentials, array $endPoints, $userDataUrl) { $instance = new static; if (! $instance->protocol = self::getAuthProtocol($clientCredentials)) { throw new \InvalidArgumentException('Credential keys are invalid.'); } $instance->...
php
{ "resource": "" }
q267415
Auth.verifyCredentials
test
public static function verifyCredentials(array $tokenCredentials, $userDataUrl) { $instance = new static; if (! $instance->protocol = self::getAuthProtocol($tokenCredentials)) { throw new \InvalidArgumentException('Credential keys are invalid.'); } $instance->addToCrede...
php
{ "resource": "" }
q267416
Auth.fetchUserData
test
protected function fetchUserData($userDataUrl) { $plugins = [ 'auth' => $this->newAuthExtension(), ]; $request = $this->newRequest(); $userData = $request::init($userDataUrl) ->addPlugins($plugins) ->GET() ->getBody(); $this-...
php
{ "resource": "" }
q267417
Auth.newAuthExtension
test
public function newAuthExtension(RequestPluginAdapter $authExtension = null) { if (empty($authExtension)) { $authExtension = new GuzzleAuth($this->credentials); } return $authExtension; }
php
{ "resource": "" }
q267418
Auth.addDataTokens
test
protected function addDataTokens(&$object, $tokenCredentials) { $tokens = &$object->tokens; $callback = function ($value, $key) use (&$tokens) { $tokens = array_add($tokens, $key, $value); }; array_walk($tokenCredentials, $callback); }
php
{ "resource": "" }
q267419
Auth.getAuthProtocol
test
public static function getAuthProtocol(array $credentials) { $instance = new static; $credentialKeys = array_keys($credentials); if ($instance->isOauth1($credentialKeys)) { return 'oauth1'; } if ($instance->isOauth2($credentialKeys)) { return '...
php
{ "resource": "" }
q267420
Auth.isOauth1
test
protected function isOauth1($credentialsKeys) { $keys = $this->getOauth1Keys(); foreach ($keys as $value) { if (subarray($value, $credentialsKeys)) { return true; } } return false; }
php
{ "resource": "" }
q267421
Auth.isOauth2
test
protected function isOauth2($credentialsKeys) { $keys = $this->getOauth2Keys(); foreach ($keys as $value) { if (subarray($value, $credentialsKeys)) { return true; } } return false; }
php
{ "resource": "" }
q267422
NativeStream.close
test
public function close(): void { // If there is no stream if (null === $this->stream) { // Don't do anything return; } // Detach the stream $resource = $this->detach(); // Close the stream fclose($resource); }
php
{ "resource": "" }
q267423
NativeStream.attach
test
public function attach(string $stream, string $mode = null): void { $this->setStream($stream, $mode); }
php
{ "resource": "" }
q267424
NativeStream.getContents
test
public function getContents(): string { // If the stream isn't readable if (! $this->isReadable()) { // Throw a runtime exception throw new RuntimeException('Stream is not readable'); } // Get the stream contents $result = stream_get_contents($this->s...
php
{ "resource": "" }
q267425
NativeStream.setStream
test
protected function setStream(string $stream, string $mode = null): void { // Set the mode $mode = $mode ?? 'r'; // Open a new resource stream $resource = fopen($stream, $mode); // If the resource isn't a resource or a stream resource type if (! \is_resource($resourc...
php
{ "resource": "" }
q267426
FileWriter.write
test
public function write(array $data, array $options) { if (!isset($options['file'])) { throw new \InvalidArgumentException( 'Parameter "file" is mandatory.' ); } if (!is_string($options['file'])) { throw new \InvalidArgumentException( ...
php
{ "resource": "" }
q267427
Transaction.getAccountVirtual
test
protected function getAccountVirtual() { $accountIdVirtual = (int) Post::getInstance()->get('editAccountIdVirtual'); $accountUserMapper = new AccountUserMapper(Database::get('money')); $accountMapper = new AccountMapper(Database::get('money')); //~ Update virtual account if nec...
php
{ "resource": "" }
q267428
Transaction.getPreviousAccount
test
public function getPreviousAccount($previousId) { $accountMapper = new AccountMapper(Database::get('money')); if ($previousId <= 0) { return $accountMapper->newDataInstance(); } return $accountMapper->findById($previousId); }
php
{ "resource": "" }
q267429
Transaction.updateAccountVirtual
test
protected function updateAccountVirtual(Account $account, Account $previousAccount, $amount, $previousAmount) { $accountMapper = new AccountMapper(Database::get('money')); //~ Revert previous amount on previous account if ($previousAccount->getId() > 0) { if ($previousAccount->g...
php
{ "resource": "" }
q267430
Command.cache
test
public function cache($duration = null) { $this->queryCacheDuration = $duration === null ? $this->db->queryCacheDuration : $duration; return $this; }
php
{ "resource": "" }
q267431
Command.setConnection
test
public function setConnection($connection = null) { if ($connection instanceof TransactionInterface) { $connection = $connection->getConnection(); } $this->connection = $connection; if ($connection instanceof EventEmitterWildcardInterface) { //Remove connectio...
php
{ "resource": "" }
q267432
Command.fetchResultsRow
test
public function fetchResultsRow($row = [], $fetchMethod = self::FETCH_ALL, $fetchMode = self::FETCH_MODE_ASSOC, $colIndex = 0) { if (in_array($fetchMethod, [static::FETCH_ALL, static::FETCH_ROW])) { $this->processResultRow($row); return $fetchMode === static::FETCH_MODE_OBJECT ? (object)...
php
{ "resource": "" }
q267433
Command.insertAndReturn
test
public function insertAndReturn($table, $columns) { $params = []; $sql = $this->db->getQueryBuilder()->insert($table, $columns, $params); $tableSchema = $this->db->getSchema()->getTableSchema($table); $returnColumns = $tableSchema->getColumnNames(); if (!empty($returnColumns)) { ...
php
{ "resource": "" }
q267434
Command.execute
test
public function execute($lazy = true) { $sql = $this->getSql(); $rawSql = $this->getRawSql(); if ($sql == '') { return reject(false); } $execPromise = $this->internalExecute($rawSql, [], $lazy); $needResCount = $this->needResultsCount(); $thenCal...
php
{ "resource": "" }
q267435
Command.logQuery
test
protected function logQuery($category) { if ($this->db->enableLogging) { $rawSql = $this->getRawSql(); $message = sprintf("SQL: \"%s\"\nCategory: %s", $rawSql, $category); \Reaction::info($message); } if (!$this->db->enableProfiling) { return [...
php
{ "resource": "" }
q267436
Command.queryScalar
test
public function queryScalar() { return $this->queryInternal(static::FETCH_FIELD)->thenLazy( function($result) { if (is_resource($result) && get_resource_type($result) === 'stream') { return stream_get_contents($result); } return...
php
{ "resource": "" }
q267437
Command.queryInternal
test
protected function queryInternal($fetchMethod, $fetchMode = null, $lazy = true) { $fetchMode = isset($fetchMode) ? $fetchMode : $this->fetchMode; list($profile, $rawSql) = $this->logQuery(__METHOD__); $self = $this; $execPromise = $this->internalExecute($this->sql, $this->params, $l...
php
{ "resource": "" }
q267438
Command.checkQueryByPattern
test
protected function checkQueryByPattern($pattern, $sql = null) { if (!isset($sql)) { $sql = $this->getSql(); } if ($sql === "") { return false; } return preg_match($pattern, $sql) > 0; }
php
{ "resource": "" }
q267439
Command.internalExecute
test
protected function internalExecute($sql, $params = [], $lazy = true) { return isset($this->connection) ? $this->connection->executeSql($sql, $params, $lazy) : $this->db->executeSql($sql, $params, $lazy); }
php
{ "resource": "" }
q267440
TClosureInvocation.invokeClosure
test
protected function invokeClosure(array $arguments, Closure $action) { $reflection = new ReflectionFunction($action); $parameters = []; foreach ($reflection->getParameters() as $parameter) { if (isset($arguments[$parameter->name])) { $parameter...
php
{ "resource": "" }
q267441
PEAR_Command_Config._checkLayer
test
function _checkLayer($layer = null) { if (!empty($layer) && $layer != 'default') { $layers = $this->config->getLayers(); if (!in_array($layer, $layers)) { return " only the layers: \"" . implode('" or "', $layers) . "\" are supported"; } } ...
php
{ "resource": "" }
q267442
FrontController.prepareDom
test
protected function prepareDom() { $dom_refs = array( 'page_menu', 'page_content', 'page_header', 'page_footer', 'page_title' ); foreach($dom_refs as $_ref) { HtmlHelper::getNewId($_ref, true); } return $this; }
php
{ "resource": "" }
q267443
FrontController.distribute
test
public function distribute() { $this ->_processSessionValues() ->_processQueryArguments() ; // if kernerl has booting errors, treat them first if (CarteBlanche::getContainer()->get('kernel')->hasBootErrors()) { $routing = array(CarteBlanche::g...
php
{ "resource": "" }
q267444
FrontController.renderError
test
public function renderError($params = null, $code = 404, $exception = null) { $mode_data = CarteBlanche::getKernelMode(true); if (!is_array($mode_data) || !isset($mode_data['debug']) || false==$mode_data['debug'] ) { $action = 'error'.$code.'Action'; ...
php
{ "resource": "" }
q267445
FrontController.renderDebug
test
public function renderDebug(&$params = null, $dbg = 'all', $parse_template = true) { $all_debug_infos = array( 'backtrace', 'php', 'server', 'session', 'constants', 'headers', 'system', 'router', 'registry', 'db' ); if (!is_array($dbg)) { if ($dbg=='all' || $dbg==1) $dbg = $all_debug_inf...
php
{ "resource": "" }
q267446
FrontController.view
test
public function view($view = null, array $params = array(), $display = false, $exit = false) { $view_file = CarteBlanche::getContainer() ->get('locator')->locateView( $view ); CarteBlanche::getContainer()->get('config') ->getRegistry()->loadStack('views'); CarteBlanch...
php
{ "resource": "" }
q267447
CannedResponsePlugin.init
test
public function init() { $this->addResponses(); $config = $this->bot->getConfig(); // detects someone speaking to the bot $responses = $this->responses; $address_re = "/(^{$config['nick']}(.+)|(.+){$config['nick']}[!.?]*)$/i"; $this->bot->onChannel($address_re, func...
php
{ "resource": "" }
q267448
CannedResponsePlugin.addResponses
test
private function addResponses() { // workaround for $this being unavailable in closures $plugin = $this; // basic response $this->addResponse('/i (love|<3) (you|u)/i', function($matches) { return 'Shutup baby, I know it!'; }); // matches things like "b...
php
{ "resource": "" }
q267449
ShortCodesProcessor.registerShortCode
test
public function registerShortCode($tag, $callback) { if (is_callable($callback)) { $this->shortCodesTags[$tag] = $callback; } return $this; }
php
{ "resource": "" }
q267450
ShortCodesProcessor.removeShortCode
test
public function removeShortCode($tag) { if (isset($this->shortCodesTags[$tag])) { unset($this->shortCodesTags[$tag]); } return $this; }
php
{ "resource": "" }
q267451
ShortCodesProcessor.parseShortCodeTag
test
public function parseShortCodeTag($matches) { // allow [[foo]] syntax for escaping a tag if ($matches[1] == '[' && $matches[6] == ']') { return substr($matches[0], 1, -1); } $tag = $matches[2]; $attributes = $this->parseShortCodeAttributes($matches[3]); ...
php
{ "resource": "" }
q267452
ShortCodesProcessor.parseShortCodeAttributes
test
protected function parseShortCodeAttributes($text) { $attributes = array(); $pattern = '/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s' . '|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/'; $text = preg_replace("/[\x{00a0}\x{...
php
{ "resource": "" }
q267453
PEAR_REST_10.getDownloadURL
test
function getDownloadURL($base, $packageinfo, $prefstate, $installed, $channel = false) { $states = $this->betterStates($prefstate, true); if (!$states) { return PEAR::raiseError('"' . $prefstate . '" is not a valid state'); } $channel = $packageinfo['channel']; ...
php
{ "resource": "" }
q267454
PEAR_REST_10.listCategory
test
function listCategory($base, $category, $info = false, $channel = false) { // gives '404 Not Found' error when category doesn't exist $packagelist = $this->_rest->retrieveData($base.'c/'.urlencode($category).'/packages.xml', false, false, $channel); if (PEAR::isError($packagelist)) { ...
php
{ "resource": "" }
q267455
PEAR_REST_10._sortReleasesByVersionNumber
test
function _sortReleasesByVersionNumber($a, $b) { if (version_compare($a['v'], $b['v'], '=')) { return 0; } if (version_compare($a['v'], $b['v'], '>')) { return -1; } if (version_compare($a['v'], $b['v'], '<')) { return 1; } }
php
{ "resource": "" }
q267456
ScheduleReceiver.getArrayData
test
public function getArrayData($id, $sens = 1, $date) { $this->date = $date; $this->uri = new Uri('/horaires_ligne/index.asp'); $this->uri->addParam('rub_code', 6); $this->uri->addParam('thm_id', 2); $this->uri->addParam('gpl_id', 0); $this->uri->addParam('lign_id', $id); $this->uri->addParam('sens', $...
php
{ "resource": "" }
q267457
ScheduleReceiver.allHours
test
private function allHours() { $index = 1; $same = false; $hours = array(); while(!$same) { # Get the page $this->uri->addParam('index', $index); $request = $this->client->get($this->uri); $resource = $request->getResource(); if(!$resource->code(200)) { return array('error' => 'fail to c...
php
{ "resource": "" }
q267458
ScheduleReceiver.parser
test
private function parser($page) { $templateTime = clone $this->date; $hours = array(); $array = array(); # Get only table $page = preg_replace('#(.+)\<tbody\>(.+)\<\/tbody\>(.+)#siU', '<table>$2</table>', $page); # save to DomDocument $dom = new DomDocument(); libxml_use_internal_errors(true); ...
php
{ "resource": "" }
q267459
AccountMapper.findAllAccountByUserId
test
public function findAllAccountByUserId($userId, $excludeVirtual = true) { $this->addWhere('user_id', $userId); if ($excludeVirtual) { $this->addWhere('account_id_parent', 0); } $query = 'SELECT ' . $this->getQueryFields() . ' FROM ' . $this->getTable() . ' '...
php
{ "resource": "" }
q267460
CommandHandler.applicationMessage
test
protected function applicationMessage(): void { output()->formatter()->magenta(); output()->writeMessage('Valkyrja Application'); output()->formatter()->resetColor(); output()->writeMessage(' version '); output()->formatter()->cyan(); output()->writeMessage(Applicatio...
php
{ "resource": "" }
q267461
CommandHandler.usageMessage
test
protected function usageMessage(string $message = null): void { $message = $message ?? $this->usagePath(); $this->sectionTitleMessage('Usage'); output()->writeMessage(static::TAB); output()->writeMessage($message, true); }
php
{ "resource": "" }
q267462
CommandHandler.usagePath
test
protected function usagePath(): string { $message = static::COMMAND; if ($this->getOptions()) { $message .= ' [options]'; } foreach ($this->getArguments() as $argument) { $message .= ' ' . ($argument->getMode() === ArgumentMode::OPTIONAL ? '[...
php
{ "resource": "" }
q267463
CommandHandler.argumentsSection
test
protected function argumentsSection(Argument ...$arguments): void { if (! $arguments) { $arguments = $this->getArguments(); } if (! $arguments) { return; } $longestLength = 0; $this->sectionDivider(); $this->sectionTitleMessage('Argu...
php
{ "resource": "" }
q267464
CommandHandler.optionsSection
test
protected function optionsSection(Option ...$options): void { if (! $options) { $options = $this->getOptions(); } if (! $options) { return; } $longestLength = 0; $this->sectionDivider(); $this->sectionTitleMessage('Options'); ...
php
{ "resource": "" }
q267465
CommandHandler.getOptionName
test
protected function getOptionName(Option $option): string { $name = ''; if ($option->getShortcut()) { $name .= '-' . $option->getShortcut() . ', '; } else { $name .= static::DOUBLE_TAB; } $name .= '--' . $option->getName(); return $name; ...
php
{ "resource": "" }
q267466
Roller2d6DrdPlus.generateRoll
test
public function generateRoll($rollSummary): Roll2d6DrdPlus { $rollSummary = ToInteger::toInteger($rollSummary); $bonusDiceRolls = []; $malusDiceRolls = []; if ($rollSummary <= 2) { // two ones = malus rolls and one "not valid" malus roll $standardDiceRolls = [new Dice1d6R...
php
{ "resource": "" }
q267467
TableSearch.columns
test
public function columns(array $columns, $prefixColumnsWithTable = true) { $this->has_modified_columns = true; $this->select->columns($columns, $prefixColumnsWithTable); return $this; }
php
{ "resource": "" }
q267468
TableSearch.having
test
public function having($predicate, $combination = Predicate\PredicateSet::OP_AND) { $this->select->having($predicate, $combination); return $this; }
php
{ "resource": "" }
q267469
TableSearch.where
test
public function where($predicate, $combination = null) { $this->select->where($predicate, $combination); return $this; }
php
{ "resource": "" }
q267470
TableSearch.join
test
public function join($table, $on, $columns = []) { $prefixed_table = $this->prefixTableJoinCondition($table); //$this->columns($this->getPrefixedColumns()); $this->select->join($prefixed_table, $on, $columns, Select::JOIN_INNER); return $this; }
php
{ "resource": "" }
q267471
TableSearch.joinLeft
test
public function joinLeft($table, $on, $columns = []) { $prefixed_table = $this->prefixTableJoinCondition($table); $this->select->join($prefixed_table, $on, $columns, Select::JOIN_LEFT); return $this; }
php
{ "resource": "" }
q267472
TableSearch.joinRight
test
public function joinRight($table, $on, $columns = []) { $prefixed_table = $this->prefixTableJoinCondition($table); $this->select->join($prefixed_table, $on, $columns, Select::JOIN_RIGHT); return $this; }
php
{ "resource": "" }
q267473
TableSearch.getSql
test
public function getSql() { $adapterPlatform = $this->table->getTableManager()->getDbAdapter()->getPlatform(); return $this->select->getSqlString($adapterPlatform); }
php
{ "resource": "" }
q267474
TableSearch.execute
test
public function execute() { $rs = new ResultSet($this->select, $this->table, !$this->has_modified_columns); return $rs; }
php
{ "resource": "" }
q267475
TableSearch.prefixTableJoinCondition
test
protected function prefixTableJoinCondition($table) { $tm = $this->table->getTableManager(); if (is_array($table)) { $alias = key($table); $prefixed_table = $tm->getPrefixedTable($table[$alias]); $table = [$alias => $prefixed_table]; } elseif (is_string($t...
php
{ "resource": "" }
q267476
Collection.get
test
public function get(string $key, $default = null) // : mixed { return $this->has($key) ? $this->collection[$key] : $default; }
php
{ "resource": "" }
q267477
Collection.set
test
public function set(string $key, $value): self { $this->collection[$key] = $value; return $this; }
php
{ "resource": "" }
q267478
Collection.remove
test
public function remove(string $key): self { if (! $this->has($key)) { return $this; } unset($this->collection[$key]); return $this; }
php
{ "resource": "" }
q267479
SQL.insert
test
public static function insert($table, array $set) { $sql = $values = $fields = $holders = []; $sql[] = 'INSERT INTO ' . static::e($table); foreach($set as $field => $value) { $fields[] = static::e($field); $holders[] = '?'; $values[] = $value; } ...
php
{ "resource": "" }
q267480
PEAR_ErrorStack.PEAR_ErrorStack
test
function PEAR_ErrorStack($package, $msgCallback = false, $contextCallback = false, $throwPEAR_Error = false) { $this->_package = $package; $this->setMessageCallback($msgCallback); $this->setContextCallback($contextCallback); $this->_compat = $throwPEAR_Error;...
php
{ "resource": "" }
q267481
PEAR_ErrorStack.&
test
function &singleton($package, $msgCallback = false, $contextCallback = false, $throwPEAR_Error = false, $stackClass = 'PEAR_ErrorStack') { if (isset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package])) { return $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package]; } ...
php
{ "resource": "" }
q267482
PEAR_ErrorStack._handleError
test
function _handleError($err) { if ($err['level'] == 'exception') { $message = $err['message']; if (isset($_SERVER['REQUEST_URI'])) { echo '<br />'; } else { echo "\n"; } var_dump($err['context']); die($mes...
php
{ "resource": "" }
q267483
PEAR_ErrorStack.setMessageCallback
test
function setMessageCallback($msgCallback) { if (!$msgCallback) { $this->_msgCallback = array(&$this, 'getErrorMessage'); } else { if (is_callable($msgCallback)) { $this->_msgCallback = $msgCallback; } } }
php
{ "resource": "" }
q267484
PEAR_ErrorStack.setDefaultCallback
test
function setDefaultCallback($callback = false, $package = false) { if (!is_callable($callback)) { $callback = false; } $package = $package ? $package : '*'; $GLOBALS['_PEAR_ERRORSTACK_DEFAULT_CALLBACK'][$package] = $callback; }
php
{ "resource": "" }
q267485
PEAR_ErrorStack.pop
test
function pop() { $err = @array_shift($this->_errors); if (!is_null($err)) { @array_pop($this->_errorsByLevel[$err['level']]); if (!count($this->_errorsByLevel[$err['level']])) { unset($this->_errorsByLevel[$err['level']]); } } retur...
php
{ "resource": "" }
q267486
PEAR_ErrorStack.staticPop
test
function staticPop($package) { if ($package) { if (!isset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package])) { return false; } return $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package]->pop(); } }
php
{ "resource": "" }
q267487
PEAR_ErrorStack.hasErrors
test
function hasErrors($level = false) { if ($level) { return isset($this->_errorsByLevel[$level]); } return count($this->_errors); }
php
{ "resource": "" }
q267488
PEAR_ErrorStack.getErrors
test
function getErrors($purge = false, $level = false) { if (!$purge) { if ($level) { if (!isset($this->_errorsByLevel[$level])) { return array(); } else { return $this->_errorsByLevel[$level]; } } el...
php
{ "resource": "" }
q267489
PEAR_ErrorStack.staticHasErrors
test
function staticHasErrors($package = false, $level = false) { if ($package) { if (!isset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package])) { return false; } return $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package]->hasErrors($level); } forea...
php
{ "resource": "" }
q267490
PEAR_ErrorStack.staticGetErrors
test
function staticGetErrors($purge = false, $level = false, $merge = false, $sortfunc = array('PEAR_ErrorStack', '_sortErrors')) { $ret = array(); if (!is_callable($sortfunc)) { $sortfunc = array('PEAR_ErrorStack', '_sortErrors'); } foreach ($GLO...
php
{ "resource": "" }
q267491
PEAR_ErrorStack.getErrorMessage
test
function getErrorMessage(&$stack, $err, $template = false) { if ($template) { $mainmsg = $template; } else { $mainmsg = $stack->getErrorMessageTemplate($err['code']); } $mainmsg = str_replace('%__msg%', $err['message'], $mainmsg); if (is_array($err['pa...
php
{ "resource": "" }
q267492
ContainerBuilder.registerConfiguration
test
public function registerConfiguration(array $configuration): void { foreach ($configuration as $identifier => $value) { $this->container->addEntry($identifier, new MixedEntry($value)); } }
php
{ "resource": "" }
q267493
ContainerBuilder.registerProvider
test
public function registerProvider(EntryProvider $provider): void { $class = \get_class($provider); $this->container->addEntry($class, new CallableEntry([\get_class($provider), 'initialize'])); foreach ($provider->getMethods() as $identifier => $method) { $this->container->addEnt...
php
{ "resource": "" }
q267494
ContainerBuilder.registerAutowiredClasses
test
public function registerAutowiredClasses(array $classes, array $overrides = []): void { foreach ($classes as $class) { $reflection = new \ReflectionClass($class); $name = $reflection->getName(); $parameters = $this->getWiredParameters($reflection, $overrides); ...
php
{ "resource": "" }
q267495
ContainerBuilder.getWiredParameters
test
private function getWiredParameters(\ReflectionClass $reflection, array $overrides): array { $constructor = $reflection->getConstructor(); if (!$constructor instanceof \ReflectionMethod) { return []; } $parameters = []; foreach ($constructor->getParameters() as...
php
{ "resource": "" }
q267496
Zend_Filter_Compress_Tar.setTarget
test
public function setTarget($target) { if (!file_exists(dirname($target))) { throw new Zend_Filter_Exception("The directory '$target' does not exist"); } $target = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $target); $this->_options['target'] = (string) $target; ...
php
{ "resource": "" }
q267497
Zend_Filter_Compress_Tar.setMode
test
public function setMode($mode) { $mode = ucfirst(strtolower($mode)); if (($mode != 'Bz2') && ($mode != 'Gz')) { throw new Zend_Filter_Exception("The mode '$mode' is unknown"); } if (($mode == 'Bz2') && (!extension_loaded('bz2'))) { throw new Zend_Filter_Exc...
php
{ "resource": "" }
q267498
NativeRouteAnnotations.getRoutes
test
public function getRoutes(string ...$classes): array { $routes = $this->getClassRoutes($classes); /** @var \Valkyrja\Routing\Route[] $finalRoutes */ $finalRoutes = []; // Iterate through all the routes foreach ($routes as $route) { // Set the route's properties ...
php
{ "resource": "" }
q267499
NativeRouteAnnotations.setRouteProperties
test
protected function setRouteProperties(Route $route): void { if (null === $route->getProperty()) { $methodReflection = $this->getMethodReflection( $route->getClass(), $route->getMethod() ?? '__construct' ); // Set the dependencies ...
php
{ "resource": "" }