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

Breadcrumb

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

class FetchingDeprecatedConstRule

@implements Rule<ConstFetch>

Hierarchy

  • class \PHPStan\Rules\Deprecations\FetchingDeprecatedConstRule implements \PHPStan\Rules\Rule

Expanded class hierarchy of FetchingDeprecatedConstRule

File

vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/FetchingDeprecatedConstRule.php, line 16

Namespace

PHPStan\Rules\Deprecations
View source
class FetchingDeprecatedConstRule implements Rule {
    
    /** @var ReflectionProvider */
    private $reflectionProvider;
    
    /** @var DeprecatedScopeHelper */
    private $deprecatedScopeHelper;
    public function __construct(ReflectionProvider $reflectionProvider, DeprecatedScopeHelper $deprecatedScopeHelper) {
        $this->reflectionProvider = $reflectionProvider;
        $this->deprecatedScopeHelper = $deprecatedScopeHelper;
    }
    public function getNodeType() : string {
        return ConstFetch::class;
    }
    public function processNode(Node $node, Scope $scope) : array {
        if ($this->deprecatedScopeHelper
            ->isScopeDeprecated($scope)) {
            return [];
        }
        if (!$this->reflectionProvider
            ->hasConstant($node->name, $scope)) {
            return [];
        }
        $constantReflection = $this->reflectionProvider
            ->getConstant($node->name, $scope);
        if ($constantReflection->isDeprecated()
            ->yes()) {
            return [
                RuleErrorBuilder::message(sprintf($constantReflection->getDeprecatedDescription() ?? 'Use of constant %s is deprecated.', $constantReflection->getName()))
                    ->identifier('constant.deprecated')
                    ->build(),
            ];
        }
        return [];
    }

}

Members

Title Sort descending Modifiers Object type Summary
FetchingDeprecatedConstRule::$deprecatedScopeHelper private property @var DeprecatedScopeHelper
FetchingDeprecatedConstRule::$reflectionProvider private property @var ReflectionProvider
FetchingDeprecatedConstRule::getNodeType public function
FetchingDeprecatedConstRule::processNode public function
FetchingDeprecatedConstRule::__construct public function
RSS feed
Powered by Drupal