_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q255000
AbstractFunctionRestrictionsSniff.setup_groups
test
protected function setup_groups( $key ) { // Prepare the function group regular expressions only once. $this->groups = $this->getGroups(); if ( empty( $this->groups ) && empty( self::$unittest_groups ) ) { return false; } // Allow for adding extra unit tests. if ( ! empty( self::$unittest_groups ) ) { ...
php
{ "resource": "" }
q255001
AbstractFunctionRestrictionsSniff.is_targetted_token
test
public function is_targetted_token( $stackPtr ) { // Exclude function definitions, class methods, and namespaced calls. if ( \T_STRING === $this->tokens[ $stackPtr ]['code'] ) { if ( $this->is_class_object_call( $stackPtr ) === true ) { return false; } if ( $this->is_token_namespaced( $stackPtr ) ===...
php
{ "resource": "" }
q255002
AbstractFunctionRestrictionsSniff.check_for_matches
test
public function check_for_matches( $stackPtr ) { $token_content = strtolower( $this->tokens[ $stackPtr ]['content'] ); $skip_to = array(); foreach ( $this->groups as $groupName => $group ) { if ( isset( $this->excluded_groups[ $groupName ] ) ) { continue; } if ( isset( $group['whitelist'][ $...
php
{ "resource": "" }
q255003
PrefixAllGlobalsSniff.process_variable_variable
test
protected function process_variable_variable( $stackPtr ) { static $indicators = array( \T_OPEN_CURLY_BRACKET => true, \T_VARIABLE => true, ); // Is this a variable variable ? // Not concerned with nested ones as those will be recognized on their own token. $next_non_empty = $this->phpcsFile-...
php
{ "resource": "" }
q255004
PrefixAllGlobalsSniff.variable_prefixed_or_whitelisted
test
private function variable_prefixed_or_whitelisted( $stackPtr, $name ) { // Ignore superglobals and WP global variables. if ( isset( $this->superglobals[ $name ] ) || isset( $this->wp_globals[ $name ] ) ) { return true; } return $this->is_prefixed( $stackPtr, $name ); }
php
{ "resource": "" }
q255005
PrefixAllGlobalsSniff.validate_prefixes
test
private function validate_prefixes() { if ( $this->previous_prefixes === $this->prefixes ) { return; } // Set the cache *before* validation so as to not break the above compare. $this->previous_prefixes = $this->prefixes; // Validate the passed prefix(es). $prefixes = array(); $ns_prefixes = array...
php
{ "resource": "" }
q255006
PrefixAllGlobalsSniff.record_potential_prefix_metric
test
private function record_potential_prefix_metric( $stackPtr, $construct_name ) { if ( preg_match( '`^([A-Z]*[a-z0-9]*+)`', ltrim( $construct_name, '\$_' ), $matches ) > 0 && isset( $matches[1] ) && '' !== $matches[1] ) { $this->phpcsFile->recordMetric( $stackPtr, 'Prefix all globals: potential prefixes - start...
php
{ "resource": "" }
q255007
AbstractArrayAssignmentRestrictionsSniff.setup_groups
test
protected function setup_groups() { $this->groups_cache = $this->getGroups(); if ( empty( $this->groups_cache ) && empty( self::$groups ) ) { return false; } // Allow for adding extra unit tests. if ( ! empty( self::$groups ) ) { $this->groups_cache = array_merge( $this->groups_cache, self::$groups );...
php
{ "resource": "" }
q255008
MultipleStatementAlignmentSniff.validate_align_multiline_items
test
protected function validate_align_multiline_items() { $alignMultilineItems = $this->alignMultilineItems; if ( 'always' === $alignMultilineItems || 'never' === $alignMultilineItems ) { return; } else { // Correct for a potentially added % sign. $alignMultilineItems = rtrim( $alignMultilineItems, '%' ); ...
php
{ "resource": "" }
q255009
AlternativeFunctionsSniff.is_local_data_stream
test
protected function is_local_data_stream( $raw_param_value ) { $raw_stripped = $this->strip_quotes( $raw_param_value ); if ( isset( $this->allowed_local_streams[ $raw_stripped ] ) || isset( $this->allowed_local_stream_constants[ $raw_param_value ] ) ) { return true; } foreach ( $this->allowed_local_str...
php
{ "resource": "" }
q255010
ValidVariableNameSniff.processVariableInString
test
protected function processVariableInString( File $phpcs_file, $stack_ptr ) { $tokens = $phpcs_file->getTokens(); if ( preg_match_all( '|[^\\\]\${?([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)|', $tokens[ $stack_ptr ]['content'], $matches ) > 0 ) { // Merge any custom variables with the defaults. $this->mergeW...
php
{ "resource": "" }
q255011
ValidVariableNameSniff.mergeWhiteList
test
protected function mergeWhiteList() { if ( $this->customPropertiesWhitelist !== $this->addedCustomProperties['properties'] ) { // Fix property potentially passed as comma-delimited string. $customProperties = Sniff::merge_custom_array( $this->customPropertiesWhitelist, array(), false ); $this->whitelisted_m...
php
{ "resource": "" }
q255012
ArrayIndentationSniff.ignore_token
test
protected function ignore_token( $ptr ) { $token_code = $this->tokens[ $ptr ]['code']; if ( isset( $this->ignore_tokens[ $token_code ] ) ) { return true; } /* * If it's a subsequent line of a multi-line sting, it will not start with a quote * character, nor just *be* a quote character. */ if ( \...
php
{ "resource": "" }
q255013
ArrayIndentationSniff.get_indentation_size
test
protected function get_indentation_size( $ptr ) { // Find the first token on the line. for ( ; $ptr >= 0; $ptr-- ) { if ( 1 === $this->tokens[ $ptr ]['column'] ) { break; } } $whitespace = ''; if ( \T_WHITESPACE === $this->tokens[ $ptr ]['code'] || \T_DOC_COMMENT_WHITESPACE === $this->tokens[ ...
php
{ "resource": "" }
q255014
ArrayIndentationSniff.get_indentation_string
test
protected function get_indentation_string( $nr ) { if ( 0 >= $nr ) { return ''; } // Space-based indentation. if ( false === $this->tabIndent ) { return str_repeat( ' ', $nr ); } // Tab-based indentation. $num_tabs = (int) floor( $nr / $this->tab_width ); $remaining = ( $nr % $this->tab_wid...
php
{ "resource": "" }
q255015
ArrayIndentationSniff.add_array_alignment_error
test
protected function add_array_alignment_error( $ptr, $error, $error_code, $expected, $found, $new_indent ) { $fix = $this->phpcsFile->addFixableError( $error, $ptr, $error_code, array( $expected, $found ) ); if ( true === $fix ) { $this->fix_alignment_error( $ptr, $new_indent ); } }
php
{ "resource": "" }
q255016
ArrayIndentationSniff.fix_alignment_error
test
protected function fix_alignment_error( $ptr, $new_indent ) { if ( 1 === $this->tokens[ $ptr ]['column'] ) { $this->phpcsFile->fixer->addContentBefore( $ptr, $new_indent ); } else { $this->phpcsFile->fixer->replaceToken( ( $ptr - 1 ), $new_indent ); } }
php
{ "resource": "" }
q255017
EnqueuedResourceParametersSniff.is_falsy
test
protected function is_falsy( $start, $end ) { // Find anything excluding the false tokens. $has_non_false = $this->phpcsFile->findNext( $this->false_tokens, $start, ( $end + 1 ), true ); // If no non-false tokens are found, we are good. if ( false === $has_non_false ) { return true; } $code_string = ''...
php
{ "resource": "" }
q255018
I18nSniff.compare_single_and_plural_arguments
test
protected function compare_single_and_plural_arguments( $stack_ptr, $single_context, $plural_context ) { $single_content = $single_context['tokens'][0]['content']; $plural_content = $plural_context['tokens'][0]['content']; preg_match_all( self::SPRINTF_PLACEHOLDER_REGEX, $single_content, $single_placeholders ); ...
php
{ "resource": "" }
q255019
I18nSniff.check_text
test
protected function check_text( $context ) { $stack_ptr = $context['stack_ptr']; $arg_name = $context['arg_name']; $content = $context['tokens'][0]['content']; $is_error = empty( $context['warning'] ); // UnorderedPlaceholders: Check for multiple unordered placeholders. $unordered_matches_count = preg_m...
php
{ "resource": "" }
q255020
AbstractClassRestrictionsSniff.is_targetted_token
test
public function is_targetted_token( $stackPtr ) { $token = $this->tokens[ $stackPtr ]; $classname = ''; if ( \in_array( $token['code'], array( \T_NEW, \T_EXTENDS, \T_IMPLEMENTS ), true ) ) { if ( \T_NEW === $token['code'] ) { $nameEnd = ( $this->phpcsFile->findNext( array( \T_OPEN_PARENTHESIS, \T_WHI...
php
{ "resource": "" }
q255021
AbstractClassRestrictionsSniff.check_for_matches
test
public function check_for_matches( $stackPtr ) { $skip_to = array(); foreach ( $this->groups as $groupName => $group ) { if ( isset( $this->excluded_groups[ $groupName ] ) ) { continue; } if ( preg_match( $group['regex'], $this->classname ) === 1 ) { $skip_to[] = $this->process_matched_token( $s...
php
{ "resource": "" }
q255022
AbstractClassRestrictionsSniff.get_namespaced_classname
test
protected function get_namespaced_classname( $classname, $search_from ) { // Don't do anything if this is already a fully qualified classname. if ( empty( $classname ) || '\\' === $classname[0] ) { return $classname; } // Remove the namespace keyword if used. if ( 0 === strpos( $classname, 'namespace\\' )...
php
{ "resource": "" }
q255023
AssignmentInConditionSniff.register
test
public function register() { $this->assignment_tokens = Tokens::$assignmentTokens; unset( $this->assignment_tokens[ \T_DOUBLE_ARROW ] ); $starters = Tokens::$booleanOperators; $starters[ \T_SEMICOLON ] = \T_SEMICOLON; $starters[ \T_OPEN_PARENTHESIS ] = \T_OPEN_PARENTHESIS; $st...
php
{ "resource": "" }
q255024
Job.execute
test
public function execute($queue) { $serializer = new Serializer(); $closure = $serializer->unserialize($this->serialized); return $closure(); }
php
{ "resource": "" }
q255025
Queue.reserve
test
protected function reserve($timeout) { $response = $this->getClient()->receiveMessage([ 'QueueUrl' => $this->url, 'AttributeNames' => ['ApproximateReceiveCount'], 'MessageAttributeNames' => ['TTR'], 'MaxNumberOfMessages' => 1, 'VisibilityTimeout' =...
php
{ "resource": "" }
q255026
Queue.close
test
protected function close() { if (!$this->context) { return; } $this->context->close(); $this->context = null; $this->setupBrokerDone = false; }
php
{ "resource": "" }
q255027
Generator.validateNamespace
test
public function validateNamespace($attribute) { $value = $this->$attribute; $value = ltrim($value, '\\'); $path = Yii::getAlias('@' . str_replace('\\', '/', $value), false); if ($path === false) { $this->addError($attribute, 'Namespace must be associated with an existing ...
php
{ "resource": "" }
q255028
Queue.push
test
public function push($job) { $event = new PushEvent([ 'job' => $job, 'ttr' => $this->pushTtr ?: ( $job instanceof RetryableJobInterface ? $job->getTtr() : $this->ttr ), 'delay' => $this->pushDelay ?: 0, ...
php
{ "resource": "" }
q255029
Command.actionListen
test
public function actionListen($timeout = 3) { if (!is_numeric($timeout)) { throw new Exception('Timeout must be numeric.'); } if ($timeout < 1) { throw new Exception('Timeout must be greater than zero.'); } return $this->queue->run(true, $timeout); ...
php
{ "resource": "" }
q255030
Command.actionExec
test
public function actionExec($id, $ttr, $attempt, $pid) { if ($this->queue->execute($id, file_get_contents('php://stdin'), $ttr, $attempt, $pid ?: null)) { return self::EXEC_DONE; } return self::EXEC_RETRY; }
php
{ "resource": "" }
q255031
Command.handleMessage
test
protected function handleMessage($id, $message, $ttr, $attempt) { // Child process command: php yii queue/exec "id" "ttr" "attempt" "pid" $cmd = [ $this->phpBinary, $_SERVER['SCRIPT_FILENAME'], $this->uniqueId . '/exec', $id, $ttr, ...
php
{ "resource": "" }
q255032
Queue.run
test
public function run() { while (($payload = array_shift($this->payloads)) !== null) { list($ttr, $message) = $payload; $this->startedId = $this->finishedId + 1; $this->handleMessage($this->startedId, $message, $ttr, 1); $this->finishedId = $this->startedId; ...
php
{ "resource": "" }
q255033
Queue.reserve
test
protected function reserve() { return $this->db->useMaster(function () { if (!$this->mutex->acquire(__CLASS__ . $this->channel, $this->mutexTimeout)) { throw new Exception('Has not waited the lock.'); } try { $this->moveExpired(); ...
php
{ "resource": "" }
q255034
Queue.moveExpired
test
private function moveExpired() { if ($this->reserveTime !== time()) { $this->reserveTime = time(); $this->db->createCommand()->update( $this->tableName, ['reserved_at' => null], '[[reserved_at]] < :time - [[ttr]] and [[done_at]] is null...
php
{ "resource": "" }
q255035
Behavior.beforePush
test
public function beforePush(PushEvent $event) { if ($event->job instanceof \Closure) { $serializer = new Serializer(); $serialized = $serializer->serialize($event->job); $event->job = new Job(); $event->job->serialized = $serialized; } }
php
{ "resource": "" }
q255036
Queue.delete
test
protected function delete($id) { $this->redis->zrem("$this->channel.reserved", $id); $this->redis->hdel("$this->channel.attempts", $id); $this->redis->hdel("$this->channel.messages", $id); }
php
{ "resource": "" }
q255037
Queue.runWorker
test
protected function runWorker(callable $handler) { $this->_workerPid = getmypid(); /** @var LoopInterface $loop */ $loop = Yii::createObject($this->loopConfig, [$this]); $event = new WorkerEvent(['loop' => $loop]); $this->trigger(self::EVENT_WORKER_START, $event); if ...
php
{ "resource": "" }
q255038
Queue.handle
test
public function handle($id, $message, $ttr, $attempt) { return $this->handleMessage($id, $message, $ttr, $attempt); }
php
{ "resource": "" }
q255039
SignalLoop.init
test
public function init() { parent::init(); if (extension_loaded('pcntl')) { foreach ($this->exitSignals as $signal) { pcntl_signal($signal, function () { self::$exit = true; }); } foreach ($this->suspendSignals as ...
php
{ "resource": "" }
q255040
SignalLoop.canContinue
test
public function canContinue() { if (extension_loaded('pcntl')) { pcntl_signal_dispatch(); // Wait for resume signal until loop is suspended while (self::$pause && !self::$exit) { usleep(10000); pcntl_signal_dispatch(); } ...
php
{ "resource": "" }
q255041
Queue.reserve
test
protected function reserve() { $id = null; $ttr = null; $attempt = null; $this->touchIndex(function (&$data) use (&$id, &$ttr, &$attempt) { if (!empty($data['reserved'])) { foreach ($data['reserved'] as $key => $payload) { if ($payload[...
php
{ "resource": "" }
q255042
Queue.delete
test
protected function delete($payload) { $id = $payload[0]; $this->touchIndex(function (&$data) use ($id) { foreach ($data['reserved'] as $key => $payload) { if ($payload[0] === $id) { unset($data['reserved'][$key]); break; ...
php
{ "resource": "" }
q255043
Reader.parse
test
public function parse(): array { $previousEntityState = libxml_disable_entity_loader(true); $previousSetting = libxml_use_internal_errors(true); try { while (self::ELEMENT !== $this->nodeType) { if (!$this->read()) { $errors = libxml_get_error...
php
{ "resource": "" }
q255044
Reader.parseGetElements
test
public function parseGetElements(array $elementMap = null): array { $result = $this->parseInnerTree($elementMap); if (!is_array($result)) { return []; } return $result; }
php
{ "resource": "" }
q255045
Reader.parseInnerTree
test
public function parseInnerTree(array $elementMap = null) { $text = null; $elements = []; if (self::ELEMENT === $this->nodeType && $this->isEmptyElement) { // Easy! $this->next(); return null; } if (!is_null($elementMap)) { $t...
php
{ "resource": "" }
q255046
Reader.readText
test
public function readText(): string { $result = ''; $previousDepth = $this->depth; while ($this->read() && $this->depth != $previousDepth) { if (in_array($this->nodeType, [XMLReader::TEXT, XMLReader::CDATA, XMLReader::WHITESPACE])) { $result .= $this->value; ...
php
{ "resource": "" }
q255047
Reader.parseCurrentElement
test
public function parseCurrentElement(): array { $name = $this->getClark(); $attributes = []; if ($this->hasAttributes) { $attributes = $this->parseAttributes(); } $value = call_user_func( $this->getDeserializerForElementName((string) $name), ...
php
{ "resource": "" }
q255048
Reader.parseAttributes
test
public function parseAttributes(): array { $attributes = []; while ($this->moveToNextAttribute()) { if ($this->namespaceURI) { // Ignoring 'xmlns', it doesn't make any sense. if ('http://www.w3.org/2000/xmlns/' === $this->namespaceURI) { ...
php
{ "resource": "" }
q255049
Reader.getDeserializerForElementName
test
public function getDeserializerForElementName(string $name): callable { if (!array_key_exists($name, $this->elementMap)) { if ('{}' == substr($name, 0, 2) && array_key_exists(substr($name, 2), $this->elementMap)) { $name = substr($name, 2); } else { re...
php
{ "resource": "" }
q255050
ContextStackTrait.pushContext
test
public function pushContext() { $this->contextStack[] = [ $this->elementMap, $this->contextUri, $this->namespaceMap, $this->classMap, ]; }
php
{ "resource": "" }
q255051
ContextStackTrait.popContext
test
public function popContext() { list( $this->elementMap, $this->contextUri, $this->namespaceMap, $this->classMap ) = array_pop($this->contextStack); }
php
{ "resource": "" }
q255052
Service.getWriter
test
public function getWriter(): Writer { $w = new Writer(); $w->namespaceMap = $this->namespaceMap; $w->classMap = $this->classMap; return $w; }
php
{ "resource": "" }
q255053
Service.parse
test
public function parse($input, string $contextUri = null, string &$rootElementName = null) { if (is_resource($input)) { // Unfortunately the XMLReader doesn't support streams. When it // does, we can optimize this. $input = (string) stream_get_contents($input); } ...
php
{ "resource": "" }
q255054
Service.expect
test
public function expect($rootElementName, $input, string $contextUri = null) { if (is_resource($input)) { // Unfortunately the XMLReader doesn't support streams. When it // does, we can optimize this. $input = (string) stream_get_contents($input); } $r = $t...
php
{ "resource": "" }
q255055
Service.write
test
public function write(string $rootElementName, $value, string $contextUri = null) { $w = $this->getWriter(); $w->openMemory(); $w->contextUri = $contextUri; $w->setIndent(true); $w->startDocument(); $w->writeElement($rootElementName, $value); return $w->outpu...
php
{ "resource": "" }
q255056
Service.mapValueObject
test
public function mapValueObject(string $elementName, string $className) { list($namespace) = self::parseClarkNotation($elementName); $this->elementMap[$elementName] = function (Reader $reader) use ($className, $namespace) { return \Sabre\Xml\Deserializer\valueObject($reader, $className, ...
php
{ "resource": "" }
q255057
Service.writeValueObject
test
public function writeValueObject($object, string $contextUri = null) { if (!isset($this->valueObjectMap[get_class($object)])) { throw new \InvalidArgumentException('"'.get_class($object).'" is not a registered value object class. Register your class with mapValueObject.'); } ret...
php
{ "resource": "" }
q255058
Service.parseClarkNotation
test
public static function parseClarkNotation(string $str): array { static $cache = []; if (!isset($cache[$str])) { if (!preg_match('/^{([^}]*)}(.*)$/', $str, $matches)) { throw new \InvalidArgumentException('\''.$str.'\' is not a valid clark-notation formatted string'); ...
php
{ "resource": "" }
q255059
XmlFragment.xmlDeserialize
test
public static function xmlDeserialize(Reader $reader) { $result = new self($reader->readInnerXml()); $reader->next(); return $result; }
php
{ "resource": "" }
q255060
Uri.xmlDeserialize
test
public static function xmlDeserialize(Xml\Reader $reader) { return new self( \Sabre\Uri\resolve( (string) $reader->contextUri, $reader->readText() ) ); }
php
{ "resource": "" }
q255061
Writer.startElement
test
public function startElement($name): bool { if ('{' === $name[0]) { list($namespace, $localName) = Service::parseClarkNotation($name); if (array_key_exists($namespace, $this->namespaceMap)) { $result = $this->startElementNS( '' ===...
php
{ "resource": "" }
q255062
Writer.writeElement
test
public function writeElement($name, $content = null): bool { $this->startElement($name); if (!is_null($content)) { $this->write($content); } $this->endElement(); return true; }
php
{ "resource": "" }
q255063
Writer.writeAttributes
test
public function writeAttributes(array $attributes) { foreach ($attributes as $name => $value) { $this->writeAttribute($name, $value); } }
php
{ "resource": "" }
q255064
Writer.writeAttribute
test
public function writeAttribute($name, $value): bool { if ('{' !== $name[0]) { return parent::writeAttribute($name, $value); } list( $namespace, $localName ) = Service::parseClarkNotation($name); if (array_key_exists($namespace, $this->nam...
php
{ "resource": "" }
q255065
RelationFinder.getModelRelations
test
public function getModelRelations(string $model) { $class = new ReflectionClass($model); $traitMethods = Collection::make($class->getTraits())->map(function (ReflectionClass $trait) { return Collection::make($trait->getMethods(ReflectionMethod::IS_PUBLIC)); })->flatten(); ...
php
{ "resource": "" }
q255066
CronCreateCommand.validateJobName
test
protected function validateJobName($name) { if (!$name || strlen($name) == 0) { throw new \InvalidArgumentException('Please set a name.'); } if ($this->queryJob($name)) { throw new \InvalidArgumentException('Name already in use.'); } return $name; ...
php
{ "resource": "" }
q255067
CronCreateCommand.validateCommand
test
protected function validateCommand($command) { $parts = explode(' ', $command); $this->getApplication()->get((string) $parts[0]); return $command; }
php
{ "resource": "" }
q255068
Resolver.createJob
test
protected function createJob(CronJob $dbJob) { $job = new ShellJob(); $job->setCommand($this->commandBuilder->build($dbJob->getCommand()), $this->rootDir); $job->setSchedule(new CrontabSchedule($dbJob->getSchedule())); $job->raw = $dbJob; return $job; }
php
{ "resource": "" }
q255069
CurrentTraceContext.createScopeAndRetrieveItsCloser
test
public function createScopeAndRetrieveItsCloser(?TraceContext $currentContext = null): callable { $previous = $this->context; $self = $this; $this->context = $currentContext; return function () use ($previous, $self) { $self->context = $previous; }; }
php
{ "resource": "" }
q255070
Span.finish
test
public function finish(?int $finishTimestamp = null): void { if ($this->finished) { return; } if ($this->timestamp !== null && $finishTimestamp !== null) { $this->duration = $finishTimestamp - $this->timestamp; } $this->finished = true; }
php
{ "resource": "" }
q255071
Tracer.getCurrentSpan
test
public function getCurrentSpan(): ?Span { $currentContext = $this->currentTraceContext->getContext(); return $currentContext === null ? null : $this->toSpan($currentContext); }
php
{ "resource": "" }
q255072
Tracer.toSpan
test
private function toSpan(TraceContext $context): Span { if (!$this->isNoop && $context->isSampled()) { return RealSpan::create($context, $this->recorder); } return NoopSpan::create($context); }
php
{ "resource": "" }
q255073
RealSpan.start
test
public function start(?int $timestamp = null): void { if ($timestamp === null) { $timestamp = now(); } else { if (!isValid($timestamp)) { throw new InvalidArgumentException( sprintf('Invalid timestamp. Expected int, got %s', $timestamp) ...
php
{ "resource": "" }
q255074
RealSpan.setName
test
public function setName(string $name): void { $this->recorder->setName($this->traceContext, $name); }
php
{ "resource": "" }
q255075
RealSpan.annotate
test
public function annotate(string $value, ?int $timestamp = null): void { if (!isValid($timestamp)) { throw new InvalidArgumentException( sprintf('Valid timestamp represented microtime expected, got \'%s\'', $timestamp) ); } $this->recorder->annotate($t...
php
{ "resource": "" }
q255076
RealSpan.setRemoteEndpoint
test
public function setRemoteEndpoint(Endpoint $remoteEndpoint): void { $this->recorder->setRemoteEndpoint($this->traceContext, $remoteEndpoint); }
php
{ "resource": "" }
q255077
Guard.generateNewToken
test
public function generateNewToken(ServerRequestInterface $request) { $pair = $this->generateToken(); $request = $this->attachRequestAttributes($request, $pair); return $request; }
php
{ "resource": "" }
q255078
Guard.getFromStorage
test
protected function getFromStorage($name) { return isset($this->storage[$name]) ? $this->storage[$name] : false; }
php
{ "resource": "" }
q255079
Guard.getLastKeyPair
test
protected function getLastKeyPair() { // Use count, since empty ArrayAccess objects can still return false for `empty` if (count($this->storage) < 1) { return null; } foreach ($this->storage as $name => $value) { continue; } $keyPair = [ ...
php
{ "resource": "" }
q255080
Guard.enforceStorageLimit
test
protected function enforceStorageLimit() { if ($this->storageLimit < 1) { return; } // $storage must be an array or implement Countable and Traversable if (!is_array($this->storage) && !($this->storage instanceof Countable && $this->storage instanceof Travers...
php
{ "resource": "" }
q255081
Sanitizer.create
test
public static function create(array $config): SanitizerInterface { $builder = new SanitizerBuilder(); $builder->registerExtension(new BasicExtension()); $builder->registerExtension(new ListExtension()); $builder->registerExtension(new ImageExtension()); $builder->registerExte...
php
{ "resource": "" }
q255082
TagVisitorTrait.setAttributes
test
private function setAttributes(\DOMNode $domNode, TagNodeInterface $node, array $allowedAttributes = []) { if (!\count($domNode->attributes)) { return; } /** @var \DOMAttr $attribute */ foreach ($domNode->attributes as $attribute) { $name = strtolower($attrib...
php
{ "resource": "" }
q255083
TagVisitorTrait.getAttribute
test
private function getAttribute(\DOMNode $domNode, string $name): ?string { if (!\count($domNode->attributes)) { return null; } /** @var \DOMAttr $attribute */ foreach ($domNode->attributes as $attribute) { if ($attribute->name === $name) { retu...
php
{ "resource": "" }
q255084
DefaultConfigPass.processDefaultEntity
test
private function processDefaultEntity(array $backendConfig) { $entityNames = \array_keys($backendConfig['entities']); $firstEntityName = $entityNames[0] ?? null; $backendConfig['default_entity_name'] = $firstEntityName; return $backendConfig; }
php
{ "resource": "" }
q255085
DefaultConfigPass.processDefaultMenuItem
test
private function processDefaultMenuItem(array $backendConfig) { $defaultMenuItem = $this->findDefaultMenuItem($backendConfig['design']['menu']); if ('empty' === $defaultMenuItem['type']) { throw new \RuntimeException(\sprintf('The "menu" configuration sets "%s" as the default item, whic...
php
{ "resource": "" }
q255086
FormTypeHelper.getTypeName
test
public static function getTypeName($typeFqcn) { // needed to avoid collisions between immutable and non-immutable date types, // which are mapped to the same Symfony Form type classes $filteredNameToClassMap = \array_filter(self::$nameToClassMap, function ($typeName) { return !\i...
php
{ "resource": "" }
q255087
PropertyConfigPass.getFormTypeOptionsOfProperty
test
private function getFormTypeOptionsOfProperty(array $mergedConfig, array $guessedConfig, array $userDefinedConfig) { $resolvedFormOptions = $mergedConfig['type_options']; // if the user has defined a 'type', the type options // must be reset so they don't get mixed with the form components ...
php
{ "resource": "" }
q255088
AdminControllerTrait.initialize
test
protected function initialize(Request $request) { $this->dispatch(EasyAdminEvents::PRE_INITIALIZE); $this->config = $this->get('easyadmin.config.manager')->getBackendConfig(); if (0 === \count($this->config['entities'])) { throw new NoEntitiesConfiguredException(); } ...
php
{ "resource": "" }
q255089
AdminControllerTrait.autocompleteAction
test
protected function autocompleteAction() { $results = $this->get('easyadmin.autocomplete')->find( $this->request->query->get('entity'), $this->request->query->get('query'), $this->request->query->get('page', 1) ); return new JsonResponse($results); }
php
{ "resource": "" }
q255090
AdminControllerTrait.listAction
test
protected function listAction() { $this->dispatch(EasyAdminEvents::PRE_LIST); $fields = $this->entity['list']['fields']; $paginator = $this->findAll($this->entity['class'], $this->request->query->get('page', 1), $this->entity['list']['max_results'], $this->request->query->get('sortField'), ...
php
{ "resource": "" }
q255091
AdminControllerTrait.editAction
test
protected function editAction() { $this->dispatch(EasyAdminEvents::PRE_EDIT); $id = $this->request->query->get('id'); $easyadmin = $this->request->attributes->get('easyadmin'); $entity = $easyadmin['item']; if ($this->request->isXmlHttpRequest() && $property = $this->reques...
php
{ "resource": "" }
q255092
AdminControllerTrait.showAction
test
protected function showAction() { $this->dispatch(EasyAdminEvents::PRE_SHOW); $id = $this->request->query->get('id'); $easyadmin = $this->request->attributes->get('easyadmin'); $entity = $easyadmin['item']; $fields = $this->entity['show']['fields']; $deleteForm = $t...
php
{ "resource": "" }
q255093
AdminControllerTrait.newAction
test
protected function newAction() { $this->dispatch(EasyAdminEvents::PRE_NEW); $entity = $this->executeDynamicMethod('createNew<EntityName>Entity'); $easyadmin = $this->request->attributes->get('easyadmin'); $easyadmin['item'] = $entity; $this->request->attributes->set('easyad...
php
{ "resource": "" }
q255094
AdminControllerTrait.deleteAction
test
protected function deleteAction() { $this->dispatch(EasyAdminEvents::PRE_DELETE); if ('DELETE' !== $this->request->getMethod()) { return $this->redirect($this->generateUrl('easyadmin', ['action' => 'list', 'entity' => $this->entity['name']])); } $id = $this->request->qu...
php
{ "resource": "" }
q255095
AdminControllerTrait.searchAction
test
protected function searchAction() { $this->dispatch(EasyAdminEvents::PRE_SEARCH); $query = \trim($this->request->query->get('query')); // if the search query is empty, redirect to the 'list' action if ('' === $query) { $queryParameters = \array_replace($this->request->qu...
php
{ "resource": "" }
q255096
AdminControllerTrait.batchAction
test
protected function batchAction(): RedirectResponse { $batchForm = $this->createBatchForm($this->entity['name']); $batchForm->handleRequest($this->request); if ($batchForm->isSubmitted() && $batchForm->isValid()) { $actionName = $batchForm->get('name')->getData(); $ac...
php
{ "resource": "" }
q255097
AdminControllerTrait.updateEntityProperty
test
protected function updateEntityProperty($entity, $property, $value) { $entityConfig = $this->entity; if (!$this->get('easyadmin.property_accessor')->isWritable($entity, $property)) { throw new \RuntimeException(\sprintf('The "%s" property of the "%s" entity is not writable.', $property,...
php
{ "resource": "" }
q255098
AdminControllerTrait.findAll
test
protected function findAll($entityClass, $page = 1, $maxPerPage = 15, $sortField = null, $sortDirection = null, $dqlFilter = null) { if (null === $sortDirection || !\in_array(\strtoupper($sortDirection), ['ASC', 'DESC'])) { $sortDirection = 'DESC'; } $queryBuilder = $this->execu...
php
{ "resource": "" }
q255099
AdminControllerTrait.createListQueryBuilder
test
protected function createListQueryBuilder($entityClass, $sortDirection, $sortField = null, $dqlFilter = null) { return $this->get('easyadmin.query_builder')->createListQueryBuilder($this->entity, $sortField, $sortDirection, $dqlFilter); }
php
{ "resource": "" }