_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q266400
RequestHelper.getRawBody
test
public function getRawBody() { if ($this->_rawBody === null) { $this->_rawBody = $this->reactRequest->getBody(); } return $this->_rawBody; }
php
{ "resource": "" }
q266401
RequestHelper.getBodyParams
test
public function getBodyParams() { if ($this->_bodyParams === null) { $reactMethod = strtoupper($this->reactRequest->getMethod()); $reactBody = $this->reactRequest->getParsedBody(); if ($reactMethod === 'POST' && isset($reactBody[$this->methodParam])) { $th...
php
{ "resource": "" }
q266402
RequestHelper.getHostInfo
test
public function getHostInfo() { if ($this->_hostInfo === null) { $secure = $this->getIsSecureConnection(); $http = $secure ? 'https' : 'http'; $serverName = $this->getServerParam('SERVER_NAME'); if ($this->getHeaders()->has('X-Forwarded-Host')) { ...
php
{ "resource": "" }
q266403
RequestHelper.getScriptUrl
test
public function getScriptUrl() { $server = $this->getServerParams(); if ($this->_scriptUrl === null) { $scriptFile = $this->getScriptFile(); $scriptName = basename($scriptFile); if (isset($server['SCRIPT_NAME']) && basename($server['SCRIPT_NAME']) === $scriptName)...
php
{ "resource": "" }
q266404
RequestHelper.getServerParams
test
public function getServerParams() { if (!isset($this->_serverParams)) { $this->_serverParams = Reaction\Helpers\ArrayHelper::merge($this->getDefaultServerParams(), $this->reactRequest->getServerParams()); } return $this->_serverParams; }
php
{ "resource": "" }
q266405
RequestHelper.getAcceptableContentTypes
test
public function getAcceptableContentTypes() { if ($this->_contentTypes === null) { if ($this->getHeaders()->get('Accept') !== null) { $this->_contentTypes = $this->parseAcceptHeader($this->getHeaders()->get('Accept')); } else { $this->_contentTypes = [...
php
{ "resource": "" }
q266406
RequestHelper.getAcceptableLanguages
test
public function getAcceptableLanguages() { if ($this->_languages === null) { if ($this->getHeaders()->has('Accept-Language')) { /** @var string $acceptLangHeader */ $acceptLangHeader = $this->getHeaders()->get('Accept-Language'); $this->_languages ...
php
{ "resource": "" }
q266407
RequestHelper.getETags
test
public function getETags() { if ($this->getHeaders()->has('If-None-Match')) { /** @var string $ifNoneHeader */ $ifNoneHeader = $this->getHeaders()->get('If-None-Match'); $eTags = preg_split('/[\s,]+/', str_replace('-gzip', '', $ifNoneHeader), -1, PREG_SPLIT_NO_EMPTY); ...
php
{ "resource": "" }
q266408
RequestHelper.getCsrfToken
test
public function getCsrfToken($regenerate = false) { if ($this->_csrfToken === null || $regenerate) { $token = $this->loadCsrfToken(); if ($regenerate || empty($token)) { $token = $this->generateCsrfToken(); } $this->_csrfToken = Reaction::$app-...
php
{ "resource": "" }
q266409
RequestHelper.generateCsrfToken
test
protected function generateCsrfToken() { $token = Reaction::$app->security->generateRandomString(); if ($this->enableCsrfCookie) { $cookie = $this->createCsrfCookie($token); $this->app->response->getCookies()->add($cookie); } else { $this->app->session->se...
php
{ "resource": "" }
q266410
RequestHelper.getDefaultServerParams
test
protected function getDefaultServerParams() { $scriptName = realpath($_SERVER['SCRIPT_FILENAME']); //Default script name fallback if (!$scriptName) { $scriptName = getcwd() . DIRECTORY_SEPARATOR . 'app'; } $params = [ 'DOCUMENT_ROOT' => getcwd(), ...
php
{ "resource": "" }
q266411
LoginSuccess.onLogin
test
public function onLogin(InteractiveLoginEvent $event) { $user = $event->getAuthenticationToken()->getUser(); if ($user) { $user->setLastLogin(new \DateTime()); $user->setLogins($user->getLogins() + 1); $this->em->persist($user); $this->em->flush(); /*$request = $event->getRequest(); $session = ...
php
{ "resource": "" }
q266412
CropTwigExtension.crop
test
public function crop(array $croppable, $index = 0) { $coordinates = $croppable['coordinates'][$index]; $file = new UploadableFile($this->root_path, $croppable['image']); $name = $this->makeCropName($file, $coordinates); $path = $file->getRootPath() . $name; if (!file_exists...
php
{ "resource": "" }
q266413
CropTwigExtension.makeCropName
test
protected function makeCropName(UploadableFile $file, $coordinates) { $ext = $file->getExtension(); $suffix = implode('_', $coordinates); return preg_replace('/\.'. $ext .'$/ui', '_crop_'. $suffix .'.'. $ext, $file->getWebPath()); }
php
{ "resource": "" }
q266414
CropTwigExtension.doCrop
test
protected function doCrop(UploadableFile $file, $coordinates, $path) { $crop = imagecreatetruecolor($coordinates['min_width'], $coordinates['min_height']); switch ($file->getExtension()) { case 'gif': $source = imagecreatefromgif($file); break; case 'png': ...
php
{ "resource": "" }
q266415
CropTwigExtension.getSize
test
public function getSize($image, $relative = false) { if (!$image instanceof File) { if ($relative) { $image = $this->root_path . $image; } $image = new File($image); } return getimagesize($image->getRealPath()); }
php
{ "resource": "" }
q266416
WindowsPathBuilder.getPermutations
test
public function getPermutations($file) { $paths = $this->_appendFileToPaths($this->_paths, $file); return $this->_appendExtensionsToPaths($paths, $this->_extensions); }
php
{ "resource": "" }
q266417
NativeAnnotationsParser.getAnnotations
test
public function getAnnotations(string $docString): array { $annotations = []; // Get all matches of @ Annotations $matches = $this->getAnnotationMatches($docString); // If there are any matches iterate through them and create new // annotations if ($matches && isset...
php
{ "resource": "" }
q266418
NativeAnnotationsParser.getAnnotationMatches
test
protected function getAnnotationMatches(string $docString): ? array { preg_match_all($this->getRegex(), $docString, $matches); return $matches ?? null; }
php
{ "resource": "" }
q266419
NativeAnnotationsParser.setAnnotation
test
protected function setAnnotation(array $matches, int $index, array &$annotations): void { $properties = $this->getAnnotationProperties($matches, $index); // Get the annotation model from the annotations map $annotation = $this->getAnnotationFromMap($properties['annotation']); // Se...
php
{ "resource": "" }
q266420
NativeAnnotationsParser.setAnnotationArguments
test
protected function setAnnotationArguments(Annotation $annotation): void { $arguments = $annotation->getAnnotationArguments(); // Iterate through the arguments foreach ($annotation->getAnnotationArguments() as $key => $argument) { $methodName = 'set' . ucfirst($key); ...
php
{ "resource": "" }
q266421
NativeAnnotationsParser.getAnnotationProperties
test
protected function getAnnotationProperties(array $matches, int $index): array { $properties = []; // Written like this to appease the code coverage gods $properties['annotation'] = $matches[1][$index] ?? null; $properties['arguments'] = $matches[2][$index] ?? null; $prope...
php
{ "resource": "" }
q266422
NativeAnnotationsParser.processAnnotationProperties
test
protected function processAnnotationProperties(array $properties): array { // If the type and description exist by the variable does not // then that means the variable regex group captured the // first word of the description if ( $properties['type'] && $prop...
php
{ "resource": "" }
q266423
NativeAnnotationsParser.getArguments
test
public function getArguments(string $arguments = null): ? array { $argumentsList = null; // If a valid arguments list was passed in if (null !== $arguments && $arguments) { $testArgs = str_replace('=', ':', $arguments); $argumentsList = json_decode('{' . $testAr...
php
{ "resource": "" }
q266424
NativeAnnotationsParser.determineValue
test
protected function determineValue($value) { if (\is_array($value)) { foreach ($value as &$item) { $item = $this->determineValue($item); } unset($item); return $value; } // Trim the value of spaces $value = trim($value...
php
{ "resource": "" }
q266425
NativeAnnotationsParser.getAnnotationFromMap
test
public function getAnnotationFromMap(string $annotationType): Annotation { // Get the annotations map (annotation name to annotation class) $annotationsMap = $this->getAnnotationsMap(); // If an annotation is mapped to a class if ($annotationType && array_key_exists( ...
php
{ "resource": "" }
q266426
NativeAnnotationsParser.cleanMatch
test
protected function cleanMatch(string $match = null): ? string { if (! $match) { return $match; } return trim(str_replace('*', '', $match)); }
php
{ "resource": "" }
q266427
Plugin.getSubscribedEvents
test
public function getSubscribedEvents() { $subscribedEvents = array(); foreach ($this->validProviders as $provider => $class) { $subscribedEvents['command.' . $provider] = 'handleCommand'; $subscribedEvents['command.' . $provider . '.help'] = 'handleCommandHelp'; } ...
php
{ "resource": "" }
q266428
Plugin.handleCommand
test
public function handleCommand(Event $event, Queue $queue) { $provider = $this->getProvider($event->getCustomCommand()); if ($provider->validateParams($event->getCustomParams())) { $request = $this->getApiRequest($event, $queue); $this->getEventEmitter()->emit('http.request', ...
php
{ "resource": "" }
q266429
Plugin.handleCommandHelp
test
public function handleCommandHelp(Event $event, Queue $queue) { $provider = $this->getProvider($event->getCustomCommand()); $this->sendIrcResponse($event, $queue, $provider->getHelpLines()); }
php
{ "resource": "" }
q266430
Plugin.getProvider
test
public function getProvider($command) { return (isset($this->validProviders[$command])) ? $this->validProviders[$command] : false; }
php
{ "resource": "" }
q266431
Builder.leftJoin
test
public function leftJoin($table, $firstColumn, $operator = null, $secondColumn = null) { return $this->join($table, $firstColumn, $operator, $secondColumn, 'left'); }
php
{ "resource": "" }
q266432
Builder.rightJoin
test
public function rightJoin($table, $firstColumn, $operator = null, $secondColumn = null) { return $this->join($table, $firstColumn, $operator, $secondColumn, 'right'); }
php
{ "resource": "" }
q266433
Builder.rightJoinWhere
test
public function rightJoinWhere($table, $firstColumn, $operator, $value) { return $this->joinWhere($table, $firstColumn, $operator, $value, 'right'); }
php
{ "resource": "" }
q266434
Builder.toSql
test
public function toSql() { if ($this->type == 'insert') { return $this->grammar->compileInsert($this); } else if ($this->type == 'update') { return $this->grammar->compileUpdate($this); } else if ($this->type == 'delete') { return $this->grammar->compileDelete($this); } else { return $this->gramma...
php
{ "resource": "" }
q266435
Builder.fetchAllColumn
test
public function fetchAllColumn() { return $this->db->fetchRows($this->toSql(), $this->getBindings(), PDO::FETCH_COLUMN); }
php
{ "resource": "" }
q266436
AutoObject.setName
test
public function setName($name = null) { if (empty($name) || !is_string($name)) { throw new \InvalidArgumentException( sprintf('Object name is invalid! (must be a string, got "%s")', var_export($name,1)) ); } $this->object_table_name = $name; re...
php
{ "resource": "" }
q266437
AutoObject.setStructure
test
public function setStructure($structure = null) { if (empty($structure) || !is_array($structure)) { throw new \InvalidArgumentException( sprintf('Object structure is invalid! (must be an array, got "%s")', gettype($structure)) ); } $this->object_struct...
php
{ "resource": "" }
q266438
AutoObject.setDatabaseName
test
public function setDatabaseName($name = null) { if (empty($name) || !is_string($name)) { throw new \InvalidArgumentException( sprintf('Object database name is invalid! (must be a string, got "%s")', var_export($name,1)) ); } $this->object_database_name...
php
{ "resource": "" }
q266439
AutoObject.setModelName
test
public function setModelName($name = null) { if (empty($name) || !is_string($name)) { throw new \InvalidArgumentException( sprintf('Object model name is invalid! (must be a string, got "%s")', var_export($name,1)) ); } if (false===\CarteBlanche\App\Loa...
php
{ "resource": "" }
q266440
AutoObject._buildModel
test
protected function _buildModel($auto_populate = true, $advanced_search = false) { if (\CarteBlanche\App\Loader::classExists($this->object_model_name)) { try { $this->object_model = new $this->object_model_name( $this->getTableName(), $this-...
php
{ "resource": "" }
q266441
AutoObject._buildFields
test
protected function _buildFields() { $db = CarteBlanche::getContainer()->get('entity_manager') ->getStorageEngine($this->getDatabaseName()); foreach ($this->getStructureEntry('structure') as $_field=>$_data) { $_f = null; if (preg_match('/^(.*)_id$/i', $_field, $m...
php
{ "resource": "" }
q266442
ValidationServiceProvider.registerValidationFactory
test
protected function registerValidationFactory() { $this->app->singleton('validator', function ($app) { $validator = new Factory($app['translator'], $app); // The validation presence verifier is responsible for determining the existence // of values in a given data collection,...
php
{ "resource": "" }
q266443
LoggerConfigLoader.load
test
public function load(): array { return [ ServiceLocatorInterface::class => [ FactoryResolver::class => [ LoggerInterface::class => LoggerFactory::class, ], StaticFactoryResolver::class => [ BacktraceDecorator...
php
{ "resource": "" }
q266444
SortableFields.targetSiteId
test
protected function targetSiteId(ElementInterface $element = null): int { /** @var Element $element */ if (Craft::$app->getIsMultiSite() === true && $element !== null) { return $element->siteId; } return Craft::$app->getSites()->currentSite->id; }
php
{ "resource": "" }
q266445
Relation.getParent
test
public function getParent(Record $record, $parent_table) { if ($record->getState() == Record::STATE_DELETED) { throw new Exception\LogicException(__METHOD__ . ": Logic exception, cannot operate on record that was deleted"); } $tableName = $this->table->getTableName(); $r...
php
{ "resource": "" }
q266446
Collapse.renderItem
test
public function renderItem($item, $index) { $header = $item['label']; if (array_key_exists('content', $item)) { $id = $this->options['id'] . '-collapse-' . $index; $options = ArrayHelper::getValue($item, 'contentOptions', []); $options['id'] = $id; Htm...
php
{ "resource": "" }
q266447
Query.all
test
public function all($db = null) { if ($this->emulateExecution) { return new LazyPromise(function() { return resolve([]); }); } return $this->createCommand($db)->queryAll()->thenLazy( function($results) { return $this->populate($results); } ...
php
{ "resource": "" }
q266448
Query.one
test
public function one($db = null) { if ($this->emulateExecution) { return new LazyPromise(function() { return reject(null); }); } return $this->createCommand($db)->queryOne(); }
php
{ "resource": "" }
q266449
Query.column
test
public function column($db = null) { if ($this->emulateExecution) { return new LazyPromise(function() { return resolve([]); }); } if ($this->indexBy === null) { return $this->createCommand($db)->queryColumn(); } if (is_string($this->indexBy) && is_ar...
php
{ "resource": "" }
q266450
Query.count
test
public function count($q = '*', $db = null) { if ($this->emulateExecution) { return new LazyPromise(function() { return resolve(0); }); } return $this->queryScalar("COUNT($q)", $db); }
php
{ "resource": "" }
q266451
Query.exists
test
public function exists($db = null) { if ($this->emulateExecution) { return reject(false); } $command = $this->createCommand($db); $params = $command->params; $command->setSql($command->db->getQueryBuilder()->selectExists($command->getSql())); $command->bin...
php
{ "resource": "" }
q266452
CallCenter.makeCall
test
public function makeCall(NamespaceProphecy $prophecy, $name, array $arguments) { // For efficiency exclude 'args' from the generated backtrace // Limit backtrace to last 3 calls as we don't use the rest $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 4); $file = $line = nu...
php
{ "resource": "" }
q266453
CallCenter.findCalls
test
public function findCalls($functionName, ArgumentsWildcard $wildcard) { return array_values( array_filter($this->recordedCalls, function (Call $call) use ($wildcard, $functionName) { return $call->getMethodName() === $functionName && 0 < $wildcard->scoreArgume...
php
{ "resource": "" }
q266454
PEAR_Registry.PEAR_Registry
test
function PEAR_Registry($pear_install_dir = PEAR_INSTALL_DIR, $pear_channel = false, $pecl_channel = false) { parent::PEAR(); $this->setInstallDir($pear_install_dir); $this->_pearChannel = $pear_channel; $this->_peclChannel = $pecl_channel; $this->_c...
php
{ "resource": "" }
q266455
PEAR_Registry._assertStateDir
test
function _assertStateDir($channel = false) { if ($channel && $this->_getChannelFromAlias($channel) != 'pear.php.net') { return $this->_assertChannelStateDir($channel); } static $init = false; if (!file_exists($this->statedir)) { if (!$this->hasWriteAccess()) ...
php
{ "resource": "" }
q266456
PEAR_Registry._assertChannelStateDir
test
function _assertChannelStateDir($channel) { $ds = DIRECTORY_SEPARATOR; if (!$channel || $this->_getChannelFromAlias($channel) == 'pear.php.net') { if (!file_exists($this->channelsdir . $ds . 'pear.php.net.reg')) { $this->_initializeChannelDirs(); } ...
php
{ "resource": "" }
q266457
PEAR_Registry._assertChannelDir
test
function _assertChannelDir() { if (!file_exists($this->channelsdir)) { if (!$this->hasWriteAccess()) { return false; } require_once 'System.php'; if (!System::mkdir(array('-p', $this->channelsdir))) { return $this->raiseError("...
php
{ "resource": "" }
q266458
PEAR_Registry._channelFileName
test
function _channelFileName($channel, $noaliases = false) { if (!$noaliases) { if (file_exists($this->_getChannelAliasFileName($channel))) { $channel = implode('', file($this->_getChannelAliasFileName($channel))); } } return $this->channelsdir . DIRECTOR...
php
{ "resource": "" }
q266459
PEAR_Registry._getChannelFromAlias
test
function _getChannelFromAlias($channel) { if (!$this->_channelExists($channel)) { if ($channel == 'pear.php.net') { return 'pear.php.net'; } if ($channel == 'pecl.php.net') { return 'pecl.php.net'; } if ($channel =...
php
{ "resource": "" }
q266460
PEAR_Registry._getAlias
test
function _getAlias($channel) { if (!$this->_channelExists($channel)) { if ($channel == 'pear.php.net') { return 'pear'; } if ($channel == 'pecl.php.net') { return 'pecl'; } if ($channel == 'doc.php.net') { ...
php
{ "resource": "" }
q266461
PEAR_Registry._lock
test
function _lock($mode = LOCK_EX) { if (stristr(php_uname(), 'Windows 9')) { return true; } if ($mode != LOCK_UN && is_resource($this->lock_fp)) { // XXX does not check type of lock (LOCK_SH/LOCK_EX) return true; } if (!$this->_assertStateD...
php
{ "resource": "" }
q266462
PEAR_Registry._channelExists
test
function _channelExists($channel, $noaliases = false) { $a = file_exists($this->_channelFileName($channel, $noaliases)); if (!$a && $channel == 'pear.php.net') { return true; } if (!$a && $channel == 'pecl.php.net') { return true; } if (!$a &...
php
{ "resource": "" }
q266463
PEAR_Registry._mirrorExists
test
function _mirrorExists($channel, $mirror) { $data = $this->_channelInfo($channel); if (!isset($data['servers']['mirror'])) { return false; } foreach ($data['servers']['mirror'] as $m) { if ($m['attribs']['host'] == $mirror) { return true; ...
php
{ "resource": "" }
q266464
PEAR_Registry.isAlias
test
function isAlias($alias) { if (PEAR::isError($e = $this->_lock(LOCK_SH))) { return $e; } $ret = $this->_isChannelAlias($alias); $this->_unlock(); return $ret; }
php
{ "resource": "" }
q266465
PEAR_Registry.channelInfo
test
function channelInfo($channel = null, $noaliases = false) { if (PEAR::isError($e = $this->_lock(LOCK_SH))) { return $e; } $ret = $this->_channelInfo($channel, $noaliases); $this->_unlock(); return $ret; }
php
{ "resource": "" }
q266466
PEAR_Registry.updateChannel
test
function updateChannel($channel, $lastmodified = null) { if ($channel->getName() == '__uri') { return false; } return $this->addChannel($channel, $lastmodified, true); }
php
{ "resource": "" }
q266467
ClosureFilter.matches
test
public function matches(array $data) { return (isset($data[$this->property]) && call_user_func($this->function, $data[$this->property])); }
php
{ "resource": "" }
q266468
Wysiwyg.tinyMCEfile
test
public function tinyMCEfile() { $reflector = new \ReflectionClass('Jin2\Form\Components\Wysiwyg'); $tinyMCEUrl = dirname($reflector->getFileName()); $tinyMCEUrl .= '..' . DIRECTORY_SEPARATOR .'..' . DIRECTORY_SEPARATOR .'..' . DIRECTORY_SEPARATOR .'..' . DIRECTORY_SEPARATOR...
php
{ "resource": "" }
q266469
Str.InitWith
test
public static function InitWith($value) { $instance = new Str(); $instance->value = $value; $instance->IsValid(); return $instance; }
php
{ "resource": "" }
q266470
BaseController.getEntityManager
test
public function getEntityManager($name = null) { $entityManager = $this->getDoctrine()->getManager($name); if (!$entityManager->isOpen()) { $entityManager = $entityManager->create($entityManager->getConnection(), $entityManager->getConfiguration()); } return $entityManager; }
php
{ "resource": "" }
q266471
InterfaceResolver.resolve
test
public function resolve($className) { $trimmed = ltrim($className, '\\'); if (!$this->canResolve($trimmed)) return $className; return $this->implementations[$trimmed]; }
php
{ "resource": "" }
q266472
Validator.validateHashesTo
test
public function validateHashesTo($attribute, $value, $parameters) { $this->requireParameterCount(1, $parameters, 'hashes_to'); return $this->hasher->check($value, $parameters[0]); }
php
{ "resource": "" }
q266473
Validator.validateRouteExists
test
public function validateRouteExists($attribute, $value, $parameters) { $method = 'getBy' . studly_case(isset($parameters[0]) ? $parameters[0] : 'name'); $routes = $this->router->getRoutes(); return $routes->$method($value) !== null; }
php
{ "resource": "" }
q266474
AssetsInstallCommand._hardCopy
test
private function _hardCopy($originDir, $targetDir) { $filesystem = $this->getApplication()->getService('filesystem'); $filesystem->mkdir($targetDir, 0777); // We use a custom iterator to ignore VCS files $filesystem->mirror( $originDir, $targetDir, Finder::cr...
php
{ "resource": "" }
q266475
Button.init
test
public function init() { parent::init(); $this->clientOptions = false; $this->htmlHlp->addCssClass($this->options, ['widget' => 'btn']); }
php
{ "resource": "" }
q266476
Dt.getNextDay
test
public static function getNextDay($dt, $format = "Y-m-d") { $dtObj = \DateTime::createFromFormat($format, $dt); if (!$dtObj) { return ""; } return $dtObj->add(date_interval_create_from_date_string('1 days'))->format($format); }
php
{ "resource": "" }
q266477
Dt.getPrevDay
test
public static function getPrevDay($dt, $format = "Y-m-d") { $dtObj = \DateTime::createFromFormat($format, $dt); if (!$dtObj) { return ""; } return $dtObj->sub(date_interval_create_from_date_string('1 days'))->format($format); }
php
{ "resource": "" }
q266478
Dt.createDateRande
test
public static function createDateRande($from, $amount, $dtFormat='Y-m-d') { $range = [ $from ]; $curDt = $from; for($i=1; $i<$amount; $i++) { $curDt = \KsUtils\Dt::getNextDay($curDt, $dtFormat); $range[] = $curDt; } return $range; ...
php
{ "resource": "" }
q266479
FileHelperAsc.file
test
public static function file(&$filePath) { $filePath = \Reaction::$app->getAlias($filePath); $filePath = FileHelper::normalizePath($filePath); return static::getFs()->file($filePath); }
php
{ "resource": "" }
q266480
FileHelperAsc.dir
test
public static function dir(&$dirPath) { $dirPath = \Reaction::$app->getAlias($dirPath); $dirPath = FileHelper::normalizePath($dirPath); return static::getFs()->dir($dirPath); }
php
{ "resource": "" }
q266481
FileHelperAsc.open
test
public static function open($filePath, $flags = 'r') { $file = static::ensureFileObject($filePath); $createMode = FileHelper::permissionsAsString(static::$fileCreateMode); return $file->open($flags, $createMode); }
php
{ "resource": "" }
q266482
FileHelperAsc.create
test
public static function create($filePath, $mode = null, $time = null) { $mode = isset($mode) ? $mode : static::$fileCreateMode; $modeStr = static::permissionsAsString($mode); $time = is_int($time) ? $time : time(); $file = static::file($filePath); return $file->create($modeStr...
php
{ "resource": "" }
q266483
FileHelperAsc.putContents
test
public static function putContents($filePath, $contents, $openFlags = 'cwt', $lock = true, $createMode = null) { $lockTimeout = is_int($lock) && !empty($lock) ? $lock : null; $lock = !empty($lock); $file = static::ensureFileObject($filePath); $createMode = isset($createMode) ? $creat...
php
{ "resource": "" }
q266484
FileHelperAsc.getContents
test
public static function getContents($filePath, $lock = true) { $lockTimeout = is_int($lock) && !empty($lock) ? $lock : null; $lock = !empty($lock); $file = static::ensureFileObject($filePath); $unlockCallback = function ($result = null) use ($lock, $filePath) { if ($lock) ...
php
{ "resource": "" }
q266485
FileHelperAsc.chmod
test
public static function chmod($path, $mode = 0755) { if ($path instanceof GenericOperationInterface) { return $path->chmod($mode); } return static::file($path)->chmod($mode); }
php
{ "resource": "" }
q266486
FileHelperAsc.lock
test
public static function lock($filePath, $timeout = null) { $filePath = FileHelper::normalizePath($filePath); $timeout = isset($timeout) ? $timeout : static::$LockTimeout; $expire = time() + $timeout; if (isset(static::$_lockedFiles[$filePath])) { $expire = static::$_locked...
php
{ "resource": "" }
q266487
FileHelperAsc.onUnlock
test
public static function onUnlock($filePath) { $filePath = FileHelper::normalizePath($filePath); if (!static::isLocked($filePath)) { return resolve(true); } $deferred = new Deferred(); if (!isset(static::$_lockedFilesQueue[$filePath])) { static::$_lockedFile...
php
{ "resource": "" }
q266488
FileHelperAsc.ensureFileObject
test
protected static function ensureFileObject(&$pathOrObject) { if ($pathOrObject instanceof FileInterface) { return $pathOrObject; } elseif ($pathOrObject instanceof DirectoryInterface) { return static::file($pathOrObject->getPath()); } elseif (is_string($pathOrObject))...
php
{ "resource": "" }
q266489
FileHelperAsc.ensureDirObject
test
protected static function ensureDirObject(&$pathOrObject) { if ($pathOrObject instanceof DirectoryInterface) { return $pathOrObject; } elseif ($pathOrObject instanceof FileInterface) { return static::dir($pathOrObject->getPath()); } elseif (is_string($pathOrObject)) {...
php
{ "resource": "" }
q266490
FileHelperAsc.checkUnlockTimer
test
protected static function checkUnlockTimer() { if (static::$_unlockTimer instanceof TimerInterface) { return; } static::$_unlockTimer = \Reaction::$app->loop->addPeriodicTimer(1, function () { $now = time(); foreach (static::$_lockedFiles as $filePath => $time...
php
{ "resource": "" }
q266491
Request.globals
test
public static function globals() { static $globals; if(!$globals) { $globals = new static(Uri::current()); $globals->servers = &$_SERVER; $globals->envs = &$_ENV; $globals->values = &$_POST; $globals->cookies = &$_COOKIE; $glo...
php
{ "resource": "" }
q266492
ThemeSectionBase.render
test
public function render() { if (!file_exists($this->template)): throw new \Exception("Template of section is not defined."); endif; $func = $this->closedRender($this->template, $this->data); $func(); }
php
{ "resource": "" }
q266493
JoinClause.on
test
public function on($firstColumn, $operator, $secondColumn, $boolean = 'and', $where = false) { if ($where) $this->bindings[] = $secondColumn; if ($where && ($operator === 'in' || $operator === 'not in') && is_array($secondColumn)) { $secondColumn = count($secondColumn); } $this->clauses[] = compa...
php
{ "resource": "" }
q266494
JoinClause.where
test
public function where($firstColumn, $operator, $secondColumn, $boolean = 'and') { return $this->on($firstColumn, $operator, $secondColumn, $boolean, true); }
php
{ "resource": "" }
q266495
JoinClause.whereNull
test
public function whereNull($column, $boolean = 'and', $not = false) { $null = $not ? 'not null' : 'null'; return $this->on($column, 'is', $null, $boolean, false); }
php
{ "resource": "" }
q266496
HelperArrayCasterTrait.arrayToCollection
test
public function arrayToCollection(array $source, $collectionClass) { $manager = $this->manager; if ($manager instanceof ArrayCasterManagerInterface) { return $manager->process($source, $collectionClass); } throw new \LogicException( "The manager must ...
php
{ "resource": "" }
q266497
MoveSpec.it_could_be_normal
test
public function it_could_be_normal() { $this->isNormal()->shouldBeBool(); $this->isNormal()->shouldBe(true); $this->isSpecial()->shouldBe(false); $this->isSuper()->shouldBe(false); }
php
{ "resource": "" }
q266498
SessionArchiveInDb.getInternal
test
protected function getInternal($id, $unserialize = true) { return $this->selectQuery()->where(['sid' => $id]) ->one($this->db) ->then(function($row) use ($unserialize) { return $unserialize ? $this->getHandler()->unserializeData($row['data']) : $row; }); ...
php
{ "resource": "" }
q266499
SessionArchiveInDb.updateInternal
test
protected function updateInternal($row, $existingRow = null) { $equal = isset($existingRow) && isset($existingRow['data']) && $row['data'] === $existingRow['data']; $id = $row['sid']; unset($row['sid']); //If data not changed then just update timestamp if ($equal) { ...
php
{ "resource": "" }