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

Breadcrumb

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

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

DisallowImplicitArrayCreationSniff

Namespace

SlevomatCodingStandard\Sniffs\Arrays

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal