function DisallowImplicitArrayCreationSniff::isCreatedInForeach
1 call to DisallowImplicitArrayCreationSniff::isCreatedInForeach()
- DisallowImplicitArrayCreationSniff::hasExplicitCreation in vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ Arrays/ DisallowImplicitArrayCreationSniff.php
File
-
vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ Arrays/ DisallowImplicitArrayCreationSniff.php, line 243
Class
Namespace
SlevomatCodingStandard\Sniffs\ArraysCode
private function isCreatedInForeach(File $phpcsFile, int $variablePointer, int $scopeCloserPointer) : bool {
$tokens = $phpcsFile->getTokens();
$parenthesisCloserPointer = TokenHelper::findNext($phpcsFile, T_CLOSE_PARENTHESIS, $variablePointer + 1, $scopeCloserPointer);
return $parenthesisCloserPointer !== null && array_key_exists('parenthesis_owner', $tokens[$parenthesisCloserPointer]) && $tokens[$tokens[$parenthesisCloserPointer]['parenthesis_owner']]['code'] === T_FOREACH && $tokens[$parenthesisCloserPointer]['parenthesis_opener'] < $variablePointer;
}