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

Breadcrumb

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

function TestClassesProtectedPropertyModulesRule::processNode

Throws

\PHPStan\ShouldNotHappenException

File

vendor/mglaman/phpstan-drupal/src/Rules/Drupal/TestClassesProtectedPropertyModulesRule.php, line 30

Class

TestClassesProtectedPropertyModulesRule
@implements Rule<ClassPropertyNode>

Namespace

mglaman\PHPStanDrupal\Rules\Drupal

Code

public function processNode(Node $node, Scope $scope) : array {
    if ($node->getName() !== 'modules') {
        return [];
    }
    $scopeClassReflection = $node->getClassReflection();
    if ($scopeClassReflection->isAnonymous()) {
        return [];
    }
    if (!in_array(TestCase::class, $scopeClassReflection->getParentClassesNames(), true)) {
        return [];
    }
    if ($node->isPublic()) {
        return [
            RuleErrorBuilder::message(sprintf('Property %s::$modules property must be protected.', $scopeClassReflection->getDisplayName()))
                ->tip('Change record: https://www.drupal.org/node/2909426')
                ->build(),
        ];
    }
    return [];
}

API Navigation

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