_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 33
8k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q266700
|
TransactionAbstract.setType
|
test
|
public function setType($type)
{
$type = (string) $type;
if ($this->exists() && $this->type !== $type) {
$this->updated['type']
|
php
|
{
"resource": ""
}
|
q266701
|
TransactionAbstract.setComment
|
test
|
public function setComment($comment)
{
$comment = ($comment === null ? $comment : (string) $comment);
if ($this->exists() && $this->comment !== $comment) {
|
php
|
{
"resource": ""
}
|
q266702
|
TransactionAbstract.setCategoryId
|
test
|
public function setCategoryId($categoryId)
{
$categoryId = (int) $categoryId;
if ($this->categoryId < 0) {
throw new \UnderflowException('Value of "categoryId"
|
php
|
{
"resource": ""
}
|
q266703
|
TransactionAbstract.setAccountIdVirtual
|
test
|
public function setAccountIdVirtual($accountIdVirtual)
{
$accountIdVirtual = (int) $accountIdVirtual;
if ($this->accountIdVirtual < 0) {
throw new \UnderflowException('Value of "accountIdVirtual"
|
php
|
{
"resource": ""
}
|
q266704
|
TimeInterval.fromString
|
test
|
public static function fromString($startTime, $endTime): self
{
return new
|
php
|
{
"resource": ""
}
|
q266705
|
Database.fromArray
|
test
|
public static function fromArray(array $config)
{
if (!isset($config['engine'])) {
throw new \InvalidArgumentException("Missing engine: must be either 'mysql' or 'sqlite'");
}
if (!in_array(strtolower($config['engine']), ['sqlite', 'mysql'])) {
throw new \InvalidArgumentException("Unsupported engine {$config['engine']}");
}
if ($config['engine'] === 'sqlite') {
return static::sqlite(
$config['file'],
$config['options'] ?? []
|
php
|
{
"resource": ""
}
|
q266706
|
Database.sqlite
|
test
|
public static function sqlite(string $file, array $options = [])
{
$options = array_replace(static::$defaultOptions, $options);
$instance = new static("sqlite:{$file}", null, null, $options);
$instance->databaseType = 'sqlite';
|
php
|
{
"resource": ""
}
|
q266707
|
Database.mysql
|
test
|
public static function mysql(string $host, string $dbname, string $user = null, string $password = null, array $options = [])
{
$options = array_replace(static::$defaultOptions, $options);
|
php
|
{
"resource": ""
}
|
q266708
|
Database.run
|
test
|
public function run($sql, array $params = [], bool $returnStatement = false, int $fetchMode = PDO::FETCH_ASSOC)
{
if ($sql instanceof Query) {
$params = $sql->getParams();
$sql = $sql->getSql();
|
php
|
{
"resource": ""
}
|
q266709
|
Database.tableNames
|
test
|
public function tableNames()
{
if ($this->databaseType === 'mysql') {
$sql = "SHOW TABLES";
} elseif ($this->databaseType === 'sqlite') {
$sql = "SELECT name FROM sqlite_master WHERE type='table'";
} else {
throw new \RuntimeException("Unsupported database type: '{$this->databaseType}'");
|
php
|
{
"resource": ""
}
|
q266710
|
Database.row
|
test
|
public function row($sql, array $params = [], $rowNumber = 0)
{
$result = $this->run($sql, $params,
|
php
|
{
"resource": ""
}
|
q266711
|
Database.cell
|
test
|
public function cell($sql, array $params = [], $columnName = 0)
{
$result = $this->run($sql, $params,
|
php
|
{
"resource": ""
}
|
q266712
|
Database.tableExists
|
test
|
public function tableExists(string $tableName)
{
try {
$sql = "SELECT 1 FROM {$tableName} LIMIT 1";
$this->prepare($sql);
|
php
|
{
"resource": ""
}
|
q266713
|
Database.columnExists
|
test
|
public function columnExists(string $tableName, string $columnName)
{
if ($this->tableExists($tableName)) {
$names = array_flip($this->getColumnNames($tableName));
|
php
|
{
"resource": ""
}
|
q266714
|
Database.getPrimaryKeys
|
test
|
public function getPrimaryKeys(string $table, bool $asArray = false)
{
$pk = [];
if ($this->databaseType === 'mysql') {
$sql = "SHOW COLUMNS FROM {$table}";
$primaryKeyIndex = 'Key';
$primaryKeyValue = 'PRI';
$tableNameIndex = 'Field';
} elseif ($this->databaseType === 'sqlite') {
$sql = "PRAGMA table_info({$table})";
$primaryKeyIndex = 'pk';
$primaryKeyValue = 1;
$tableNameIndex = 'name';
} else {
throw new \RuntimeException("Unsupported database type: '{$this->databaseType}'");
}
$stm = $this->query($sql);
|
php
|
{
"resource": ""
}
|
q266715
|
Database.getColumnNames
|
test
|
public function getColumnNames(string $table, bool $withTableName = false, bool $aliased = false)
{
$cols = [];
if ($this->databaseType === 'mysql') {
$sql = "SHOW COLUMNS FROM {$table}";
$tableNameIndex = 'Field';
} elseif ($this->databaseType === 'sqlite') {
$sql = "PRAGMA table_info({$table})";
$tableNameIndex = 'name';
} else {
throw new \RuntimeException("Unsupported database type: '{$this->databaseType}'");
}
# Get all columns from a selected table
$r = $this->query($sql)->fetchAll();
$this->logQuery($sql);
|
php
|
{
"resource": ""
}
|
q266716
|
Database.logQuery
|
test
|
public function logQuery(string $sql, array $params = [])
{
if ($this->logger instanceof LoggerInterface) {
$message = $sql .
|
php
|
{
"resource": ""
}
|
q266717
|
Module.onBootstrap
|
test
|
public function onBootstrap(EventInterface $e)
{
/* @var $sm \Zend\ServiceManager\ServiceLocatorInterface */
$sm = $e->getApplication()->getServiceManager();
/* @var $em \Doctrine\ORM\EntityManager */
|
php
|
{
"resource": ""
}
|
q266718
|
OptimizeCommand.run
|
test
|
public function run(): int
{
// If the cache file already exists, delete it
if (file_exists(config()['cacheFilePath'])) {
unlink(config()['cacheFilePath']);
}
app()->setup(
[
'app' => [
'debug' => false,
'env' => 'production',
],
],
true
);
$containerCache = container()->getCacheable();
$consoleCache = console()->getCacheable();
$eventsCache = events()->getCacheable();
$routesCache = router()->getCacheable();
$configCache = config();
$configCache['cache']['container'] = $containerCache;
$configCache['cache']['console'] = $consoleCache;
$configCache['cache']['events'] = $eventsCache;
$configCache['cache']['routing'] = $routesCache;
$configCache['container']['useCache'] = true;
$configCache['console']['useCache'] = true;
|
php
|
{
"resource": ""
}
|
q266719
|
Zend_Filter_Encrypt_Openssl._setKeys
|
test
|
protected function _setKeys($keys)
{
if (!is_array($keys)) {
throw new Zend_Filter_Exception('Invalid options argument provided to filter');
}
foreach ($keys as $type => $key) {
if (is_file($key) and is_readable($key)) {
$file = fopen($key, 'r');
$cert = fread($file, 8192);
fclose($file);
} else {
$cert = $key;
$key = count($this->_keys[$type]);
}
switch ($type) {
case 'public':
$test = openssl_pkey_get_public($cert);
if ($test === false) {
throw new Zend_Filter_Exception("Public key '{$cert}' not valid");
}
openssl_free_key($test);
$this->_keys['public'][$key] = $cert;
break;
|
php
|
{
"resource": ""
}
|
q266720
|
Zend_Filter_Encrypt_Openssl.setPrivateKey
|
test
|
public function setPrivateKey($key, $passphrase = null)
{
if (is_array($key)) {
foreach($key as $type => $option) {
if ($type !== 'private') {
$key['private'] = $option;
unset($key[$type]);
}
}
} else {
|
php
|
{
"resource": ""
}
|
q266721
|
Zend_Filter_Encrypt_Openssl.setEnvelopeKey
|
test
|
public function setEnvelopeKey($key)
{
if (is_array($key)) {
foreach($key as $type => $option) {
if ($type !== 'envelope') {
$key['envelope'] = $option;
unset($key[$type]);
}
|
php
|
{
"resource": ""
}
|
q266722
|
Zend_Filter_Encrypt_Openssl.setCompression
|
test
|
public function setCompression($compression)
{
if (is_string($this->_compression)) {
$compression = array('adapter' => $compression);
|
php
|
{
"resource": ""
}
|
q266723
|
Base.tsGetFormatted
|
test
|
public function tsGetFormatted(\DateTime $tsProperty = null, $format = self::DEFAULT_DATE_FORMAT, $timezone = null)
{
if ($tsProperty === null) {
return '';
}
|
php
|
{
"resource": ""
}
|
q266724
|
Users.supprimerUtilisateur
|
test
|
public function supprimerUtilisateur($idUser) {
$oDateNow = new \DateTime('now');
$iReturn = $this->_oParamUsersRepository->supprimerUtilisateur($idUser, $oDateNow);
if($iReturn != 1) {
$aVarReturn = array(
'error' => true,
'reasons' => array(
'msg'=>'Une erreur s\'est produite durant la suppression'
|
php
|
{
"resource": ""
}
|
q266725
|
ReturnArgumentPromise.execute
|
test
|
public function execute(array $args, FunctionProphecy $function)
|
php
|
{
"resource": ""
}
|
q266726
|
MigrateController.createMigrationHistoryTable
|
test
|
protected function createMigrationHistoryTable()
{
$tableName = $this->db->getSchema()->getRawTableName($this->migrationTable);
$this->stdout("Creating migration history table \"$tableName\"...", Console::FG_YELLOW);
$promises = [];
$promises[] = $this->db->createCommand()->createTable($this->migrationTable, [
|
php
|
{
"resource": ""
}
|
q266727
|
Zend_Filter.addFilter
|
test
|
public function addFilter(Zend_Filter_Interface $filter, $placement = self::CHAIN_APPEND)
{
if ($placement == self::CHAIN_PREPEND) {
array_unshift($this->_filters, $filter);
|
php
|
{
"resource": ""
}
|
q266728
|
Zend_Filter.filterStatic
|
test
|
public static function filterStatic($value, $classBaseName, array $args = array(), $namespaces = array())
{
$namespaces = array_merge((array) $namespaces, self::$_defaultNamespaces, array('Zend_Filter'));
foreach ($namespaces as $namespace) {
$className = $namespace . '_' . ucfirst($classBaseName);
if (!class_exists($className, false)) {
try {
$file = str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
if (Zend_Loader::isReadable($file)) {
Zend_Loader::loadClass($className);
} else {
continue;
}
} catch (Zend_Exception $ze) {
continue;
|
php
|
{
"resource": ""
}
|
q266729
|
ActiveRelationTrait.addInverseRelations
|
test
|
protected function addInverseRelations(&$result)
{
if ($this->inverseOf === null) {
return;
}
foreach ($result as $i => $relatedModel) {
if ($relatedModel instanceof ActiveRecordInterface) {
if (!isset($inverseRelation)) {
$inverseRelation = $relatedModel->getRelation($this->inverseOf);
}
$relatedModel->populateRelation($this->inverseOf, $inverseRelation->multiple ? [$this->primaryModel] : $this->primaryModel);
} else {
if (!isset($inverseRelation)) {
|
php
|
{
"resource": ""
}
|
q266730
|
ActiveRelationTrait.populateRelation
|
test
|
public function populateRelation($name, &$primaryModels)
{
if (!is_array($this->link)) {
throw new InvalidConfigException('Invalid link: it must be an array of key-value pairs.');
}
$viaQuery = null;
$viaModels = null;
$viaModelsUsed = true;
if ($this->via instanceof self) {
// via junction table
/* @var $viaQuery ActiveRelationTrait */
$viaQuery = $this->via;
$filterPr = $viaQuery->findJunctionRows($primaryModels)->otherwise(
function() {
return [];
}
);
} elseif (is_array($this->via)) {
// via relation
/* @var $viaQuery ActiveRelationTrait|ActiveQueryTrait */
list($viaName, $viaQuery) = $this->via;
if ($viaQuery->asArray === null) {
// inherit asArray from primary query
$viaQuery->asArray($this->asArray);
}
$viaQuery->primaryModel = null;
$filterPr = $viaQuery->populateRelation($viaName, $primaryModels)->otherwise(
function() {
return [];
|
php
|
{
"resource": ""
}
|
q266731
|
ActiveRelationTrait.populateRelationAsyncSingle
|
test
|
protected function populateRelationAsyncSingle($name, &$primaryModels) {
return $this->one()->otherwise(function() { return null; })->then(
function($model) use ($name, &$primaryModels) {
$primaryModel = reset($primaryModels);
if ($primaryModel instanceof ActiveRecordInterface) {
$primaryModel->populateRelation($name, $model);
} else {
$primaryModels[key($primaryModels)][$name] = $model;
|
php
|
{
"resource": ""
}
|
q266732
|
ActiveRelationTrait.populateRelationAsyncMultiple
|
test
|
protected function populateRelationAsyncMultiple($name, &$primaryModels, $viaModels = null, $viaQuery = null) {
// https://github.com/yiisoft/yii2/issues/3197
// delay indexing related models after buckets are built
$indexBy = $this->indexBy;
$this->indexBy = null;
return $this->all()->otherwise(function() {
return [];
})->then(
function($models) use (&$primaryModels, $name, $viaModels, $viaQuery, $indexBy) {
if (isset($viaModels, $viaQuery)) {
$buckets = $this->buildBuckets($models, $this->link, $viaModels, $viaQuery->link);
} else {
$buckets = $this->buildBuckets($models, $this->link);
}
$this->indexBy = $indexBy;
if ($this->indexBy !== null && $this->multiple) {
$buckets = $this->indexBuckets($buckets, $this->indexBy);
}
$link = array_values(isset($viaQuery) ? $viaQuery->link : $this->link);
foreach ($primaryModels as $i => $primaryModel) {
if ($this->multiple && count($link) === 1 && is_array($keys = $primaryModel[reset($link)])) {
$value = [];
foreach ($keys as $key) {
$key = $this->normalizeModelKey($key);
if (isset($buckets[$key])) {
if ($this->indexBy !== null) {
// if indexBy is set, array_merge will cause renumbering of numeric array
foreach ($buckets[$key] as $bucketKey => $bucketValue) {
|
php
|
{
"resource": ""
}
|
q266733
|
Message.listInvalidProperties
|
test
|
public function listInvalidProperties()
{
$invalid_properties = [];
if ($this->container['source'] === null) {
$invalid_properties[] = "'source'
|
php
|
{
"resource": ""
}
|
q266734
|
Flatten.process
|
test
|
private function process(array $array, $prefix = '')
{
$result = [];
foreach ($array as $key => $value) {
// Subarrray handling needed?
if (is_array($value)) {
// __preserve key set tha signals us to store the array as it is?
if ($this->preserve_flagged_arrays && array_key_exists('__preserve', $value)) {
$result[$prefix . $key . $this->glue . 'array'] = $value;
unset($value['__preserve']);
}
|
php
|
{
"resource": ""
}
|
q266735
|
Entity.of
|
test
|
public static function of($class)
{
$reflector = new \ReflectionClass($class);
$name = Annotation::ofClass($class, 'entity') ?: strtolower($reflector->getShortName());
$entity = new static($name, $class);
$defaults = $reflector->getDefaultProperties();
foreach ($defaults as $property => $default) {
|
php
|
{
"resource": ""
}
|
q266736
|
Text.equals
|
test
|
public function equals(?Text $other = null): bool {
if($other === null) {
return false;
}
|
php
|
{
"resource": ""
}
|
q266737
|
Text.endsWith
|
test
|
public function endsWith(Text $other): bool {
return strrpos($this->raw,
|
php
|
{
"resource": ""
}
|
q266738
|
Text.contains
|
test
|
public function contains(Text $other): bool {
|
php
|
{
"resource": ""
}
|
q266739
|
Text.substring
|
test
|
public function substring(int $start, ?int $length = null): Text {
if($length === null) {
|
php
|
{
"resource": ""
}
|
q266740
|
Text.replace
|
test
|
public function replace(Text $search, Text $replace): Text
|
php
|
{
"resource": ""
}
|
q266741
|
Text.replaceByRegex
|
test
|
public function replaceByRegex(Regex $search, Text
|
php
|
{
"resource": ""
}
|
q266742
|
BaseActiveRecord.beforeSave
|
test
|
public function beforeSave($insert)
{
$eventName = $insert ? self::EVENT_BEFORE_INSERT : self::EVENT_BEFORE_UPDATE;
$isValid = true;
|
php
|
{
"resource": ""
}
|
q266743
|
BaseActiveRecord.beforeDelete
|
test
|
public function beforeDelete()
{
$isValid = true;
|
php
|
{
"resource": ""
}
|
q266744
|
BaseActiveRecord.refresh
|
test
|
public function refresh()
{
return static::findOne($this->getPrimaryKey(true))->then(
function($record) {
/* @var $record BaseActiveRecord */
|
php
|
{
"resource": ""
}
|
q266745
|
ActiveRecord.updateAll
|
test
|
public static function updateAll($attributes, $condition = '', $params = [], $connection = null)
{
$command = static::getDb()->createCommand();
$command->update(static::tableName(), $attributes, $condition, $params);
|
php
|
{
"resource": ""
}
|
q266746
|
ActiveRecord.deleteAll
|
test
|
public static function deleteAll($condition = null, $params = [], $connection = null)
{
$command = static::getDb()->createCommand();
$command->delete(static::tableName(), $condition, $params);
|
php
|
{
"resource": ""
}
|
q266747
|
ActiveRecord.insert
|
test
|
public function insert($runValidation = true, $attributes = null)
{
$validationPromise = $runValidation
? new LazyPromise(function() use ($attributes) {
return $this->validate($attributes);
})
: Reaction\Promise\resolveLazy(true);
return $validationPromise
->otherwiseLazy(function() {
Reaction::info('Model not inserted due to validation error in {method}.', ['method' => __METHOD__]);
return reject(new ValidationError("Model validation error"));
})->thenLazy(function() use ($attributes) {
if (!$this->isTransactional(self::OP_INSERT)) {
return new LazyPromise(function() use ($attributes) {
return $this->insertInternal($attributes);
});
}
$transaction = static::getDb()->createTransaction();
return $transaction->begin()->then(
function(ConnectionInterface $connection) use ($attributes) {
|
php
|
{
"resource": ""
}
|
q266748
|
ActiveRecord.insertInternal
|
test
|
protected function insertInternal($attributes = null, $connection = null)
{
if (!$this->beforeSave(true)) {
return reject(false);
}
$values = $this->getDirtyAttributes($attributes);
return static::getDb()->getSchema()->insert(static::tableName(), $values, $connection)->then(
function($primaryKeys) use ($values) {
if ($primaryKeys === false) {
return reject(false);
}
foreach ($primaryKeys as $name => $value) {
|
php
|
{
"resource": ""
}
|
q266749
|
ActiveRecord.deleteInternal
|
test
|
protected function deleteInternal($connection = null)
{
if (!$this->beforeDelete()) {
return Reaction\Promise\rejectLazy(false);
}
// we do not check the return value of deleteAll() because it's possible
// the record is already deleted in the database and thus the method will return 0
$condition = $this->getOldPrimaryKey(true);
$lock = $this->optimisticLock();
if ($lock !== null) {
$condition[$lock] = $this->$lock;
}
return static::deleteAll($condition, [], $connection)->thenLazy(
function($result)
|
php
|
{
"resource": ""
}
|
q266750
|
AbstractEntryProvider.getMethods
|
test
|
public function getMethods(): array
{
$methods = [];
$reflection = new \ReflectionClass($this);
foreach ($reflection->getMethods() as $method)
|
php
|
{
"resource": ""
}
|
q266751
|
AbstractEntryProvider.getMethodIdentifier
|
test
|
private function getMethodIdentifier(\ReflectionMethod $method): ?string
{
if (!$method->isPublic() || $method->isStatic()) {
return null;
}
if (preg_match('/^__[^_]/', $method->getName())) {
return null;
}
$type
|
php
|
{
"resource": ""
}
|
q266752
|
ResponseItemData.callbackCustomData
|
test
|
public function callbackCustomData($value, $raw) {
$defaultKeys = ['id','slugs','data','type','href','tags','lang','alternate_languages','linked_documents','first_publication_date','last_publication_date'];
foreach($raw as $key => $value) {
|
php
|
{
"resource": ""
}
|
q266753
|
HelpController.getCommands
|
test
|
public function getCommands($withInternal = false)
{$commands = [];
$namespaces = Reaction::$app->router->controllerNamespaces;
$controllers = Reaction\Helpers\ClassFinderHelper::findClassesPsr4($namespaces, true);
foreach ($controllers as $controllerClass) {
if (!$withInternal && Reaction\Helpers\ReflectionHelper::isImplements($controllerClass, 'Reaction\Routes\ControllerInternalInterface')) {
continue;
}
if ($this->validateControllerClass($controllerClass)) {
$relativePath = Reaction::$app->router->getRelativeControllerNamespace($controllerClass);
$pathArray = explode('\\', $relativePath);
$classBasename = array_pop($pathArray);
|
php
|
{
"resource": ""
}
|
q266754
|
HelpController.getCommandHelp
|
test
|
protected function getCommandHelp($controller)
{
$controller->color = $this->color;
$this->stdout("\nDESCRIPTION\n", Console::BOLD);
$comment = $controller->getHelp();
if ($comment !== '') {
$this->stdout("\n$comment\n\n");
}
$actions = $this->getActions($controller);
if (!empty($actions)) {
$this->stdout("\nSUB-COMMANDS\n\n", Console::BOLD);
$prefix = $controller->getUniqueId();
$maxlen = 5;
foreach ($actions as $action) {
$len = strlen($prefix . '/' . $action) + 2 + ($action === $controller->defaultAction ? 10 : 0);
if ($maxlen < $len) {
$maxlen = $len;
}
}
foreach ($actions as $action) {
$this->stdout('- ' . $this->ansiFormat($prefix . '/' . $action, Console::FG_YELLOW));
$len = strlen($prefix . '/' . $action) + 2;
if ($action === $controller->defaultAction) {
$this->stdout(' (default)', Console::FG_GREEN);
|
php
|
{
"resource": ""
}
|
q266755
|
HelpController.createController
|
test
|
protected function createController($command, $config = [], $defaultOnFault = true) {
|
php
|
{
"resource": ""
}
|
q266756
|
ErrorHandler.handleException
|
test
|
public function handleException($exception)
{
$this->exception = $exception;
try {
$this->logException($exception);
if ($this->discardExistingOutput) {
$this->clearOutput();
}
return $this->renderException($exception);
}
|
php
|
{
"resource": ""
}
|
q266757
|
ErrorHandler.handleFatalError
|
test
|
public function handleFatalError()
{
unset($this->_memoryReserve);
static::loadErrorExceptionClass();
$error = error_get_last();
if (ErrorException::isFatalError($error)) {
$exception = new ErrorException($error['message'], $error['type'],
|
php
|
{
"resource": ""
}
|
q266758
|
ErrorHandler.logException
|
test
|
public function logException($exception)
{
$category = get_class($exception);
if ($exception instanceof HttpException) {
$category = 'Reaction\\Exceptions\\HttpException:' . $exception->statusCode;
} elseif ($exception instanceof \ErrorException) {
$category .= ':' . $exception->getSeverity();
}
$message = $exception->getMessage();
$fileLine = '';
if ($exception->getFile() && $exception->getLine()) {
$fileLine = "\n" . $exception->getFile() . ':' . $exception->getLine();
|
php
|
{
"resource": ""
}
|
q266759
|
ErrorHandler.getExceptionTrace
|
test
|
public static function getExceptionTrace(\Throwable $exception, $asString = true) {
$trace = $exception->getTrace();
|
php
|
{
"resource": ""
}
|
q266760
|
ErrorHandler.reduceStackTrace
|
test
|
public static function reduceStackTrace(\Throwable $exception, $trace)
{
$exclude = [
'Reaction\Promise\Promise' => ['settle'],
'React\Promise\Promise' => ['settle'],
'Rx\Observer\AbstractObserver' => [],
'Rx\Observer\AutoDetachObserver' => [],
'Rx\Observer\CallbackObserver' => [],
];
$file = $exception->getFile();
$traceNew = [];
foreach ($trace as $num => $row) {
$rowFile = isset($row['file']) ? $row['file'] : null;
$rowClass = isset($row['class']) ? $row['class'] : null;
|
php
|
{
"resource": ""
}
|
q266761
|
RequestAppHelperProxy.proxyWithAppProperty
|
test
|
private function proxyWithAppProperty($method, $arguments = [], $position = -1, $propertyName = 'charset')
{
|
php
|
{
"resource": ""
}
|
q266762
|
RequestAppHelperProxy.proxyWithApp
|
test
|
protected function proxyWithApp($method, $arguments = [], $position = -1)
{
$this->injectVariableToArguments($this->app,
|
php
|
{
"resource": ""
}
|
q266763
|
RequestAppHelperProxy.injectVariableToArguments
|
test
|
protected function injectVariableToArguments($variable, &$arguments, $position = -1) {
$argsCount = count($arguments);
//Negative value handle (from end)
if ($position < 0) {
$position = $argsCount - $position;
|
php
|
{
"resource": ""
}
|
q266764
|
RequestAppHelperProxy.ensureTranslated
|
test
|
protected function ensureTranslated(&$string)
{
if (is_object($string) &&
|
php
|
{
"resource": ""
}
|
q266765
|
CreateGithubRepo.create
|
test
|
public function create(string $repoName) {
$this->getGithubAuthentication()->authenticate();
|
php
|
{
"resource": ""
}
|
q266766
|
Notification.startup
|
test
|
protected function startup($notification)
{
$reflect = new ReflectionClass($notification);
$this->configBase = 'notifications.' . $reflect->getShortName();
if (empty(config("{$this->configBase}.notification.name"))) {
$this->failed("Required notification.name is missing in notification configuration");
}
|
php
|
{
"resource": ""
}
|
q266767
|
SecurityKeyGenerator.random
|
test
|
public function random($prefix = ''){
$key = $prefix.$this->create().strval(rand(strlen($_SERVER['REMOTE_ADDR']), rand(111,2222)));
|
php
|
{
"resource": ""
}
|
q266768
|
Entity.forDataStore
|
test
|
public function forDataStore(): array
{
$properties = [];
// Otherwise iterate through the properties array
foreach (static::$properties as $property) {
$value = $this->{$property};
// Check if a type was set for this attribute
$type = static::$propertyTypes[$property] ?? null;
// If the type is object and the property isn't already an object
if ($type === PropertyType::OBJECT && \is_object($value)) {
// Unserialize the object
$value = serialize($value);
|
php
|
{
"resource": ""
}
|
q266769
|
Assert.registerClass
|
test
|
public static function registerClass(
/*int*/ $customType,
/*string*/ $customClassName
) {
$customType = @intval($customType);
if(0x1000 > $customType) {
self::raise([
'message' => 'Unique id for a custom error starts from 0x1000',
'type' => Exceptions\Error::TYPE_ARGUMENT,
'magic' => 0xf181
]);
}
// One custom class for each unique id.
if(isset(self::$customErrors[$customType])) {
self::raise([
'message' => sprintf(
'Unique id (%d) has already been assigned a custom error',
$customType
),
'type' => Exceptions\Error::TYPE_ARGUMENT,
'magic' => 0xf182
]);
}
// Remove any white spaces from the class name.
$customClassName = @trim($customClassName);
|
php
|
{
"resource": ""
}
|
q266770
|
AssignmentController.actionAssign
|
test
|
public function actionAssign($id) {
$model = Yii::createObject([
'class' => Assignment::className(),
'user_id' => $id,
]);
if ($model->load(\Yii::$app->request->post()) && $model->updateAssignments()) {
|
php
|
{
"resource": ""
}
|
q266771
|
Search.requestForCountries
|
test
|
public function requestForCountries($countries = array())
{
if (empty($countries)) {
$countries = self::$countryList;
}
$results = array();
foreach ($countries as $country) {
|
php
|
{
"resource": ""
}
|
q266772
|
StringTools.htmlEncode
|
test
|
public static function htmlEncode($string, $specialChars = true)
{
if ($specialChars) {
|
php
|
{
"resource": ""
}
|
q266773
|
HTTP_Request2_Response.getDefaultReasonPhrase
|
test
|
public static function getDefaultReasonPhrase($code = null)
{
if (null === $code) {
return self::$phrases;
} else {
return
|
php
|
{
"resource": ""
}
|
q266774
|
HTTP_Request2_Response.getHeader
|
test
|
public function getHeader($headerName = null)
{
if (null === $headerName) {
return $this->headers;
} else {
$headerName = strtolower($headerName);
|
php
|
{
"resource": ""
}
|
q266775
|
HTTP_Request2_Response.getBody
|
test
|
public function getBody()
{
if (0 == strlen($this->body) || !$this->bodyEncoded
|| !in_array(strtolower($this->getHeader('content-encoding')), array('gzip', 'deflate'))
) {
return $this->body;
} else {
if (extension_loaded('mbstring') && (2 & ini_get('mbstring.func_overload'))) {
$oldEncoding = mb_internal_encoding();
mb_internal_encoding('8bit');
}
try {
switch (strtolower($this->getHeader('content-encoding'))) {
case 'gzip':
$decoded = self::decodeGzip($this->body);
break;
case 'deflate':
|
php
|
{
"resource": ""
}
|
q266776
|
HTTP_Request2_Response.decodeDeflate
|
test
|
public static function decodeDeflate($data)
{
if (!function_exists('gzuncompress')) {
throw new HTTP_Request2_LogicException(
'Unable to decode body: gzip extension not available',
HTTP_Request2_Exception::MISCONFIGURATION
);
|
php
|
{
"resource": ""
}
|
q266777
|
Builder.exists
|
test
|
public function exists()
{
try {
$sql = SQL::tableExists($this->entity->name);
return $this->execute($sql);
|
php
|
{
"resource": ""
}
|
q266778
|
Builder.clear
|
test
|
public function clear()
{
$sql = SQL::truncateTable($this->entity->name);
|
php
|
{
"resource": ""
}
|
q266779
|
Connections.checking
|
test
|
private function checking() : void
{
$cleared = ! ($this->cIdleCount() + $this->cBusyCount());
if ($this->exiting) {
if ($this->pool && ($closed = $this->pool->closed())->pended() && $cleared) {
$closed->resolve();
}
return;
}
$cleared && $this->resizing(
|
php
|
{
"resource": ""
}
|
q266780
|
Server.getHeaders
|
test
|
public function getHeaders(): array
{
$headers = [];
$specialHeaders = self::SPECIAL_HEADERS;
foreach ($this->collection as $key => $value) {
if (
\in_array($key, $specialHeaders, true)
|
php
|
{
"resource": ""
}
|
q266781
|
Server.getHeaderName
|
test
|
protected function getHeaderName($header): string
{
if (0 === strpos($header, 'HTTP_')) {
$header = substr($header, 5);
}
$header =
str_replace(
' ',
'-',
|
php
|
{
"resource": ""
}
|
q266782
|
NativeOutput.write
|
test
|
public function write(array $messages, bool $newLine = null, OutputStyle $outputStyle = null): void
|
php
|
{
"resource": ""
}
|
q266783
|
NativeOutput.writeMessage
|
test
|
public function writeMessage(string $message, bool $newLine = null, OutputStyle $outputStyle = null): void
{
$newLine = $newLine ?? false;
$outputStyleType =
$outputStyle ? $outputStyle->getValue() : OutputStyle::NORMAL;
switch ($outputStyleType) {
case OutputStyle::NORMAL:
$message = $this->formatter->format($message);
break;
case OutputStyle::RAW:
|
php
|
{
"resource": ""
}
|
q266784
|
Zend_Filter_Null.setType
|
test
|
public function setType($type = null)
{
if (is_array($type)) {
$detected = 0;
foreach($type as $value) {
if (is_int($value)) {
$detected += $value;
} else if (in_array($value, $this->_constants)) {
$detected += array_search($value, $this->_constants);
}
}
$type = $detected;
} else if (is_string($type)) {
if
|
php
|
{
"resource": ""
}
|
q266785
|
FileFinder.findInPaths
|
test
|
protected function findInPaths($name, array $paths)
{
foreach ($paths as $path) {
foreach ($this->getPossibleFiles($name) as $file) {
if ($this->fs->exists($viewPath = $path.'/'.$file)) {
|
php
|
{
"resource": ""
}
|
q266786
|
FileFinder.getPossibleFiles
|
test
|
protected function getPossibleFiles($name)
{
return array_map(function($extension) use
|
php
|
{
"resource": ""
}
|
q266787
|
NativeSession.start
|
test
|
public function start(): void
{
// If the session is already active
if ($this->isActive() || headers_sent()) {
// No need to reactivate
return;
|
php
|
{
"resource": ""
}
|
q266788
|
NativeSession.get
|
test
|
public function get(string $id)
{
|
php
|
{
"resource": ""
}
|
q266789
|
NativeSession.set
|
test
|
public function set(string $id, string $value): void
{
|
php
|
{
"resource": ""
}
|
q266790
|
NativeSession.remove
|
test
|
public function remove(string $id): bool
{
if (! $this->has($id)) {
|
php
|
{
"resource": ""
}
|
q266791
|
NativeSession.csrf
|
test
|
public function csrf(string $id): string
{
$token = bin2hex(random_bytes(64));
|
php
|
{
"resource": ""
}
|
q266792
|
NativeSession.validateCsrf
|
test
|
public function validateCsrf(string $id, string $token): bool
{
if (! $this->has($id)) {
return false;
}
$sessionToken = $this->get($id);
if (! \is_string($sessionToken)) {
return
|
php
|
{
"resource": ""
}
|
q266793
|
Inflector.humanize
|
test
|
public static function humanize($name)
{
if (empty($name)) {
return '';
}
$word = static::tableize(static::classify($name), ' ');
|
php
|
{
"resource": ""
}
|
q266794
|
File.delete
|
test
|
public function delete($clean_only = false): bool
{
$path = $this->replaceDirectorySeperator($this->filename);
if (!file_exists($path)) {
return true;
}
if (!is_dir($path)) {
return unlink($path);
}
$files = scandir($path);
foreach ($files as $item) {
$file = $path . DIRECTORY_SEPARATOR . $item;
if (is_dir($file)) {
|
php
|
{
"resource": ""
}
|
q266795
|
File.move
|
test
|
public function move($destination)
{
if (copy($this->filename, $destination)) {
unlink($this->filename);
$this->filename = $destination;
|
php
|
{
"resource": ""
}
|
q266796
|
File.clean
|
test
|
public function clean($delimiter = '-')
{
// The fileextension should not be normalized.
if (strrpos($this->filename, '.') !== false) {
list ($name, $extension) = explode('.', $this->filename);
}
$normalize = new Normalize($name);
$name = $normalize->normalize();
$name = preg_replace('/[^[:alnum:]\-]+/', $delimiter, $name);
|
php
|
{
"resource": ""
}
|
q266797
|
DispatcherAwareTrait.dispatch
|
test
|
final public function dispatch($name, EventInterface $event)
{
if ($this->hasDispatcher()) {
|
php
|
{
"resource": ""
}
|
q266798
|
Error.handle
|
test
|
public function handle($level, $message, $file, $line, $context)
{
if ( $this->level === 0 ) return true;
if ( $level & (E_USER_DEPRECATED | E_DEPRECATED) ) {
if (self::$logger !== null) {
if ( version_compare(PHP_VERSION, '5.4', '<') ) {
$stack = array_slice(debug_backtrace(false), 0, 10);
} else {
$stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 10);
}
|
php
|
{
"resource": ""
}
|
q266799
|
Error.handleFatal
|
test
|
public function handleFatal()
{
$error = $this->getLastError();
if ($error === null) return;
unset($this->reservedMemory);
$type = $error['type'];
if ( $this->level === 0 || !in_array($type, array(E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE))) {
return;
}
// get current exception handler
$exceptionHandler = set_exception_handler(function() {});
restore_exception_handler();
if (
|
php
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.