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

Breadcrumb

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

function RequireConstructorPropertyPromotionSniff::isParameterModifiedBeforeAssignment

1 call to RequireConstructorPropertyPromotionSniff::isParameterModifiedBeforeAssignment()
RequireConstructorPropertyPromotionSniff::process in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Classes/RequireConstructorPropertyPromotionSniff.php
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *

File

vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Classes/RequireConstructorPropertyPromotionSniff.php, line 362

Class

RequireConstructorPropertyPromotionSniff

Namespace

SlevomatCodingStandard\Sniffs\Classes

Code

private function isParameterModifiedBeforeAssignment(File $phpcsFile, int $functionPointer, string $parameterName, int $assignmentPointer) : bool {
    $tokens = $phpcsFile->getTokens();
    for ($i = $assignmentPointer - 1; $i > $tokens[$functionPointer]['scope_opener']; $i--) {
        if ($tokens[$i]['code'] !== T_VARIABLE) {
            continue;
        }
        if ($tokens[$i]['content'] !== $parameterName) {
            continue;
        }
        $nextPointer = TokenHelper::findNextEffective($phpcsFile, $i + 1);
        if (in_array($tokens[$nextPointer]['code'], Tokens::$assignmentTokens, true)) {
            return true;
        }
        if ($tokens[$nextPointer]['code'] === T_INC) {
            return true;
        }
        $previousPointer = TokenHelper::findNextEffective($phpcsFile, $i - 1);
        if ($tokens[$previousPointer]['code'] === T_DEC) {
            return true;
        }
    }
    return false;
}

API Navigation

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