diff --git a/tests/PHPStan/Node/AttributeArgRule.php b/tests/PHPStan/Node/AttributeArgRule.php new file mode 100644 index 0000000000..90865da170 --- /dev/null +++ b/tests/PHPStan/Node/AttributeArgRule.php @@ -0,0 +1,31 @@ + + */ +class AttributeArgRule implements Rule +{ + + public const ERROR_MESSAGE = 'Found Arg'; + + public function getNodeType(): string + { + return Node\Arg::class; + } + + /** + * @param Node\Arg $node + * @return string[] + */ + public function processNode(Node $node, Scope $scope): array + { + return [self::ERROR_MESSAGE]; + } + +} diff --git a/tests/PHPStan/Node/AttributeArgRuleTest.php b/tests/PHPStan/Node/AttributeArgRuleTest.php index d1946f91c3..29773859d8 100644 --- a/tests/PHPStan/Node/AttributeArgRuleTest.php +++ b/tests/PHPStan/Node/AttributeArgRuleTest.php @@ -3,43 +3,29 @@ namespace PHPStan\Node; use PhpParser\Node; -use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; -use PHPStan\Rules\RuleError; use PHPStan\Testing\RuleTestCase; +/** + * @extends RuleTestCase + */ class AttributeArgRuleTest extends RuleTestCase { - public const ERROR_MESSAGE = 'Found Arg'; - + /** + * @return Rule + */ protected function getRule(): Rule { - return new class() implements Rule { - - public function getNodeType(): string - { - return Node\Arg::class; - } - - /** - * @param Node\Arg $node - * @return RuleError[] - */ - public function processNode(Node $node, Scope $scope): array - { - return [AttributeArgRuleTest::ERROR_MESSAGE]; - } - - }; + return new AttributeArgRule(); } public function dataRule(): iterable { yield [ __DIR__ . '/data/attributes.php', - self::ERROR_MESSAGE, - [8, 16, 20, 23, 26, 27, 34, 40], + AttributeArgRule::ERROR_MESSAGE, + [8, 16, 20, 23, 26, 27, 34, 40], ]; } diff --git a/tests/PHPStan/Node/AttributeGroupRule.php b/tests/PHPStan/Node/AttributeGroupRule.php new file mode 100644 index 0000000000..127c4f1f62 --- /dev/null +++ b/tests/PHPStan/Node/AttributeGroupRule.php @@ -0,0 +1,31 @@ + + */ +class AttributeGroupRule implements Rule +{ + + public const ERROR_MESSAGE = 'Found AttributeGroup'; + + public function getNodeType(): string + { + return Node\AttributeGroup::class; + } + + /** + * @param Node\AttributeGroup $node + * @return string[] + */ + public function processNode(Node $node, Scope $scope): array + { + return [self::ERROR_MESSAGE]; + } + +} diff --git a/tests/PHPStan/Node/AttributeGroupRuleTest.php b/tests/PHPStan/Node/AttributeGroupRuleTest.php index 4739c28919..d1e3044f44 100644 --- a/tests/PHPStan/Node/AttributeGroupRuleTest.php +++ b/tests/PHPStan/Node/AttributeGroupRuleTest.php @@ -3,43 +3,29 @@ namespace PHPStan\Node; use PhpParser\Node; -use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; -use PHPStan\Rules\RuleError; use PHPStan\Testing\RuleTestCase; +/** + * @extends RuleTestCase + */ class AttributeGroupRuleTest extends RuleTestCase { - public const ERROR_MESSAGE = 'Found AttributeGroup'; - + /** + * @return Rule + */ protected function getRule(): Rule { - return new class() implements Rule { - - public function getNodeType(): string - { - return Node\AttributeGroup::class; - } - - /** - * @param Node\AttributeGroup $node - * @return RuleError[] - */ - public function processNode(Node $node, Scope $scope): array - { - return [AttributeGroupRuleTest::ERROR_MESSAGE]; - } - - }; + return new AttributeGroupRule(); } public function dataRule(): iterable { yield [ __DIR__ . '/data/attributes.php', - self::ERROR_MESSAGE, - [8, 16, 20, 23, 26, 27, 34, 40], + AttributeGroupRule::ERROR_MESSAGE, + [8, 16, 20, 23, 26, 27, 34, 40], ]; } diff --git a/tests/PHPStan/Node/AttributeRule.php b/tests/PHPStan/Node/AttributeRule.php new file mode 100644 index 0000000000..9b7519bce8 --- /dev/null +++ b/tests/PHPStan/Node/AttributeRule.php @@ -0,0 +1,31 @@ + + */ +class AttributeRule implements Rule +{ + + public const ERROR_MESSAGE = 'Found Attribute'; + + public function getNodeType(): string + { + return Node\Attribute::class; + } + + /** + * @param Node\Attribute $node + * @return string[] + */ + public function processNode(Node $node, Scope $scope): array + { + return [self::ERROR_MESSAGE]; + } + +} diff --git a/tests/PHPStan/Node/AttributeRuleTest.php b/tests/PHPStan/Node/AttributeRuleTest.php index f1f6efce7d..9eadcd0fdb 100644 --- a/tests/PHPStan/Node/AttributeRuleTest.php +++ b/tests/PHPStan/Node/AttributeRuleTest.php @@ -3,43 +3,30 @@ namespace PHPStan\Node; use PhpParser\Node; -use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; -use PHPStan\Rules\RuleError; use PHPStan\Testing\RuleTestCase; +use const PHP_VERSION_ID; +/** + * @extends RuleTestCase + */ class AttributeRuleTest extends RuleTestCase { - public const ERROR_MESSAGE = 'Found Attribute'; - + /** + * @return Rule + */ protected function getRule(): Rule { - return new class() implements Rule { - - public function getNodeType(): string - { - return Node\Attribute::class; - } - - /** - * @param Node\Attribute $node - * @return RuleError[] - */ - public function processNode(Node $node, Scope $scope): array - { - return [AttributeRuleTest::ERROR_MESSAGE]; - } - - }; + return new AttributeRule(); } public function dataRule(): iterable { yield [ __DIR__ . '/data/attributes.php', - self::ERROR_MESSAGE, - [8, 16, 20, 23, 26, 27, 34, 40], + AttributeRule::ERROR_MESSAGE, + [8, 16, 20, 23, 26, 27, 34, 40], ]; } diff --git a/tests/PHPStan/Node/data/attributes.php b/tests/PHPStan/Node/data/attributes.php index 050f5c7845..0103b343c4 100644 --- a/tests/PHPStan/Node/data/attributes.php +++ b/tests/PHPStan/Node/data/attributes.php @@ -1,4 +1,4 @@ -= 8.0 namespace NodeCallbackCalled;