function PluginAnnotationContextDefinitionsRule::doProcessNode
Overrides DeprecatedAnnotationsRuleBase::doProcessNode
File
-
vendor/
mglaman/ phpstan-drupal/ src/ Rules/ Deprecations/ PluginAnnotationContextDefinitionsRule.php, line 19
Class
Namespace
mglaman\PHPStanDrupal\Rules\DeprecationsCode
protected function doProcessNode(ClassReflection $reflection, Node\Stmt\Class_ $node, Scope $scope) : array {
$annotation = $reflection->getResolvedPhpDoc();
// Plugins should always be annotated, but maybe this class is missing its
// annotation since it swaps an existing one.
if ($annotation === null) {
return [];
}
$hasMatch = preg_match('/context\\s?=\\s?{/', $annotation->getPhpDocString());
if ($hasMatch === false) {
throw new ShouldNotHappenException('Unexpected error when trying to run match on phpDoc string.');
}
if ($hasMatch === 1) {
return [
'Providing context definitions via the "context" key is deprecated in Drupal 8.7.x and will be removed before Drupal 9.0.0. Use the "context_definitions" key instead.',
];
}
return [];
}