function DisallowImplicitArrayCreationSniff::isCreatedInList
1 call to DisallowImplicitArrayCreationSniff::isCreatedInList()
- DisallowImplicitArrayCreationSniff::hasExplicitCreation in vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ Arrays/ DisallowImplicitArrayCreationSniff.php
File
-
vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ Arrays/ DisallowImplicitArrayCreationSniff.php, line 217
Class
Namespace
SlevomatCodingStandard\Sniffs\ArraysCode
private function isCreatedInList(File $phpcsFile, int $variablePointer, int $scopeOpenerPointer) : bool {
$tokens = $phpcsFile->getTokens();
$parenthesisOpenerPointer = TokenHelper::findPrevious($phpcsFile, [
T_OPEN_PARENTHESIS,
T_OPEN_SHORT_ARRAY,
T_OPEN_SQUARE_BRACKET,
], $variablePointer - 1, $scopeOpenerPointer);
if ($parenthesisOpenerPointer === null) {
return false;
}
if ($tokens[$parenthesisOpenerPointer]['code'] === T_OPEN_PARENTHESIS) {
if ($tokens[$parenthesisOpenerPointer]['parenthesis_closer'] < $variablePointer) {
return false;
}
$pointerBeforeParenthesisOpener = TokenHelper::findPreviousEffective($phpcsFile, $parenthesisOpenerPointer - 1);
return $tokens[$pointerBeforeParenthesisOpener]['code'] === T_LIST;
}
return $tokens[$parenthesisOpenerPointer]['bracket_closer'] > $variablePointer;
}