class TestClassesProtectedPropertyModulesRule
@implements Rule<ClassPropertyNode>
Hierarchy
- class \mglaman\PHPStanDrupal\Rules\Drupal\TestClassesProtectedPropertyModulesRule implements \PHPStan\Rules\Rule
Expanded class hierarchy of TestClassesProtectedPropertyModulesRule
File
-
vendor/
mglaman/ phpstan-drupal/ src/ Rules/ Drupal/ TestClassesProtectedPropertyModulesRule.php, line 19
Namespace
mglaman\PHPStanDrupal\Rules\DrupalView source
class TestClassesProtectedPropertyModulesRule implements Rule {
public function getNodeType() : string {
return ClassPropertyNode::class;
}
/**
* @throws \PHPStan\ShouldNotHappenException
*/
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 [];
}
}