_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])) { $this->_bodyParams = $reactBody; unset($this->_bodyParams[$this->methodParam]); return $this->_bodyParams; } $rawContentType = $this->getContentType(); if (($pos = strpos($rawContentType, ';')) !== false) { // e.g. text/html; charset=UTF-8 $contentType = substr($rawContentType, 0, $pos); } else { $contentType = $rawContentType; } if (isset($this->parsers[$contentType])) { $parser = Reaction::create($this->parsers[$contentType]); if (!($parser instanceof RequestParserInterface)) { throw new InvalidConfigException("The '$contentType' request parser is invalid. It must implement the Reaction\\Web\\RequestParserInterface."); } $this->_bodyParams = $parser->parse($this->getRawBody(), $rawContentType); } elseif (isset($this->parsers['*'])) { $parser = Reaction::create($this->parsers['*']); if (!($parser instanceof RequestParserInterface)) { throw new InvalidConfigException('The fallback request parser is invalid. It must implement the Reaction\\Web\\RequestParserInterface.'); } $this->_bodyParams = $parser->parse($this->getRawBody(), $rawContentType); } elseif ($this->getMethod() === 'POST') { // PHP has already parsed the body so we have all params in $_POST $this->_bodyParams = $reactBody; } else { $this->_bodyParams = []; mb_parse_str($this->getRawBody(), $this->_bodyParams); } } return $this->_bodyParams; }
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')) { $this->_hostInfo = $http . '://' . $this->getHeaders()->get('X-Forwarded-Host'); } elseif ($this->getHeaders()->has('Host')) { $this->_hostInfo = $http . '://' . $this->getHeaders()->get('Host'); } elseif (isset($serverName)) { $this->_hostInfo = $http . '://' . $serverName; $port = $secure ? $this->getSecurePort() : $this->getPort(); if (($port !== 80 && !$secure) || ($port !== 443 && $secure)) { $this->_hostInfo .= ':' . $port; } } } return $this->_hostInfo; }
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) { $this->_scriptUrl = $server['SCRIPT_NAME']; } elseif (isset($server['PHP_SELF']) && basename($server['PHP_SELF']) === $scriptName) { $this->_scriptUrl = $server['PHP_SELF']; } elseif (isset($server['ORIG_SCRIPT_NAME']) && basename($server['ORIG_SCRIPT_NAME']) === $scriptName) { $this->_scriptUrl = $server['ORIG_SCRIPT_NAME']; } elseif (isset($server['PHP_SELF']) && ($pos = strpos($server['PHP_SELF'], '/' . $scriptName)) !== false) { $this->_scriptUrl = substr($server['SCRIPT_NAME'], 0, $pos) . '/' . $scriptName; } elseif (!empty($server['DOCUMENT_ROOT']) && strpos($scriptFile, $server['DOCUMENT_ROOT']) === 0) { $this->_scriptUrl = str_replace([$server['DOCUMENT_ROOT'], '\\'], ['', '/'], $scriptFile); } else { throw new InvalidConfigException('Unable to determine the entry script URL.'); } } return $this->_scriptUrl; }
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 = []; } } return $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 = array_keys($this->parseAcceptHeader($acceptLangHeader)); } else { $this->_languages = []; } } return $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); return is_array($eTags) ? $eTags : []; } return []; }
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->security->maskToken($token); } return $this->_csrfToken; }
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->set($this->csrfParam, $token); } return $token; }
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(), 'SCRIPT_FILENAME' => $scriptName, ]; return $params; }
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 = $request->getSession(); if (null != $user->getPreferedLocale()) { $locale = $user->getPreferedLocale(); $session->set('_locale', $locale->getPrefix()); }*/ } }
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($path)) { $this->doCrop($file, $coordinates, $path); } return $name; }
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': $source = imagecreatefrompng($file); break; default: $source = imagecreatefromjpeg($file); } if (preg_match('/^(gif|png)$/', $file->getExtension())) { imagecolortransparent($crop, imagecolorallocatealpha($crop, 0, 0, 0, 127)); imagealphablending($crop, false); imagesavealpha($crop, true); } imagecopyresampled( $crop, $source, 0, 0, $coordinates['left'], $coordinates['top'], $coordinates['min_width'], $coordinates['min_height'], $coordinates['width'], $coordinates['height'] ); switch ($file->getExtension()) { case 'gif': imagegif($crop, $path); break; case 'png': imagepng($crop, $path); break; default: imagejpeg($crop, $path, 100); } }
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($matches[0], $matches[1])) { foreach ($matches[0] as $index => $match) { $this->setAnnotation($matches, $index, $annotations); } } return $annotations; }
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']); // Set the annotation's type $annotation->setAnnotationType($properties['annotation']); // If there are arguments if (null !== $properties['arguments'] && $properties['arguments']) { // Filter the arguments and set them in the annotation $annotation->setAnnotationArguments( $this->getArguments($properties['arguments']) ); // Having set the arguments there's no need to retain this key in // the properties unset($properties['arguments']); // Set the annotation's arguments to setters if they exist $this->setAnnotationArguments($annotation); // If all arguments have been set to their own properties in the // annotation model if (empty($annotation->getAnnotationArguments())) { // Set the arguments to null $annotation->setAnnotationArguments(); } } // Set all the matches $annotation->setMatches($properties); // Set the annotation in the list $annotations[] = $annotation; }
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); // Check if there is a setter function for this argument if (method_exists($annotation, $methodName)) { // Set the argument using the setter $annotation->{$methodName}($argument); // Unset from the arguments array unset($arguments[$key]); } } $annotation->setAnnotationArguments($arguments); }
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; $properties['type'] = $matches[3][$index] ?? null; $properties['variable'] = $matches[4][$index] ?? null; $properties['description'] = $matches[5][$index] ?? null; return $this->processAnnotationProperties($properties); }
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'] && $properties['description'] && ! $properties['variable'] ) { // Rectify this by concatenating the type and description $properties['description'] = $properties['type'] . $properties['description']; // Then unset the type unset($properties['type']); } // Iterate through the properties foreach ($properties as &$property) { // Clean each one $property = $this->cleanMatch($property); } return $properties; }
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('{' . $testArgs . '}', true); if (\is_array($argumentsList)) { foreach ($argumentsList as &$value) { $value = $this->determineValue($value); } unset($value); } return $argumentsList; } return $argumentsList; }
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); // If there was no double colon found there's no need to go further if (strpos($value, '::') === false) { return $value; } // Determine if the value is a constant if (\defined($value)) { // Set the value as the constant's value return \constant($value); } [$class, $member] = explode('::', $value); // Check for static property if (property_exists($class, $member)) { return $class::$$member; } // Check for static method if (method_exists($class, $member)) { return $class::$member(); } return $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( $annotationType, $annotationsMap ) ) { // Set a new class based on the match found $annotation = new $annotationsMap[$annotationType](); } else { // Otherwise set a new base annotation model $annotation = new Annotation(); } return $annotation; }
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'; } return $subscribedEvents; }
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', array($request)); } else { $this->handleCommandhelp($event, $queue); } }
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->grammar->compileSelect($this); } }
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; return $this; }
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_structure = $structure; return $this; }
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 = $name; return $this; }
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\Loader::classExists($name)) { throw new \InvalidArgumentException( sprintf('Object model\'s class can\'t be found! (got "%s")', var_export($name,1)) ); } $this->object_model_name = $name; return $this; }
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->getFields(), $this->getStructure(), $auto_populate, $advanced_search ); $db = CarteBlanche::getContainer()->get('entity_manager') ->getStorageEngine($this->getDatabaseName()); $this->object_model->setStorageEngine($db); } catch ( \Exception $e ) { throw new \Exception( sprintf('Model "%s" constructor seems not compliant with the "\CarteBlanche\Interfaces\ModelInterface" interface!', $this->object_model_name) ); } } else { trigger_error( sprintf('Model "%s" can\'t be found!', $this->object_model_name), E_USER_ERROR); } }
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, $matches)) { if (isset($matches[1]) && is_string($matches[1])) { $related_object = $matches[1]; if ($related_object=='parent') $related_object = $this->getTableName(); $table = AutoObjectMapper::getAutoObject($related_object, $this->getDatabaseName()); $_f = new Relation( $_field, $_data, $db, $related_object, $table->getModel() ); } } else { $_f = new Field( $_field, $_data, $db ); } if (!is_null($_f)) $this->object_fields->setEntry( $_field, $_f ); } }
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, typically a relational database or // other persistent data stores. And it is used to check for uniqueness. if(isset($app['validation.presence'])) { $validator->setPresenceVerifier($app['validation.presence']); } return $validator; }); }
php
{ "resource": "" }
q266443
LoggerConfigLoader.load
test
public function load(): array { return [ ServiceLocatorInterface::class => [ FactoryResolver::class => [ LoggerInterface::class => LoggerFactory::class, ], StaticFactoryResolver::class => [ BacktraceDecorator::class => BacktraceDecorator::class, PriorityFilter::class => PriorityFilter::class, AlertPriority::class => AlertPriority::class, CriticalPriority::class => CriticalPriority::class, DebugPriority::class => DebugPriority::class, EmergencyPriority::class => EmergencyPriority::class, ErrorPriority::class => ErrorPriority::class, InformationalPriority::class => InformationalPriority::class, NoticePriority::class => NoticePriority::class, WarningPriority::class => WarningPriority::class, FileWriter::class => FileWriter::class, PdoWriter::class => PdoWriter::class, ], ReflectionResolver::class => [ LoggerMiddleware::class => LoggerMiddleware::class, ], ], LoggerInterface::class => [ 'writers' => [], ], ]; }
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(); $relations = $this->table->getTableManager()->metadata()->getForeignKeys($tableName); //$rels = array(); foreach ($relations as $column => $parent) { if ($parent['referenced_table'] == $parent_table) { // @todo, check the case when // table has many relations to the same parent // we'll have to throw an exception $record = $this->table->getTableManager()->table($parent_table)->findOneBy([ $parent['referenced_column'] => $record->offsetGet($column) ]); return $record; } } throw new Exception\RelationNotFoundException(__METHOD__ . ": Cannot find parent relation between table '$tableName' and '$parent_table'"); }
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; Html::addCssClass($options, ['widget' => 'collapse']); $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels; if ($encodeLabel) { $header = $this->htmlHlp->encode($header); } $headerOptions = [ 'class' => 'collapse-toggle', 'data-toggle' => 'collapse', ]; $headerToggle = $this->htmlHlp->a($header, '#' . $id, $headerOptions) . "\n"; if (is_string($item['content']) || is_numeric($item['content']) || is_object($item['content'])) { $content = $this->htmlHlp->tag('div', $item['content'], ['class' => 'card-body']) . "\n"; } elseif (is_array($item['content'])) { $content = $this->htmlHlp->ul($item['content'], [ 'class' => 'list-group list-group-flush', 'itemOptions' => [ 'class' => 'list-group-item' ], 'encode' => false, ]) . "\n"; } else { throw new InvalidConfigException('The "content" option should be a string, array or object.'); } } else { throw new InvalidConfigException('The "content" option is required.'); } if ($this->autoCloseItems) { $options['data-parent'] = '#' . $this->options['id']; } $contentCollapse = $this->htmlHlp->tag('div', $content, $options); $cardConfig = [ 'app' => $this->app, 'options' => [ 'id' => $this->id . '-collapse-card-' . $index, ], 'body' => $contentCollapse, 'bodyOptions' => null, 'header' => $headerToggle, 'footer' => isset($item['footer']) ? $item['footer'] : null, ]; return Card::widget($cardConfig); }
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_array($this->select) && count($this->select) === 1) { if (strpos($this->indexBy, '.') === false && count($tables = $this->getTablesUsedInFrom()) > 0) { $this->select[] = key($tables) . '.' . $this->indexBy; } else { $this->select[] = $this->indexBy; } } return $this->createCommand($db)->queryAll()->thenLazy( function($results) { $rows = []; foreach ($results as $row) { $value = reset($row); if ($this->indexBy instanceof \Closure) { $rows[call_user_func($this->indexBy, $row)] = $value; } else { $rows[$row[$this->indexBy]] = $value; } } return $rows; } ); }
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->bindValues($params); return $command->queryScalar() ->thenLazy(function($count = 0) { return $count > 0 ? true : reject(new Error("Does not exist")); }); }
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 = null; if (isset($backtrace[3]) && isset($backtrace[3]['file'])) { $file = $backtrace[3]['file']; $line = $backtrace[3]['line']; } // There are method prophecies, so it's a fake/stub. Searching prophecy for this call $matches = []; foreach ($prophecy->getProphecies() as $methodProphecy) { if ($methodProphecy->getName() !== $name) { continue; } if (0 < $score = $methodProphecy->getArgumentsWildcard()->scoreArguments($arguments)) { $matches[] = [$score, $methodProphecy]; } } // If fake/stub doesn't have method prophecy for this call - throw exception if (!count($matches)) { throw $this->createUnexpectedCallException($prophecy, $name, $arguments); } // Sort matches by their score value @usort($matches, function ($match1, $match2) { return $match2[0] - $match1[0]; }); // If Highest rated method prophecy has a promise - execute it or return null instead $returnValue = null; $exception = null; if ($promise = $matches[0][1]->getPromise()) { try { $returnValue = $promise->execute($arguments, $matches[0][1]); } catch (\Exception $e) { $exception = $e; } } $this->recordedCalls[] = new Call($name, $arguments, $returnValue, $exception, $file, $line); if (null !== $exception) { throw $exception; } return $returnValue; }
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->scoreArguments($call->getArguments()); }) ); }
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->_config = false; }
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()) { return false; } require_once 'System.php'; if (!System::mkdir(array('-p', $this->statedir))) { return $this->raiseError("could not create directory '{$this->statedir}'"); } $init = true; } elseif (!is_dir($this->statedir)) { return $this->raiseError('Cannot create directory ' . $this->statedir . ', ' . 'it already exists and is not a directory'); } $ds = DIRECTORY_SEPARATOR; if (!file_exists($this->channelsdir)) { if (!file_exists($this->channelsdir . $ds . 'pear.php.net.reg') || !file_exists($this->channelsdir . $ds . 'pecl.php.net.reg') || !file_exists($this->channelsdir . $ds . 'doc.php.net.reg') || !file_exists($this->channelsdir . $ds . '__uri.reg')) { $init = true; } } elseif (!is_dir($this->channelsdir)) { return $this->raiseError('Cannot create directory ' . $this->channelsdir . ', ' . 'it already exists and is not a directory'); } if ($init) { static $running = false; if (!$running) { $running = true; $this->_initializeDirs(); $running = false; $init = false; } } else { $this->_initializeDepDB(); } return true; }
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(); } return $this->_assertStateDir($channel); } $channelDir = $this->_channelDirectoryName($channel); if (!is_dir($this->channelsdir) || !file_exists($this->channelsdir . $ds . 'pear.php.net.reg')) { $this->_initializeChannelDirs(); } if (!file_exists($channelDir)) { if (!$this->hasWriteAccess()) { return false; } require_once 'System.php'; if (!System::mkdir(array('-p', $channelDir))) { return $this->raiseError("could not create directory '" . $channelDir . "'"); } } elseif (!is_dir($channelDir)) { return $this->raiseError("could not create directory '" . $channelDir . "', already exists and is not a directory"); } return true; }
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("could not create directory '{$this->channelsdir}'"); } } elseif (!is_dir($this->channelsdir)) { return $this->raiseError("could not create directory '{$this->channelsdir}" . "', it already exists and is not a directory"); } if (!file_exists($this->channelsdir . DIRECTORY_SEPARATOR . '.alias')) { if (!$this->hasWriteAccess()) { return false; } require_once 'System.php'; if (!System::mkdir(array('-p', $this->channelsdir . DIRECTORY_SEPARATOR . '.alias'))) { return $this->raiseError("could not create directory '{$this->channelsdir}/.alias'"); } } elseif (!is_dir($this->channelsdir . DIRECTORY_SEPARATOR . '.alias')) { return $this->raiseError("could not create directory '{$this->channelsdir}" . "/.alias', it already exists and is not a directory"); } return true; }
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 . DIRECTORY_SEPARATOR . str_replace('/', '_', strtolower($channel)) . '.reg'; }
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 == 'doc.php.net') { return 'doc.php.net'; } if ($channel == '__uri') { return '__uri'; } return false; } $channel = strtolower($channel); if (file_exists($this->_getChannelAliasFileName($channel))) { // translate an alias to an actual channel return implode('', file($this->_getChannelAliasFileName($channel))); } return $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') { return 'phpdocs'; } return false; } $channel = $this->_getChannel($channel); if (PEAR::isError($channel)) { return $channel; } return $channel->getAlias(); }
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->_assertStateDir()) { if ($mode == LOCK_EX) { return $this->raiseError('Registry directory is not writeable by the current user'); } return true; } $open_mode = 'w'; // XXX People reported problems with LOCK_SH and 'w' if ($mode === LOCK_SH || $mode === LOCK_UN) { if (!file_exists($this->lockfile)) { touch($this->lockfile); } $open_mode = 'r'; } if (!is_resource($this->lock_fp)) { $this->lock_fp = @fopen($this->lockfile, $open_mode); } if (!is_resource($this->lock_fp)) { $this->lock_fp = null; return $this->raiseError("could not create lock file" . (isset($php_errormsg) ? ": " . $php_errormsg : "")); } if (!(int)flock($this->lock_fp, $mode)) { switch ($mode) { case LOCK_SH: $str = 'shared'; break; case LOCK_EX: $str = 'exclusive'; break; case LOCK_UN: $str = 'unlock'; break; default: $str = 'unknown'; break; } //is resource at this point, close it on error. fclose($this->lock_fp); $this->lock_fp = null; return $this->raiseError("could not acquire $str lock ($this->lockfile)", PEAR_REGISTRY_ERROR_LOCK); } return true; }
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 && $channel == 'doc.php.net') { return true; } return $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; } } return false; }
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 .'assets' . DIRECTORY_SEPARATOR. 'wysiwyg'; $tinyMCEUrl = preg_replace('#^.*(\\'. DIRECTORY_SEPARATOR .'vendor\\'. DIRECTORY_SEPARATOR .'.+)$#', '$1', $tinyMCEUrl); $tinyMCEUrl = str_replace(DIRECTORY_SEPARATOR, '/', $tinyMCEUrl); return $tinyMCEUrl . '/tinymce/tinymce.min.js'; }
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::create()->ignoreDotFiles(false)->in($originDir) ); }
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, $time) ->then(function() use ($file, $mode) { return $file->chmod($mode); }); }
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) ? $createMode : static::$fileCreateMode; $createModeStr = FileHelper::permissionsAsString($createMode); $unlockCallback = function ($result = null) use ($filePath, $lock) { if ($lock) { static::unlock($filePath); } if (is_object($result) && $result instanceof \Throwable) { throw $result; } return $result; }; return static::onUnlock($filePath) ->then(function() use (&$file, $filePath, $lockTimeout, $openFlags, $createModeStr, $lock) { if ($lock) { static::lock($filePath, $lockTimeout); } return $file->open($openFlags, $createModeStr); })->then(function(WritableStreamInterface $stream) use (&$file, $contents) { $stream->write($contents); return $file->close(); })->then($unlockCallback, $unlockCallback); }
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) { static::unlock($filePath); } if (is_object($result) && $result instanceof \Throwable) { throw $result; } return $result; }; return static::onUnlock($filePath)->then( function () use (&$file, $filePath, $lock, $lockTimeout) { if ($lock) { static::lock($filePath, $lockTimeout); } return $file->exists(); } ) ->then(function () use (&$file, $filePath) { return $file->getContents(); })->then($unlockCallback, $unlockCallback); }
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::$_lockedFiles[$filePath] <= $expire ? $expire : static::$_lockedFiles[$filePath]; } static::$_lockedFiles[$filePath] = $expire; static::checkUnlockTimer(); }
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::$_lockedFilesQueue[$filePath] = []; } static::$_lockedFilesQueue[$filePath][] = $deferred; return $deferred->promise(); }
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)) { return static::file($pathOrObject); } return $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)) { return static::dir($pathOrObject); } return $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 => $timeout) { if ($timeout <= $now) { static::unlock($filePath); } } }); }
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; $globals->accept = Request\Accept::from( $globals->server('HTTP_ACCEPT'), $globals->server('HTTP_ACCEPT_LANGUAGE'), $globals->server('HTTP_ACCEPT_ENCODING'), $globals->server('HTTP_ACCEPT_CHARSET') ); $globals->method = $globals->server('REQUEST_METHOD'); $globals->secure = ($globals->server('HTTPS') == 'on'); $globals->ajax = $globals->server('HTTP_X_REQUESTED_WITH') && strtolower($globals->server('HTTP_X_REQUESTED_WITH')) == 'xmlhttprequest'; $globals->root = dirname($globals->server('SCRIPT_FILENAME')); $globals->root = rtrim($globals->root, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; if(function_exists('http_response_code')) { $globals->code = http_response_code(); } if(function_exists('http_get_request_body')) { $globals->body = http_get_request_body(); } if(function_exists('apache_request_headers')) { $globals->headers = apache_request_headers(); } foreach($_FILES as $index => $file) { $globals->files[$index] = new Request\File($file); } $globals->cli = (php_sapi_name() === 'cli'); $globals->agent = $globals->server('HTTP_USER_AGENT'); $globals->ip = $globals->server('REMOTE_ADDR'); $globals->time = $globals->server('REQUEST_TIME'); } return $globals; }
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[] = compact('firstColumn', 'operator', 'secondColumn', 'boolean', 'where'); return $this; }
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 be set to cast array in collection" ); }
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) { unset($row['data']); } return $this->createCommand() ->update($this->table, $row, ['sid' => $id]) ->execute(); }
php
{ "resource": "" }