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

Breadcrumb

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

function VariableAnalysisSniff::processVariableAsClassProperty

* Process a class property that is being defined. * * Property definitions are ignored currently because all property access is * legal, even to undefined properties. * * Can be called for any token and will return false if the variable is not * of this type. * *

Parameters

File $phpcsFile: * @param int $stackPtr * * @return bool

1 call to VariableAnalysisSniff::processVariableAsClassProperty()
VariableAnalysisSniff::processVariable in vendor/sirbrillig/phpcs-variable-analysis/VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php
* Process a normal variable in the code. * * Most importantly, this function determines if the variable use is a "read" * (using the variable for something) or a "write" (an assignment) or, * sometimes, both at once. * …

File

vendor/sirbrillig/phpcs-variable-analysis/VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php, line 865

Class

VariableAnalysisSniff

Namespace

VariableAnalysis\Sniffs\CodeAnalysis

Code

protected function processVariableAsClassProperty(File $phpcsFile, $stackPtr) {
    // Make sure we are not in a class method before assuming it's a property.
    $tokens = $phpcsFile->getTokens();
    
    /** @var array{conditions?: (int|string)[], content?: string}|null */
    $token = $tokens[$stackPtr];
    if ($token && !empty($token['conditions']) && !empty($token['content']) && !Helpers::areConditionsWithinFunctionBeforeClass($token)) {
        return Helpers::areAnyConditionsAClass($token);
    }
    return false;
}

API Navigation

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