_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q242100 | Tokens.isAllTokenKindsFound | validation | public function isAllTokenKindsFound(array $tokenKinds)
{
foreach ($tokenKinds as $tokenKind) {
if (empty($this->foundTokenKinds[$tokenKind])) {
return false;
}
}
return true;
} | php | {
"resource": ""
} |
q242101 | Tokens.clearRange | validation | public function clearRange($indexStart, $indexEnd)
{
for ($i = $indexStart; $i <= $indexEnd; ++$i) {
$this->clearAt($i);
}
} | php | {
"resource": ""
} |
q242102 | Tokens.isMonolithicPhp | validation | public function isMonolithicPhp()
{
$size = $this->count();
if (0 === $size) {
return false;
}
if (self::isLegacyMode()) {
// If code is not monolithic there is a great chance that first or last token is `T_INLINE_HTML`:
if ($this[0]->isGivenKind... | php | {
"resource": ""
} |
q242103 | Tokens.getCache | validation | private static function getCache($key)
{
if (!self::hasCache($key)) {
throw new \OutOfBoundsException(sprintf('Unknown cache key: "%s".', $key));
}
return self::$cache[$key];
} | php | {
"resource": ""
} |
q242104 | Tokens.changeCodeHash | validation | private function changeCodeHash($codeHash)
{
if (null !== $this->codeHash) {
self::clearCache($this->codeHash);
}
$this->codeHash = $codeHash;
self::setCache($this->codeHash, $this);
} | php | {
"resource": ""
} |
q242105 | Tokens.registerFoundToken | validation | private function registerFoundToken($token)
{
// inlined extractTokenKind() call on the hot path
$tokenKind = $token instanceof Token
? ($token->isArray() ? $token->getId() : $token->getContent())
: (\is_array($token) ? $token[0] : $token)
;
if (!isset($this-... | php | {
"resource": ""
} |
q242106 | NoWhitespaceBeforeCommaInArrayFixer.skipNonArrayElements | validation | private function skipNonArrayElements($index, Tokens $tokens)
{
if ($tokens[$index]->equals('}')) {
return $tokens->findBlockStart(Tokens::BLOCK_TYPE_CURLY_BRACE, $index);
}
if ($tokens[$index]->equals(')')) {
$startIndex = $tokens->findBlockStart(Tokens::BLOCK_TYPE_... | php | {
"resource": ""
} |
q242107 | Token.isType | validation | public function isType($types)
{
if (!\is_array($types)) {
$types = [$types];
}
return \in_array($this->getType(), $types, true);
} | php | {
"resource": ""
} |
q242108 | AbstractNoUselessElseFixer.getPreviousBlock | validation | private function getPreviousBlock(Tokens $tokens, $index)
{
$close = $previous = $tokens->getPrevMeaningfulToken($index);
// short 'if' detection
if ($tokens[$close]->equals('}')) {
$previous = $tokens->findBlockStart(Tokens::BLOCK_TYPE_CURLY_BRACE, $close);
}
$o... | php | {
"resource": ""
} |
q242109 | AbstractNoUselessElseFixer.isInConditionWithoutBraces | validation | private function isInConditionWithoutBraces(Tokens $tokens, $index, $lowerLimitIndex)
{
do {
if ($tokens[$index]->isComment() || $tokens[$index]->isWhitespace()) {
$index = $tokens->getPrevMeaningfulToken($index);
}
$token = $tokens[$index];
i... | php | {
"resource": ""
} |
q242110 | ProcessLinter.createProcessForSource | validation | private function createProcessForSource($source)
{
if (null === $this->temporaryFile) {
$this->temporaryFile = tempnam('.', 'cs_fixer_tmp_');
$this->fileRemoval->observe($this->temporaryFile);
}
if (false === @file_put_contents($this->temporaryFile, $source)) {
... | php | {
"resource": ""
} |
q242111 | ListSyntaxFixer.configure | validation | public function configure(array $configuration = null)
{
parent::configure($configuration);
$this->candidateTokenKind = 'long' === $this->configuration['syntax'] ? CT::T_DESTRUCTURING_SQUARE_BRACE_OPEN : T_LIST;
} | php | {
"resource": ""
} |
q242112 | HelpCommand.getDisplayableAllowedValues | validation | public static function getDisplayableAllowedValues(FixerOptionInterface $option)
{
$allowed = $option->getAllowedValues();
if (null !== $allowed) {
$allowed = array_filter($allowed, static function ($value) {
return !($value instanceof \Closure);
});
... | php | {
"resource": ""
} |
q242113 | HelpCommand.wordwrap | validation | private static function wordwrap($string, $width)
{
$result = [];
$currentLine = 0;
$lineLength = 0;
foreach (explode(' ', $string) as $word) {
$wordLength = \strlen(Preg::replace('~</?(\w+)>~', '', $word));
if (0 !== $lineLength) {
++$wordLeng... | php | {
"resource": ""
} |
q242114 | DocBlock.getAnnotations | validation | public function getAnnotations()
{
if (null === $this->annotations) {
$this->annotations = [];
$total = \count($this->lines);
for ($index = 0; $index < $total; ++$index) {
if ($this->lines[$index]->containsATag()) {
// get all the line... | php | {
"resource": ""
} |
q242115 | DocBlock.getAnnotationsOfType | validation | public function getAnnotationsOfType($types)
{
$annotations = [];
$types = (array) $types;
foreach ($this->getAnnotations() as $annotation) {
$tag = $annotation->getTag()->getName();
foreach ($types as $type) {
if ($type === $tag) {
... | php | {
"resource": ""
} |
q242116 | HeredocToNowdocFixer.convertToNowdoc | validation | private function convertToNowdoc(Token $token)
{
return new Token([
$token->getId(),
Preg::replace('/^([Bb]?<<<)([ \t]*)"?([^\s"]+)"?/', '$1$2\'$3\'', $token->getContent()),
]);
} | php | {
"resource": ""
} |
q242117 | BracesFixer.isCommentWithFixableIndentation | validation | private function isCommentWithFixableIndentation(Tokens $tokens, $index)
{
if (!$tokens[$index]->isComment()) {
return false;
}
if (0 === strpos($tokens[$index]->getContent(), '/*')) {
return true;
}
$firstCommentIndex = $index;
while (true) ... | php | {
"resource": ""
} |
q242118 | ProtectedToPrivateFixer.skipClass | validation | private function skipClass(Tokens $tokens, $classIndex, $classOpenIndex, $classCloseIndex)
{
$prevToken = $tokens[$tokens->getPrevMeaningfulToken($classIndex)];
if (!$prevToken->isGivenKind(T_FINAL)) {
return true;
}
for ($index = $classIndex; $index < $classOpenIndex; +... | php | {
"resource": ""
} |
q242119 | FixerFactory.useRuleSet | validation | public function useRuleSet(RuleSetInterface $ruleSet)
{
$fixers = [];
$fixersByName = [];
$fixerConflicts = [];
$fixerNames = array_keys($ruleSet->getRules());
foreach ($fixerNames as $name) {
if (!\array_key_exists($name, $this->fixersByName)) {
... | php | {
"resource": ""
} |
q242120 | RuleSet.resolveSet | validation | private function resolveSet()
{
$rules = $this->set;
$resolvedRules = [];
// expand sets
foreach ($rules as $name => $value) {
if ('@' === $name[0]) {
if (!\is_bool($value)) {
throw new \UnexpectedValueException(sprintf('Nested rule se... | php | {
"resource": ""
} |
q242121 | RuleSet.resolveSubset | validation | private function resolveSubset($setName, $setValue)
{
$rules = $this->getSetDefinition($setName);
foreach ($rules as $name => $value) {
if ('@' === $name[0]) {
$set = $this->resolveSubset($name, $setValue);
unset($rules[$name]);
$rules = ar... | php | {
"resource": ""
} |
q242122 | AbstractPhpdocTypesFixer.fixTypes | validation | private function fixTypes(Annotation $annotation)
{
$types = $annotation->getTypes();
$new = $this->normalizeTypes($types);
if ($types !== $new) {
$annotation->setTypes($new);
}
} | php | {
"resource": ""
} |
q242123 | AbstractPhpdocTypesFixer.normalizeType | validation | private function normalizeType($type)
{
if ('[]' === substr($type, -2)) {
return $this->normalize(substr($type, 0, -2)).'[]';
}
return $this->normalize($type);
} | php | {
"resource": ""
} |
q242124 | UseTransformer.isUseForLambda | validation | private function isUseForLambda(Tokens $tokens, $index)
{
$nextToken = $tokens[$tokens->getNextMeaningfulToken($index)];
// test `function () use ($foo) {}` case
return $nextToken->equals('(');
} | php | {
"resource": ""
} |
q242125 | EregToPregFixer.getBestDelimiter | validation | private function getBestDelimiter($pattern)
{
// try do find something that's not used
$delimiters = [];
foreach (self::$delimiters as $k => $d) {
if (false === strpos($pattern, $d)) {
return $d;
}
$delimiters[$d] = [substr_count($pattern,... | php | {
"resource": ""
} |
q242126 | CT.getName | validation | public static function getName($value)
{
if (!self::has($value)) {
throw new \InvalidArgumentException(sprintf('No custom token was found for "%s".', $value));
}
$tokens = self::getMapById();
return 'CT::'.$tokens[$value];
} | php | {
"resource": ""
} |
q242127 | SimplifiedNullReturnFixer.clear | validation | private function clear(Tokens $tokens, $index)
{
while (!$tokens[++$index]->equals(';')) {
if ($this->shouldClearToken($tokens, $index)) {
$tokens->clearAt($index);
}
}
} | php | {
"resource": ""
} |
q242128 | SimplifiedNullReturnFixer.needFixing | validation | private function needFixing(Tokens $tokens, $index)
{
if ($this->isStrictOrNullableReturnTypeFunction($tokens, $index)) {
return false;
}
$content = '';
while (!$tokens[$index]->equals(';')) {
$index = $tokens->getNextMeaningfulToken($index);
$con... | php | {
"resource": ""
} |
q242129 | SimplifiedNullReturnFixer.isStrictOrNullableReturnTypeFunction | validation | private function isStrictOrNullableReturnTypeFunction(Tokens $tokens, $returnIndex)
{
$functionIndex = $returnIndex;
do {
$functionIndex = $tokens->getPrevTokenOfKind($functionIndex, [[T_FUNCTION]]);
if (null === $functionIndex) {
return false;
}
... | php | {
"resource": ""
} |
q242130 | SimplifiedNullReturnFixer.shouldClearToken | validation | private function shouldClearToken(Tokens $tokens, $index)
{
$token = $tokens[$index];
return !$token->isComment() && !($token->isWhitespace() && $tokens[$index + 1]->isComment());
} | php | {
"resource": ""
} |
q242131 | Annotation.getTypes | validation | public function getTypes()
{
if (null === $this->types) {
$this->types = [];
$content = $this->getTypesContent();
while ('' !== $content && false !== $content) {
Preg::match(
'{^'.self::REGEX_TYPES.'$}x',
$content,... | php | {
"resource": ""
} |
q242132 | Annotation.setTypes | validation | public function setTypes(array $types)
{
$pattern = '/'.preg_quote($this->getTypesContent(), '/').'/';
$this->lines[0]->setContent(Preg::replace($pattern, implode('|', $types), $this->lines[0]->getContent(), 1));
$this->clearCache();
} | php | {
"resource": ""
} |
q242133 | Annotation.getNormalizedTypes | validation | public function getNormalizedTypes()
{
$normalized = array_map(static function ($type) {
return strtolower($type);
}, $this->getTypes());
sort($normalized);
return $normalized;
} | php | {
"resource": ""
} |
q242134 | Annotation.getTypesContent | validation | private function getTypesContent()
{
if (null === $this->typesContent) {
$name = $this->getTag()->getName();
if (!$this->supportTypes()) {
throw new \RuntimeException('This tag does not support types.');
}
$matchingResult = Preg::match(
... | php | {
"resource": ""
} |
q242135 | ArgumentsAnalyzer.getArguments | validation | public function getArguments(Tokens $tokens, $openParenthesis, $closeParenthesis)
{
$arguments = [];
$firstSensibleToken = $tokens->getNextMeaningfulToken($openParenthesis);
if ($tokens[$firstSensibleToken]->equals(')')) {
return $arguments;
}
$paramContentIndex ... | php | {
"resource": ""
} |
q242136 | YodaStyleFixer.findComparisonEnd | validation | private function findComparisonEnd(Tokens $tokens, $index)
{
++$index;
$count = \count($tokens);
while ($index < $count) {
$token = $tokens[$index];
if ($token->isGivenKind([T_WHITESPACE, T_COMMENT, T_DOC_COMMENT])) {
++$index;
continu... | php | {
"resource": ""
} |
q242137 | YodaStyleFixer.findComparisonStart | validation | private function findComparisonStart(Tokens $tokens, $index)
{
--$index;
$nonBlockFound = false;
while (0 <= $index) {
$token = $tokens[$index];
if ($token->isGivenKind([T_WHITESPACE, T_COMMENT, T_DOC_COMMENT])) {
--$index;
continue;
... | php | {
"resource": ""
} |
q242138 | YodaStyleFixer.fixTokensCompare | validation | private function fixTokensCompare(
Tokens $tokens,
$startLeft,
$endLeft,
$compareOperatorIndex,
$startRight,
$endRight
) {
$type = $tokens[$compareOperatorIndex]->getId();
$content = $tokens[$compareOperatorIndex]->getContent();
if (\array_key_... | php | {
"resource": ""
} |
q242139 | YodaStyleFixer.isOfLowerPrecedence | validation | private function isOfLowerPrecedence(Token $token)
{
static $tokens;
if (null === $tokens) {
$tokens = [
T_AND_EQUAL, // &=
T_BOOLEAN_AND, // &&
T_BOOLEAN_OR, // ||
T_CASE, // case
T_CONCAT_EQU... | php | {
"resource": ""
} |
q242140 | TokensAnalyzer.getImportUseIndexes | validation | public function getImportUseIndexes($perNamespace = false)
{
$tokens = $this->tokens;
$tokens->rewind();
$uses = [];
$namespaceIndex = 0;
for ($index = 0, $limit = $tokens->count(); $index < $limit; ++$index) {
$token = $tokens[$index];
if ($token-... | php | {
"resource": ""
} |
q242141 | TokensAnalyzer.isArrayMultiLine | validation | public function isArrayMultiLine($index)
{
if (!$this->isArray($index)) {
throw new \InvalidArgumentException(sprintf('Not an array at given index %d.', $index));
}
$tokens = $this->tokens;
// Skip only when its an array, for short arrays we need the brace for correct
... | php | {
"resource": ""
} |
q242142 | TokensAnalyzer.getMethodAttributes | validation | public function getMethodAttributes($index)
{
$tokens = $this->tokens;
$token = $tokens[$index];
if (!$token->isGivenKind(T_FUNCTION)) {
throw new \LogicException(sprintf('No T_FUNCTION at given index %d, got %s.', $index, $token->getName()));
}
$attributes = [
... | php | {
"resource": ""
} |
q242143 | TokensAnalyzer.isAnonymousClass | validation | public function isAnonymousClass($index)
{
$tokens = $this->tokens;
$token = $tokens[$index];
if (!$token->isClassy()) {
throw new \LogicException(sprintf('No classy token at given index %d.', $index));
}
if (!$token->isGivenKind(T_CLASS)) {
return f... | php | {
"resource": ""
} |
q242144 | TokensAnalyzer.isLambda | validation | public function isLambda($index)
{
if (!$this->tokens[$index]->isGivenKind(T_FUNCTION)) {
throw new \LogicException(sprintf('No T_FUNCTION at given index %d, got %s.', $index, $this->tokens[$index]->getName()));
}
$startParenthesisIndex = $this->tokens->getNextMeaningfulToken($i... | php | {
"resource": ""
} |
q242145 | TokensAnalyzer.isUnarySuccessorOperator | validation | public function isUnarySuccessorOperator($index)
{
static $allowedPrevToken = [
']',
[T_STRING],
[T_VARIABLE],
[CT::T_DYNAMIC_PROP_BRACE_CLOSE],
[CT::T_DYNAMIC_VAR_BRACE_CLOSE],
];
$tokens = $this->tokens;
$token = $tokens[... | php | {
"resource": ""
} |
q242146 | TokensAnalyzer.isUnaryPredecessorOperator | validation | public function isUnaryPredecessorOperator($index)
{
static $potentialSuccessorOperator = [T_INC, T_DEC];
static $potentialBinaryOperator = ['+', '-', '&', [CT::T_RETURN_REF]];
static $otherOperators;
if (null === $otherOperators) {
$otherOperators = ['!', '~', '@', [T_... | php | {
"resource": ""
} |
q242147 | TokensAnalyzer.isBinaryOperator | validation | public function isBinaryOperator($index)
{
static $nonArrayOperators = [
'=' => true,
'*' => true,
'/' => true,
'%' => true,
'<' => true,
'>' => true,
'|' => true,
'^' => true,
'.' => true,
];... | php | {
"resource": ""
} |
q242148 | TokensAnalyzer.findClassyElements | validation | private function findClassyElements($index)
{
$elements = [];
$curlyBracesLevel = 0;
$bracesLevel = 0;
$classIndex = $index;
++$index; // skip the classy index itself
for ($count = \count($this->tokens); $index < $count; ++$index) {
$token = $this->tokens... | php | {
"resource": ""
} |
q242149 | SquareBraceTransformer.isShortArray | validation | private function isShortArray(Tokens $tokens, $index)
{
if (!$tokens[$index]->equals('[')) {
return false;
}
static $disallowedPrevTokens = [
')',
']',
'}',
'"',
[T_CONSTANT_ENCAPSED_STRING],
[T_STRING],
... | php | {
"resource": ""
} |
q242150 | HeaderCommentFixer.getHeaderAsComment | validation | private function getHeaderAsComment()
{
$lineEnding = $this->whitespacesConfig->getLineEnding();
$comment = (self::HEADER_COMMENT === $this->configuration['comment_type'] ? '/*' : '/**').$lineEnding;
$lines = explode("\n", str_replace("\r", '', $this->configuration['header']));
for... | php | {
"resource": ""
} |
q242151 | HeaderCommentFixer.findHeaderCommentInsertionIndex | validation | private function findHeaderCommentInsertionIndex(Tokens $tokens)
{
if ('after_open' === $this->configuration['location']) {
return 1;
}
$index = $tokens->getNextMeaningfulToken(0);
if (null === $index) {
// file without meaningful tokens but an open tag, comm... | php | {
"resource": ""
} |
q242152 | Line.addBlank | validation | public function addBlank()
{
$matched = Preg::match('/^([ \t]*\*)[^\r\n]*(\r?\n)$/', $this->content, $matches);
if (1 !== $matched) {
return;
}
$this->content .= $matches[1].$matches[2];
} | php | {
"resource": ""
} |
q242153 | PhpdocOrderFixer.moveParamAnnotations | validation | private function moveParamAnnotations($content)
{
$doc = new DocBlock($content);
$params = $doc->getAnnotationsOfType('param');
// nothing to do if there are no param annotations
if (empty($params)) {
return $content;
}
$others = $doc->getAnnotationsOfTy... | php | {
"resource": ""
} |
q242154 | PhpdocOrderFixer.moveReturnAnnotations | validation | private function moveReturnAnnotations($content)
{
$doc = new DocBlock($content);
$returns = $doc->getAnnotationsOfType('return');
// nothing to do if there are no return annotations
if (empty($returns)) {
return $content;
}
$others = $doc->getAnnotation... | php | {
"resource": ""
} |
q242155 | Utils.calculateBitmask | validation | public static function calculateBitmask(array $options)
{
$bitmask = 0;
foreach ($options as $optionName) {
if (\defined($optionName)) {
$bitmask |= \constant($optionName);
}
}
return $bitmask;
} | php | {
"resource": ""
} |
q242156 | Utils.camelCaseToUnderscore | validation | public static function camelCaseToUnderscore($string)
{
return Preg::replaceCallback(
'/(^|[a-z0-9])([A-Z])/',
static function (array $matches) {
return strtolower('' !== $matches[1] ? $matches[1].'_'.$matches[2] : $matches[2]);
},
$string
... | php | {
"resource": ""
} |
q242157 | Utils.calculateTrailingWhitespaceIndent | validation | public static function calculateTrailingWhitespaceIndent(Token $token)
{
if (!$token->isWhitespace()) {
throw new \InvalidArgumentException(sprintf('The given token must be whitespace, got "%s".', $token->getName()));
}
$str = strrchr(
str_replace(["\r\n", "\r"], "\n... | php | {
"resource": ""
} |
q242158 | Utils.stableSort | validation | public static function stableSort(array $elements, callable $getComparedValue, callable $compareValues)
{
array_walk($elements, static function (&$element, $index) use ($getComparedValue) {
$element = [$element, $index, $getComparedValue($element)];
});
usort($elements, static f... | php | {
"resource": ""
} |
q242159 | Utils.sortFixers | validation | public static function sortFixers(array $fixers)
{
// Schwartzian transform is used to improve the efficiency and avoid
// `usort(): Array was modified by the user comparison function` warning for mocked objects.
return self::stableSort(
$fixers,
static function (Fixe... | php | {
"resource": ""
} |
q242160 | ShortDescription.getEnd | validation | public function getEnd()
{
$reachedContent = false;
foreach ($this->doc->getLines() as $index => $line) {
// we went past a description, then hit a tag or blank line, so
// the last line of the description must be the one before this one
if ($reachedContent && ($... | php | {
"resource": ""
} |
q242161 | PhpdocSeparationFixer.fixDescription | validation | private function fixDescription(DocBlock $doc)
{
foreach ($doc->getLines() as $index => $line) {
if ($line->containsATag()) {
break;
}
if ($line->containsUsefulContent()) {
$next = $doc->getLine($index + 1);
if ($next->con... | php | {
"resource": ""
} |
q242162 | PhpdocSeparationFixer.fixAnnotations | validation | private function fixAnnotations(DocBlock $doc)
{
foreach ($doc->getAnnotations() as $index => $annotation) {
$next = $doc->getAnnotation($index + 1);
if (null === $next) {
break;
}
if (true === $next->getTag()->valid()) {
if (... | php | {
"resource": ""
} |
q242163 | PhpdocSeparationFixer.ensureAreTogether | validation | private function ensureAreTogether(DocBlock $doc, Annotation $first, Annotation $second)
{
$pos = $first->getEnd();
$final = $second->getStart();
for ($pos = $pos + 1; $pos < $final; ++$pos) {
$doc->getLine($pos)->remove();
}
} | php | {
"resource": ""
} |
q242164 | PhpdocSeparationFixer.ensureAreSeparate | validation | private function ensureAreSeparate(DocBlock $doc, Annotation $first, Annotation $second)
{
$pos = $first->getEnd();
$final = $second->getStart() - 1;
// check if we need to add a line, or need to remove one or more lines
if ($pos === $final) {
$doc->getLine($pos)->addBla... | php | {
"resource": ""
} |
q242165 | ErrorsManager.getInvalidErrors | validation | public function getInvalidErrors()
{
return array_filter($this->errors, static function (Error $error) {
return Error::TYPE_INVALID === $error->getType();
});
} | php | {
"resource": ""
} |
q242166 | ErrorsManager.getExceptionErrors | validation | public function getExceptionErrors()
{
return array_filter($this->errors, static function (Error $error) {
return Error::TYPE_EXCEPTION === $error->getType();
});
} | php | {
"resource": ""
} |
q242167 | ErrorsManager.getLintErrors | validation | public function getLintErrors()
{
return array_filter($this->errors, static function (Error $error) {
return Error::TYPE_LINT === $error->getType();
});
} | php | {
"resource": ""
} |
q242168 | NoEmptyCommentFixer.getCommentBlock | validation | private function getCommentBlock(Tokens $tokens, $index)
{
$commentType = $this->getCommentType($tokens[$index]->getContent());
$empty = $this->isEmptyComment($tokens[$index]->getContent());
$start = $index;
$count = \count($tokens);
++$index;
for (; $index < $count;... | php | {
"resource": ""
} |
q242169 | FileRemoval.delete | validation | public function delete($path)
{
if (isset($this->files[$path])) {
unset($this->files[$path]);
}
$this->unlink($path);
} | php | {
"resource": ""
} |
q242170 | FileRemoval.clean | validation | public function clean()
{
foreach ($this->files as $file => $value) {
$this->unlink($file);
}
$this->files = [];
} | php | {
"resource": ""
} |
q242171 | Transformers.transform | validation | public function transform(Tokens $tokens)
{
foreach ($this->items as $transformer) {
foreach ($tokens as $index => $token) {
$transformer->process($tokens, $token, $index);
}
}
} | php | {
"resource": ""
} |
q242172 | Token.clear | validation | public function clear()
{
@trigger_error(__METHOD__.' is deprecated and will be removed in 3.0.', E_USER_DEPRECATED);
Tokens::setLegacyMode(true);
$this->content = '';
$this->id = null;
$this->isArray = false;
} | php | {
"resource": ""
} |
q242173 | Token.clearChanged | validation | public function clearChanged()
{
@trigger_error(__METHOD__.' is deprecated and will be removed in 3.0.', E_USER_DEPRECATED);
Tokens::setLegacyMode(true);
$this->changed = false;
} | php | {
"resource": ""
} |
q242174 | Token.equals | validation | public function equals($other, $caseSensitive = true)
{
if ($other instanceof self) {
// Inlined getPrototype() on this very hot path.
// We access the private properties of $other directly to save function call overhead.
// This is only possible because $other is of the ... | php | {
"resource": ""
} |
q242175 | Token.equalsAny | validation | public function equalsAny(array $others, $caseSensitive = true)
{
foreach ($others as $other) {
if ($this->equals($other, $caseSensitive)) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q242176 | Token.isKeyCaseSensitive | validation | public static function isKeyCaseSensitive($caseSensitive, $key)
{
if (\is_array($caseSensitive)) {
return isset($caseSensitive[$key]) ? $caseSensitive[$key] : true;
}
return $caseSensitive;
} | php | {
"resource": ""
} |
q242177 | Token.getNameForId | validation | public static function getNameForId($id)
{
if (CT::has($id)) {
return CT::getName($id);
}
$name = token_name($id);
return 'UNKNOWN' === $name ? null : $name;
} | php | {
"resource": ""
} |
q242178 | Token.getKeywords | validation | public static function getKeywords()
{
static $keywords = null;
if (null === $keywords) {
$keywords = self::getTokenKindsForNames(['T_ABSTRACT', 'T_ARRAY', 'T_AS', 'T_BREAK', 'T_CALLABLE', 'T_CASE',
'T_CATCH', 'T_CLASS', 'T_CLONE', 'T_CONST', 'T_CONTINUE', 'T_DECLARE', '... | php | {
"resource": ""
} |
q242179 | Token.isGivenKind | validation | public function isGivenKind($possibleKind)
{
return $this->isArray && (\is_array($possibleKind) ? \in_array($this->id, $possibleKind, true) : $this->id === $possibleKind);
} | php | {
"resource": ""
} |
q242180 | Token.isWhitespace | validation | public function isWhitespace($whitespaces = " \t\n\r\0\x0B")
{
if (null === $whitespaces) {
$whitespaces = " \t\n\r\0\x0B";
}
if ($this->isArray && !$this->isGivenKind(T_WHITESPACE)) {
return false;
}
return '' === trim($this->content, $whitespaces);... | php | {
"resource": ""
} |
q242181 | Token.override | validation | public function override($other)
{
@trigger_error(__METHOD__.' is deprecated and will be removed in 3.0.', E_USER_DEPRECATED);
Tokens::setLegacyMode(true);
$prototype = $other instanceof self ? $other->getPrototype() : $other;
if ($this->equals($prototype)) {
return;
... | php | {
"resource": ""
} |
q242182 | ConfigurationResolver.getPath | validation | public function getPath()
{
if (null === $this->path) {
$filesystem = new Filesystem();
$cwd = $this->cwd;
if (1 === \count($this->options['path']) && '-' === $this->options['path'][0]) {
$this->path = $this->options['path'];
} else {
... | php | {
"resource": ""
} |
q242183 | ConfigurationResolver.isDryRun | validation | public function isDryRun()
{
if (null === $this->isDryRun) {
if ($this->isStdIn()) {
// Can't write to STDIN
$this->isDryRun = true;
} else {
$this->isDryRun = $this->options['dry-run'];
}
}
return $this->is... | php | {
"resource": ""
} |
q242184 | ConfigurationResolver.computeConfigFiles | validation | private function computeConfigFiles()
{
$configFile = $this->options['config'];
if (null !== $configFile) {
if (false === file_exists($configFile) || false === is_readable($configFile)) {
throw new InvalidConfigurationException(sprintf('Cannot read config file "%s".', $c... | php | {
"resource": ""
} |
q242185 | ConfigurationResolver.parseRules | validation | private function parseRules()
{
if (null === $this->options['rules']) {
return $this->getConfig()->getRules();
}
$rules = trim($this->options['rules']);
if ('' === $rules) {
throw new InvalidConfigurationException('Empty rules value is not allowed.');
... | php | {
"resource": ""
} |
q242186 | ConfigurationResolver.setOption | validation | private function setOption($name, $value)
{
if (!\array_key_exists($name, $this->options)) {
throw new InvalidConfigurationException(sprintf('Unknown option name: "%s".', $name));
}
$this->options[$name] = $value;
} | php | {
"resource": ""
} |
q242187 | AuthProxy.handle | validation | public function handle(Request $request, Closure $next)
{
// Grab the query parameters we need, remove signature since its not part of the signature calculation
$query = $request->query->all();
$signature = $query['signature'];
unset($query['signature']);
// Build a local si... | php | {
"resource": ""
} |
q242188 | ScripttagInstaller.scripttagExists | validation | protected function scripttagExists(array $shopScripttags, array $scripttag)
{
foreach ($shopScripttags as $shopScripttag) {
if ($shopScripttag->src === $scripttag['src']) {
// Found the scripttag in our list
return true;
}
}
return fal... | php | {
"resource": ""
} |
q242189 | ShopifyApp.api | validation | public function api()
{
$apiClass = Config::get('shopify-app.api_class');
$api = new $apiClass();
$api->setApiKey(Config::get('shopify-app.api_key'));
$api->setApiSecret(Config::get('shopify-app.api_secret'));
// Add versioning?
$version = Config::get('shopify-app.ap... | php | {
"resource": ""
} |
q242190 | ShopifyApp.sanitizeShopDomain | validation | public function sanitizeShopDomain($domain)
{
if (empty($domain)) {
return;
}
$configEndDomain = Config::get('shopify-app.myshopify_domain');
$domain = strtolower(preg_replace('/https?:\/\//i', '', trim($domain)));
if (strpos($domain, $configEndDomain) === false... | php | {
"resource": ""
} |
q242191 | ShopifyApp.createHmac | validation | public function createHmac(array $opts)
{
// Setup defaults
$data = $opts['data'];
$raw = $opts['raw'] ?? false;
$buildQuery = $opts['buildQuery'] ?? false;
$buildQueryWithJoin = $opts['buildQueryWithJoin'] ?? false;
$encode = $opts['encode'] ?? false;
$secret... | php | {
"resource": ""
} |
q242192 | UsageCharge.activate | validation | public function activate()
{
// Ensure we have a recurring charge
$currentCharge = $this->shop->planCharge();
if (!$currentCharge->isType(Charge::CHARGE_RECURRING)) {
throw new Exception('Can only create usage charges for recurring charge.');
}
$this->response = ... | php | {
"resource": ""
} |
q242193 | UsageCharge.save | validation | public function save()
{
if (!$this->response) {
throw new Exception('No activation response was recieved.');
}
// Get the plan charge
$planCharge = $this->shop->planCharge();
// Create the charge
$charge = new Charge();
$charge->type = Charge::C... | php | {
"resource": ""
} |
q242194 | AuthControllerTrait.authenticate | validation | public function authenticate(AuthShop $request)
{
// Get the validated data
$validated = $request->validated();
$shopDomain = ShopifyApp::sanitizeShopDomain($validated['shop']);
$shop = ShopifyApp::shop($shopDomain);
// Start the process
$auth = new AuthShopHandler($... | php | {
"resource": ""
} |
q242195 | AuthControllerTrait.returnTo | validation | protected function returnTo()
{
// Set in AuthShop middleware
$return_to = Session::get('return_to');
if ($return_to) {
Session::forget('return_to');
return Redirect::to($return_to);
}
// No return_to, go to home route
return Redirect::route(... | php | {
"resource": ""
} |
q242196 | Charge.retrieve | validation | public function retrieve()
{
$path = null;
switch ($this->type) {
case self::CHARGE_CREDIT:
$path = 'application_credits';
break;
case self::CHARGE_ONETIME:
$path = 'application_charges';
break;
defau... | php | {
"resource": ""
} |
q242197 | Charge.isActiveTrial | validation | public function isActiveTrial()
{
return $this->isTrial() && Carbon::today()->lte(Carbon::parse($this->trial_ends_on));
} | php | {
"resource": ""
} |
q242198 | Charge.remainingTrialDays | validation | public function remainingTrialDays()
{
if (!$this->isTrial()) {
return;
}
return $this->isActiveTrial() ? Carbon::today()->diffInDays($this->trial_ends_on) : 0;
} | php | {
"resource": ""
} |
q242199 | Charge.remainingTrialDaysFromCancel | validation | public function remainingTrialDaysFromCancel()
{
if (!$this->isTrial()) {
return;
}
$cancelledDate = Carbon::parse($this->cancelled_on);
$trialEndsDate = Carbon::parse($this->trial_ends_on);
// Ensure cancelled date happened before the trial was supposed to end
... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.