diff --git a/tests/PHPStan/Rules/NameHookedRuleTest.php b/tests/PHPStan/Rules/NameHookedRuleTest.php new file mode 100644 index 0000000000..80419b3ab0 --- /dev/null +++ b/tests/PHPStan/Rules/NameHookedRuleTest.php @@ -0,0 +1,53 @@ + + */ +class NameHookedRuleTest extends RuleTestCase +{ + + /** + * @return Rule + */ + protected function getRule(): Rule + { + return new class implements Rule { + + public function getNodeType(): string + { + return Name::class; + } + + /** + * @param Name $node + */ + public function processNode(Node $node, Scope $scope): array + { + $error = RuleErrorBuilder::message('Found a name: ' . $node->toString()) + ->identifier('test.name.hooked') + ->build(); + + return [$error]; + } + + }; + } + + public function testRule(): void + { + $this->analyse([__DIR__ . '/data/name-hooked.php'], [ + [ + 'Found a name: NameHooked', + 3, + ], + ]); + } + +} diff --git a/tests/PHPStan/Rules/data/name-hooked.php b/tests/PHPStan/Rules/data/name-hooked.php new file mode 100644 index 0000000000..c6d1f183bc --- /dev/null +++ b/tests/PHPStan/Rules/data/name-hooked.php @@ -0,0 +1,3 @@ +