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

Breadcrumb

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

function PropertyHelper::isProperty

14 calls to PropertyHelper::isProperty()
AttributeHelper::getAttributeTarget in vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AttributeHelper.php
ClassMemberSpacingSniff::findNextMember in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Classes/ClassMemberSpacingSniff.php
ClassStructureSniff::findNextGroup in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Classes/ClassStructureSniff.php
*
DisallowMultiPropertyDefinitionSniff::process in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Classes/DisallowMultiPropertyDefinitionSniff.php
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
DisallowOneLinePropertyDocCommentSniff::process in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Commenting/DisallowOneLinePropertyDocCommentSniff.php
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *

... See full list

File

vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/PropertyHelper.php, line 36

Class

PropertyHelper
@internal

Namespace

SlevomatCodingStandard\Helpers

Code

public static function isProperty(File $phpcsFile, int $variablePointer, bool $promoted = false) : bool {
    $tokens = $phpcsFile->getTokens();
    $previousPointer = TokenHelper::findPreviousExcluding($phpcsFile, array_merge(TokenHelper::$ineffectiveTokenCodes, TokenHelper::getTypeHintTokenCodes(), [
        T_NULLABLE,
    ]), $variablePointer - 1);
    if ($tokens[$previousPointer]['code'] === T_STATIC) {
        $previousPointer = TokenHelper::findPreviousEffective($phpcsFile, $previousPointer - 1);
    }
    if (in_array($tokens[$previousPointer]['code'], [
        T_PUBLIC,
        T_PROTECTED,
        T_PRIVATE,
        T_VAR,
        T_READONLY,
    ], true)) {
        $constructorPointer = TokenHelper::findPrevious($phpcsFile, T_FUNCTION, $previousPointer - 1);
        if ($constructorPointer === null) {
            return true;
        }
        return $tokens[$constructorPointer]['parenthesis_closer'] < $previousPointer || $promoted;
    }
    if (!array_key_exists('conditions', $tokens[$variablePointer]) || count($tokens[$variablePointer]['conditions']) === 0) {
        return false;
    }
    $functionPointer = TokenHelper::findPrevious($phpcsFile, array_merge(TokenHelper::$functionTokenCodes, [
        T_SEMICOLON,
        T_CLOSE_CURLY_BRACKET,
        T_OPEN_CURLY_BRACKET,
    ]), $variablePointer - 1);
    if ($functionPointer !== null && in_array($tokens[$functionPointer]['code'], TokenHelper::$functionTokenCodes, true)) {
        return false;
    }
    $conditionCode = array_values($tokens[$variablePointer]['conditions'])[count($tokens[$variablePointer]['conditions']) - 1];
    return in_array($conditionCode, Tokens::$ooScopeTokens, true);
}

API Navigation

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