Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DisallowImplicitArrayCreationSniff.php

function DisallowImplicitArrayCreationSniff::isCreatedByReferencedParameterInFunctionCall

1 call to DisallowImplicitArrayCreationSniff::isCreatedByReferencedParameterInFunctionCall()
DisallowImplicitArrayCreationSniff::hasExplicitCreation in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Arrays/DisallowImplicitArrayCreationSniff.php

File

vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Arrays/DisallowImplicitArrayCreationSniff.php, line 254

Class

DisallowImplicitArrayCreationSniff

Namespace

SlevomatCodingStandard\Sniffs\Arrays

Code

private function isCreatedByReferencedParameterInFunctionCall(File $phpcsFile, int $variablePointer, int $scopeOpenerPointer) : bool {
    $tokens = $phpcsFile->getTokens();
    $parenthesisOpenerPointer = TokenHelper::findPrevious($phpcsFile, T_OPEN_PARENTHESIS, $variablePointer - 1, $scopeOpenerPointer);
    if ($parenthesisOpenerPointer === null || $tokens[$parenthesisOpenerPointer]['parenthesis_closer'] < $variablePointer) {
        return false;
    }
    $pointerBeforeParenthesisOpener = TokenHelper::findPreviousEffective($phpcsFile, $parenthesisOpenerPointer - 1);
    return $tokens[$pointerBeforeParenthesisOpener]['code'] === T_STRING;
}
RSS feed
Powered by Drupal