From 4d52e3c6273dac4b084dcf14ba02083b27d5ab3f Mon Sep 17 00:00:00 2001 From: Carlos Alandete Sastre Date: Sat, 23 Dec 2023 19:54:19 +0100 Subject: [PATCH 1/9] wip is named --- .../Declaration/DeclarationAssertion.php | 6 +-- .../ShouldBeAbstract/ShouldBeAbstract.php | 2 +- .../ShouldBeFinal/ShouldBeFinal.php | 2 +- .../Declaration/ShouldBeNamed/NameRule.php | 17 +++++++ .../ShouldBeNamed/ShouldBeNamed.php | 45 +++++++++++++++++++ .../ShouldBeReadonly/ShouldBeReadonly.php | 2 +- .../ShouldHaveOnlyOnePublicMethod.php | 2 +- .../ShouldNotBeAbstract.php | 2 +- .../ShouldNotBeFinal/ShouldNotBeFinal.php | 2 +- .../Declaration/AbstractExtractor.php | 2 +- .../Declaration/ClassnameExtractor.php | 27 +++++++++++ .../Extractor/Declaration/FinalExtractor.php | 2 +- .../Declaration/OnePublicMethodExtractor.php | 2 +- .../Declaration/ReadonlyExtractor.php | 2 +- .../Builder/DeclarationStatementBuilder.php | 18 ++++---- src/Test/Builder/AssertionStep.php | 9 ++++ src/Test/DeclarationRule.php | 5 +++ src/Test/RelationRule.php | 8 ++++ src/Test/Rule.php | 5 +++ 19 files changed, 139 insertions(+), 21 deletions(-) create mode 100644 src/Rule/Assertion/Declaration/ShouldBeNamed/NameRule.php create mode 100644 src/Rule/Assertion/Declaration/ShouldBeNamed/ShouldBeNamed.php create mode 100644 src/Rule/Extractor/Declaration/ClassnameExtractor.php diff --git a/src/Rule/Assertion/Declaration/DeclarationAssertion.php b/src/Rule/Assertion/Declaration/DeclarationAssertion.php index d1aaaa44..385ef0ae 100644 --- a/src/Rule/Assertion/Declaration/DeclarationAssertion.php +++ b/src/Rule/Assertion/Declaration/DeclarationAssertion.php @@ -16,7 +16,7 @@ abstract class DeclarationAssertion implements Assertion { - /** @var array, array}> */ + /** @var array, array, array}> */ protected array $statements; protected Configuration $configuration; protected ReflectionProvider $reflectionProvider; @@ -59,12 +59,12 @@ public function prepareMessage(string $ruleName, string $message): string : $message; } - abstract protected function meetsDeclaration(Node $node, Scope $scope): bool; + abstract protected function meetsDeclaration(Node $node, Scope $scope, array $params = []): bool; /** * @param class-string $subject */ - abstract protected function getMessage(string $ruleName, string $subject): string; + abstract protected function getMessage(string $ruleName, string $subject, array $params = []): string; /** * @param array $tips diff --git a/src/Rule/Assertion/Declaration/ShouldBeAbstract/ShouldBeAbstract.php b/src/Rule/Assertion/Declaration/ShouldBeAbstract/ShouldBeAbstract.php index c0866388..eb8975cd 100644 --- a/src/Rule/Assertion/Declaration/ShouldBeAbstract/ShouldBeAbstract.php +++ b/src/Rule/Assertion/Declaration/ShouldBeAbstract/ShouldBeAbstract.php @@ -34,7 +34,7 @@ protected function applyValidation(string $ruleName, ClassReflection $subject, b return $this->applyShould($ruleName, $subject, $meetsDeclaration, $tips); } - protected function getMessage(string $ruleName, string $subject): string + protected function getMessage(string $ruleName, string $subject, array $params = []): string { return $this->prepareMessage( $ruleName, diff --git a/src/Rule/Assertion/Declaration/ShouldBeFinal/ShouldBeFinal.php b/src/Rule/Assertion/Declaration/ShouldBeFinal/ShouldBeFinal.php index f8149a2d..e56fe42b 100644 --- a/src/Rule/Assertion/Declaration/ShouldBeFinal/ShouldBeFinal.php +++ b/src/Rule/Assertion/Declaration/ShouldBeFinal/ShouldBeFinal.php @@ -39,7 +39,7 @@ protected function applyValidation(string $ruleName, ClassReflection $subject, b return $this->applyShould($ruleName, $subject, $meetsDeclaration, $tips); } - protected function getMessage(string $ruleName, string $subject): string + protected function getMessage(string $ruleName, string $subject, array $params = []): string { return $this->prepareMessage( $ruleName, diff --git a/src/Rule/Assertion/Declaration/ShouldBeNamed/NameRule.php b/src/Rule/Assertion/Declaration/ShouldBeNamed/NameRule.php new file mode 100644 index 00000000..4cabafef --- /dev/null +++ b/src/Rule/Assertion/Declaration/ShouldBeNamed/NameRule.php @@ -0,0 +1,17 @@ + + */ +final class NameRule extends ShouldBeAbstract implements Rule +{ + use ClassnameExtractor; +} diff --git a/src/Rule/Assertion/Declaration/ShouldBeNamed/ShouldBeNamed.php b/src/Rule/Assertion/Declaration/ShouldBeNamed/ShouldBeNamed.php new file mode 100644 index 00000000..9253898a --- /dev/null +++ b/src/Rule/Assertion/Declaration/ShouldBeNamed/ShouldBeNamed.php @@ -0,0 +1,45 @@ +applyShould($ruleName, $subject, $meetsDeclaration, $tips); + } + + protected function getMessage(string $ruleName, string $subject, array $params = []): string + { + $message = $params['isRegex'] === true + ? sprintf('%s should be named matching the regex "%s', $subject, $params['classname']) + : sprintf('%s should be named "%s"', $subject, $params['classname']); + + return $this->prepareMessage($ruleName, $message); + } +} diff --git a/src/Rule/Assertion/Declaration/ShouldBeReadonly/ShouldBeReadonly.php b/src/Rule/Assertion/Declaration/ShouldBeReadonly/ShouldBeReadonly.php index 1f2b717e..d9ddffed 100644 --- a/src/Rule/Assertion/Declaration/ShouldBeReadonly/ShouldBeReadonly.php +++ b/src/Rule/Assertion/Declaration/ShouldBeReadonly/ShouldBeReadonly.php @@ -39,7 +39,7 @@ protected function applyValidation(string $ruleName, ClassReflection $subject, b return $this->applyShould($ruleName, $subject, $meetsDeclaration, $tips); } - protected function getMessage(string $ruleName, string $subject): string + protected function getMessage(string $ruleName, string $subject, array $params = []): string { return $this->prepareMessage( $ruleName, diff --git a/src/Rule/Assertion/Declaration/ShouldHaveOnlyOnePublicMethod/ShouldHaveOnlyOnePublicMethod.php b/src/Rule/Assertion/Declaration/ShouldHaveOnlyOnePublicMethod/ShouldHaveOnlyOnePublicMethod.php index 834544dd..5b42b86c 100644 --- a/src/Rule/Assertion/Declaration/ShouldHaveOnlyOnePublicMethod/ShouldHaveOnlyOnePublicMethod.php +++ b/src/Rule/Assertion/Declaration/ShouldHaveOnlyOnePublicMethod/ShouldHaveOnlyOnePublicMethod.php @@ -34,7 +34,7 @@ protected function applyValidation(string $ruleName, ClassReflection $subject, b return $this->applyShould($ruleName, $subject, $meetsDeclaration, $tips); } - protected function getMessage(string $ruleName, string $subject): string + protected function getMessage(string $ruleName, string $subject, array $params = []): string { return $this->prepareMessage($ruleName, sprintf('%s should have only one public method', $subject)); } diff --git a/src/Rule/Assertion/Declaration/ShouldNotBeAbstract/ShouldNotBeAbstract.php b/src/Rule/Assertion/Declaration/ShouldNotBeAbstract/ShouldNotBeAbstract.php index 454f6508..3d9984ce 100644 --- a/src/Rule/Assertion/Declaration/ShouldNotBeAbstract/ShouldNotBeAbstract.php +++ b/src/Rule/Assertion/Declaration/ShouldNotBeAbstract/ShouldNotBeAbstract.php @@ -34,7 +34,7 @@ protected function applyValidation(string $ruleName, ClassReflection $subject, b return $this->applyShouldNot($ruleName, $subject, $meetsDeclaration, $tips); } - protected function getMessage(string $ruleName, string $subject): string + protected function getMessage(string $ruleName, string $subject, array $params = []): string { return $this->prepareMessage( $ruleName, diff --git a/src/Rule/Assertion/Declaration/ShouldNotBeFinal/ShouldNotBeFinal.php b/src/Rule/Assertion/Declaration/ShouldNotBeFinal/ShouldNotBeFinal.php index e31d54ab..6cf7f0d5 100644 --- a/src/Rule/Assertion/Declaration/ShouldNotBeFinal/ShouldNotBeFinal.php +++ b/src/Rule/Assertion/Declaration/ShouldNotBeFinal/ShouldNotBeFinal.php @@ -34,7 +34,7 @@ protected function applyValidation(string $ruleName, ClassReflection $subject, b return $this->applyShouldNot($ruleName, $subject, $meetsDeclaration, $tips); } - protected function getMessage(string $ruleName, string $subject): string + protected function getMessage(string $ruleName, string $subject, array $params = []): string { return $this->prepareMessage( $ruleName, diff --git a/src/Rule/Extractor/Declaration/AbstractExtractor.php b/src/Rule/Extractor/Declaration/AbstractExtractor.php index 17e217de..cb3cda4a 100644 --- a/src/Rule/Extractor/Declaration/AbstractExtractor.php +++ b/src/Rule/Extractor/Declaration/AbstractExtractor.php @@ -16,7 +16,7 @@ public function getNodeType(): string /** * @param InClassNode $node */ - protected function meetsDeclaration(Node $node, Scope $scope): bool + protected function meetsDeclaration(Node $node, Scope $scope, array $params = []): bool { return $node->getClassReflection()->isAbstract(); } diff --git a/src/Rule/Extractor/Declaration/ClassnameExtractor.php b/src/Rule/Extractor/Declaration/ClassnameExtractor.php new file mode 100644 index 00000000..de6aeb8c --- /dev/null +++ b/src/Rule/Extractor/Declaration/ClassnameExtractor.php @@ -0,0 +1,27 @@ +getClassReflection()->getName()) === 1; + } + + return $node->getClassReflection()->getName() === $params['classname']; + } +} diff --git a/src/Rule/Extractor/Declaration/FinalExtractor.php b/src/Rule/Extractor/Declaration/FinalExtractor.php index e8d4fa07..bf966210 100644 --- a/src/Rule/Extractor/Declaration/FinalExtractor.php +++ b/src/Rule/Extractor/Declaration/FinalExtractor.php @@ -16,7 +16,7 @@ public function getNodeType(): string /** * @param InClassNode $node */ - protected function meetsDeclaration(Node $node, Scope $scope): bool + protected function meetsDeclaration(Node $node, Scope $scope, array $params = []): bool { return $node->getClassReflection()->isFinal(); } diff --git a/src/Rule/Extractor/Declaration/OnePublicMethodExtractor.php b/src/Rule/Extractor/Declaration/OnePublicMethodExtractor.php index f854267c..d562aac6 100644 --- a/src/Rule/Extractor/Declaration/OnePublicMethodExtractor.php +++ b/src/Rule/Extractor/Declaration/OnePublicMethodExtractor.php @@ -16,7 +16,7 @@ public function getNodeType(): string /** * @param InClassNode $node */ - protected function meetsDeclaration(Node $node, Scope $scope): bool + protected function meetsDeclaration(Node $node, Scope $scope, array $params = []): bool { $reflectionClass = $node->getClassReflection()->getNativeReflection(); $methods = $reflectionClass->getMethods(1); diff --git a/src/Rule/Extractor/Declaration/ReadonlyExtractor.php b/src/Rule/Extractor/Declaration/ReadonlyExtractor.php index c5fc93b5..3c3b3f8d 100644 --- a/src/Rule/Extractor/Declaration/ReadonlyExtractor.php +++ b/src/Rule/Extractor/Declaration/ReadonlyExtractor.php @@ -16,7 +16,7 @@ public function getNodeType(): string /** * @param InClassNode $node */ - protected function meetsDeclaration(Node $node, Scope $scope): bool + protected function meetsDeclaration(Node $node, Scope $scope, array $params = []): bool { return $node->getClassReflection()->isReadOnly(); } diff --git a/src/Statement/Builder/DeclarationStatementBuilder.php b/src/Statement/Builder/DeclarationStatementBuilder.php index f902a9c9..30d9de37 100644 --- a/src/Statement/Builder/DeclarationStatementBuilder.php +++ b/src/Statement/Builder/DeclarationStatementBuilder.php @@ -10,7 +10,7 @@ final class DeclarationStatementBuilder implements StatementBuilder { - /** @var array, array}> */ + /** @var array, array, array}> */ private array $statements = []; /** @var array */ @@ -30,14 +30,14 @@ public function __construct(string $assertion, array $rules) } /** - * @return array, array}> + * @return array, array, array}> */ public function build(): array { $params = $this->extractCurrentAssertion($this->rules); foreach ($params as $param) { - $this->addStatement($param[0], $param[1], $param[2], $param[3]); + $this->addStatement($param[0], $param[1], $param[2], $param[3], $param[4]); } return $this->statements; @@ -46,19 +46,21 @@ public function build(): array /** * @param array $subjectExcludes * @param array $tips + * @param array $params */ private function addStatement( string $ruleName, SelectorInterface $subject, array $subjectExcludes, - array $tips + array $tips, + array $params ): void { - $this->statements[] = [$ruleName, $subject, $subjectExcludes, $tips]; + $this->statements[] = [$ruleName, $subject, $subjectExcludes, $tips, $params]; } /** - * @param array $rules - * @return array, array}> + * @param array $rules + * @return array, array, array}> */ private function extractCurrentAssertion(array $rules): array { @@ -67,7 +69,7 @@ private function extractCurrentAssertion(array $rules): array if ($rule->getAssertion() === $this->assertion) { $ruleName = $this->extractRuleName($rule->getRuleName()); foreach ($rule->getSubjects() as $selector) { - $result[] = [$ruleName, $selector, $rule->getSubjectExcludes(), $rule->getTips()]; + $result[] = [$ruleName, $selector, $rule->getSubjectExcludes(), $rule->getTips(), $rule->getParams()]; } } } diff --git a/src/Test/Builder/AssertionStep.php b/src/Test/Builder/AssertionStep.php index 292e4ebc..e629ebb6 100644 --- a/src/Test/Builder/AssertionStep.php +++ b/src/Test/Builder/AssertionStep.php @@ -4,6 +4,7 @@ use PHPat\Rule\Assertion\Declaration\ShouldBeAbstract\ShouldBeAbstract; use PHPat\Rule\Assertion\Declaration\ShouldBeFinal\ShouldBeFinal; +use PHPat\Rule\Assertion\Declaration\ShouldBeNamed\ShouldBeNamed; use PHPat\Rule\Assertion\Declaration\ShouldBeReadonly\ShouldBeReadonly; use PHPat\Rule\Assertion\Declaration\ShouldHaveOnlyOnePublicMethod\ShouldHaveOnlyOnePublicMethod; use PHPat\Rule\Assertion\Declaration\ShouldNotBeAbstract\ShouldNotBeAbstract; @@ -19,6 +20,14 @@ class AssertionStep extends AbstractStep { + public function shouldBeNamed(string $classname, bool $regex): Rule + { + $this->rule->assertion = ShouldBeNamed::class; + $this->rule->params = ['isRegex' => $regex, 'classname' => $classname]; + + return new BuildStep($this->rule); + } + public function shouldBeAbstract(): Rule { $this->rule->assertion = ShouldBeAbstract::class; diff --git a/src/Test/DeclarationRule.php b/src/Test/DeclarationRule.php index 06027d54..70c6529c 100644 --- a/src/Test/DeclarationRule.php +++ b/src/Test/DeclarationRule.php @@ -55,4 +55,9 @@ public function getTips(): array { return []; } + + public function getParams(): array + { + return []; + } } diff --git a/src/Test/RelationRule.php b/src/Test/RelationRule.php index 7d9e1130..e74b7bef 100644 --- a/src/Test/RelationRule.php +++ b/src/Test/RelationRule.php @@ -28,6 +28,9 @@ final class RelationRule implements Rule /** @var array */ public array $tips = []; + /** @var array */ + public array $params = []; + /** * @return null|class-string|class-string */ @@ -65,4 +68,9 @@ public function getTips(): array { return $this->tips; } + + public function getParams(): array + { + return $this->params; + } } diff --git a/src/Test/Rule.php b/src/Test/Rule.php index 4c15ce8d..e90e2279 100644 --- a/src/Test/Rule.php +++ b/src/Test/Rule.php @@ -38,4 +38,9 @@ public function getRuleName(): string; * @return array */ public function getTips(): array; + + /** + * @return array + */ + public function getParams(): array; } From 4afa456637f635a4ae7b4c24f459904f2cff6725 Mon Sep 17 00:00:00 2001 From: Carlos Alandete Sastre Date: Sat, 23 Dec 2023 20:04:51 +0100 Subject: [PATCH 2/9] wip is named --- extension.neon | 6 +++ .../{NameRule.php => ClassnameRule.php} | 2 +- tests/unit/FakeTestParser.php | 8 ++- .../rules/ShouldBeNamed/ClassnameTest.php | 49 +++++++++++++++++++ 4 files changed, 63 insertions(+), 2 deletions(-) rename src/Rule/Assertion/Declaration/ShouldBeNamed/{NameRule.php => ClassnameRule.php} (85%) create mode 100644 tests/unit/rules/ShouldBeNamed/ClassnameTest.php diff --git a/extension.neon b/extension.neon index 4fa08b47..78d5b236 100644 --- a/extension.neon +++ b/extension.neon @@ -18,6 +18,12 @@ services: # # # # # DECLARATION RULES # # # # # + # ShouldBeNamed rules + - + class: PHPat\Rule\Assertion\Declaration\ShouldBeNamed\ClassnameRule + tags: + - phpstan.rules.rule + # ShouldBeReadonly rules - class: PHPat\Rule\Assertion\Declaration\ShouldBeReadonly\IsReadonlyRule diff --git a/src/Rule/Assertion/Declaration/ShouldBeNamed/NameRule.php b/src/Rule/Assertion/Declaration/ShouldBeNamed/ClassnameRule.php similarity index 85% rename from src/Rule/Assertion/Declaration/ShouldBeNamed/NameRule.php rename to src/Rule/Assertion/Declaration/ShouldBeNamed/ClassnameRule.php index 4cabafef..b0df7136 100644 --- a/src/Rule/Assertion/Declaration/ShouldBeNamed/NameRule.php +++ b/src/Rule/Assertion/Declaration/ShouldBeNamed/ClassnameRule.php @@ -11,7 +11,7 @@ /** * @implements Rule */ -final class NameRule extends ShouldBeAbstract implements Rule +final class ClassnameRule extends ShouldBeAbstract implements Rule { use ClassnameExtractor; } diff --git a/tests/unit/FakeTestParser.php b/tests/unit/FakeTestParser.php index d65abcd0..451f4906 100644 --- a/tests/unit/FakeTestParser.php +++ b/tests/unit/FakeTestParser.php @@ -23,6 +23,9 @@ class FakeTestParser extends TestParser /** @var array */ public array $tips = []; + /** @var array */ + public array $params = []; + public function __invoke(): array { $rule = new RelationRule(); @@ -31,6 +34,7 @@ public function __invoke(): array $rule->subjects = $this->subjects; $rule->targets = $this->targets; $rule->tips = $this->tips; + $rule->params = $this->params; return [$rule]; } @@ -40,8 +44,9 @@ public function __invoke(): array * @param array $subjects * @param array $targets * @param array $tips + * @param array $params */ - public static function create(string $ruleName, string $assertion, array $subjects, array $targets, array $tips = []): self + public static function create(string $ruleName, string $assertion, array $subjects, array $targets, array $tips = [], array $params = []): self { /** @var self $self */ $self = (new \ReflectionClass(self::class))->newInstanceWithoutConstructor(); @@ -50,6 +55,7 @@ public static function create(string $ruleName, string $assertion, array $subjec $self->subjects = $subjects; $self->targets = $targets; $self->tips = $tips; + $self->params = $params; return $self; } diff --git a/tests/unit/rules/ShouldBeNamed/ClassnameTest.php b/tests/unit/rules/ShouldBeNamed/ClassnameTest.php new file mode 100644 index 00000000..49d88c60 --- /dev/null +++ b/tests/unit/rules/ShouldBeNamed/ClassnameTest.php @@ -0,0 +1,49 @@ + + * @internal + * @coversNothing + */ +class ClassnameTest extends RuleTestCase +{ + public const RULE_NAME = 'test_FixtureClassShouldBeNamed'; + + public function testRule(): void + { + $this->analyse(['tests/fixtures/FixtureClass.php'], [ + [sprintf('%s should be named NotTheFixtureClassClassname', FixtureClass::class), 29], + ]); + } + + protected function getRule(): Rule + { + $testParser = FakeTestParser::create( + self::RULE_NAME, + ShouldBeAbstract::class, + [new Classname(FixtureClass::class, false)], + [], + ['isRegex' => false, 'classname' => 'NotTheFixtureClassClassname'] + ); + + return new AbstractRule( + new StatementBuilderFactory($testParser), + new Configuration(false, true, false), + $this->createReflectionProvider(), + self::getContainer()->getByType(FileTypeMapper::class) + ); + } +} From cd71f80bee49766440e21a676152ed1408790d83 Mon Sep 17 00:00:00 2001 From: Carlos Alandete Sastre Date: Sat, 23 Dec 2023 23:23:12 +0100 Subject: [PATCH 3/9] wip is named --- .../Assertion/Declaration/DeclarationAssertion.php | 14 ++++++++++---- .../ShouldBeAbstract/ShouldBeAbstract.php | 4 ++-- .../Declaration/ShouldBeFinal/ShouldBeFinal.php | 4 ++-- .../Declaration/ShouldBeNamed/ClassnameRule.php | 4 +--- .../Declaration/ShouldBeNamed/ShouldBeNamed.php | 9 +++++---- .../ShouldBeReadonly/ShouldBeReadonly.php | 4 ++-- .../ShouldHaveOnlyOnePublicMethod.php | 4 ++-- .../ShouldNotBeAbstract/ShouldNotBeAbstract.php | 4 ++-- .../ShouldNotBeFinal/ShouldNotBeFinal.php | 4 ++-- src/Rule/Assertion/Declaration/ValidationTrait.php | 10 ++++++---- .../Extractor/Declaration/ClassnameExtractor.php | 10 ++++++++-- src/Test/Builder/AssertionStep.php | 2 +- tests/architecture/ConfigurationTest.php | 9 +++++++++ tests/unit/rules/ShouldBeNamed/ClassnameTest.php | 13 ++++++++----- 14 files changed, 60 insertions(+), 35 deletions(-) diff --git a/src/Rule/Assertion/Declaration/DeclarationAssertion.php b/src/Rule/Assertion/Declaration/DeclarationAssertion.php index 385ef0ae..94e90a77 100644 --- a/src/Rule/Assertion/Declaration/DeclarationAssertion.php +++ b/src/Rule/Assertion/Declaration/DeclarationAssertion.php @@ -47,11 +47,17 @@ public function processNode(Node $node, Scope $scope): array return []; } - $meetsDeclaration = $this->meetsDeclaration($node, $scope); + $meetsDeclaration = $this->meetsDeclaration($node, $scope, $this->getParams()); return $this->validateGetErrors($scope, $meetsDeclaration); } + // TODO: This is a temporary hack, the 'statement' concept needs to be reworked + public function getParams(): array + { + return $this->statements[0][4] ?? []; + } + public function prepareMessage(string $ruleName, string $message): string { return $this->configuration->showRuleNames() @@ -70,7 +76,7 @@ abstract protected function getMessage(string $ruleName, string $subject, array * @param array $tips * @return array */ - abstract protected function applyValidation(string $ruleName, ClassReflection $subject, bool $meetsDeclaration, array $tips): array; + abstract protected function applyValidation(string $ruleName, ClassReflection $subject, bool $meetsDeclaration, array $tips, array $params = []): array; protected function ruleApplies(Scope $scope): bool { @@ -93,7 +99,7 @@ protected function validateGetErrors(Scope $scope, bool $meetsDeclaration): arra throw new ShouldNotHappenException(); } - foreach ($this->statements as [$ruleName, $selector, $subjectExcludes, $tips]) { + foreach ($this->statements as [$ruleName, $selector, $subjectExcludes, $tips, $params]) { if ($subject->isBuiltin() || !$selector->matches($subject)) { continue; } @@ -103,7 +109,7 @@ protected function validateGetErrors(Scope $scope, bool $meetsDeclaration): arra } } - array_push($errors, ...$this->applyValidation($ruleName, $subject, $meetsDeclaration, $tips)); + array_push($errors, ...$this->applyValidation($ruleName, $subject, $meetsDeclaration, $tips, $params)); } return $errors; diff --git a/src/Rule/Assertion/Declaration/ShouldBeAbstract/ShouldBeAbstract.php b/src/Rule/Assertion/Declaration/ShouldBeAbstract/ShouldBeAbstract.php index eb8975cd..7a41cc5e 100644 --- a/src/Rule/Assertion/Declaration/ShouldBeAbstract/ShouldBeAbstract.php +++ b/src/Rule/Assertion/Declaration/ShouldBeAbstract/ShouldBeAbstract.php @@ -29,9 +29,9 @@ public function __construct( ); } - protected function applyValidation(string $ruleName, ClassReflection $subject, bool $meetsDeclaration, array $tips): array + protected function applyValidation(string $ruleName, ClassReflection $subject, bool $meetsDeclaration, array $tips, array $params = []): array { - return $this->applyShould($ruleName, $subject, $meetsDeclaration, $tips); + return $this->applyShould($ruleName, $subject, $meetsDeclaration, $tips, $params); } protected function getMessage(string $ruleName, string $subject, array $params = []): string diff --git a/src/Rule/Assertion/Declaration/ShouldBeFinal/ShouldBeFinal.php b/src/Rule/Assertion/Declaration/ShouldBeFinal/ShouldBeFinal.php index e56fe42b..1aaa44e9 100644 --- a/src/Rule/Assertion/Declaration/ShouldBeFinal/ShouldBeFinal.php +++ b/src/Rule/Assertion/Declaration/ShouldBeFinal/ShouldBeFinal.php @@ -34,9 +34,9 @@ public function __construct( * @param array $tips * @return array */ - protected function applyValidation(string $ruleName, ClassReflection $subject, bool $meetsDeclaration, array $tips): array + protected function applyValidation(string $ruleName, ClassReflection $subject, bool $meetsDeclaration, array $tips, array $params = []): array { - return $this->applyShould($ruleName, $subject, $meetsDeclaration, $tips); + return $this->applyShould($ruleName, $subject, $meetsDeclaration, $tips, $params); } protected function getMessage(string $ruleName, string $subject, array $params = []): string diff --git a/src/Rule/Assertion/Declaration/ShouldBeNamed/ClassnameRule.php b/src/Rule/Assertion/Declaration/ShouldBeNamed/ClassnameRule.php index b0df7136..a62591d5 100644 --- a/src/Rule/Assertion/Declaration/ShouldBeNamed/ClassnameRule.php +++ b/src/Rule/Assertion/Declaration/ShouldBeNamed/ClassnameRule.php @@ -2,8 +2,6 @@ namespace PHPat\Rule\Assertion\Declaration\ShouldBeNamed; -use PHPat\Rule\Assertion\Declaration\ShouldBeAbstract\ShouldBeAbstract; -use PHPat\Rule\Extractor\Declaration\AbstractExtractor; use PHPat\Rule\Extractor\Declaration\ClassnameExtractor; use PHPStan\Node\InClassNode; use PHPStan\Rules\Rule; @@ -11,7 +9,7 @@ /** * @implements Rule */ -final class ClassnameRule extends ShouldBeAbstract implements Rule +final class ClassnameRule extends ShouldBeNamed implements Rule { use ClassnameExtractor; } diff --git a/src/Rule/Assertion/Declaration/ShouldBeNamed/ShouldBeNamed.php b/src/Rule/Assertion/Declaration/ShouldBeNamed/ShouldBeNamed.php index 9253898a..a5d80928 100644 --- a/src/Rule/Assertion/Declaration/ShouldBeNamed/ShouldBeNamed.php +++ b/src/Rule/Assertion/Declaration/ShouldBeNamed/ShouldBeNamed.php @@ -5,6 +5,7 @@ use PHPat\Configuration; use PHPat\Rule\Assertion\Declaration\DeclarationAssertion; use PHPat\Rule\Assertion\Declaration\ValidationTrait; +use PHPat\ShouldNotHappenException; use PHPat\Statement\Builder\StatementBuilderFactory; use PHPStan\Reflection\ClassReflection; use PHPStan\Reflection\ReflectionProvider; @@ -29,16 +30,16 @@ public function __construct( ); } - protected function applyValidation(string $ruleName, ClassReflection $subject, bool $meetsDeclaration, array $tips): array + protected function applyValidation(string $ruleName, ClassReflection $subject, bool $meetsDeclaration, array $tips, array $params = []): array { - return $this->applyShould($ruleName, $subject, $meetsDeclaration, $tips); + return $this->applyShould($ruleName, $subject, $meetsDeclaration, $tips, $params); } protected function getMessage(string $ruleName, string $subject, array $params = []): string { $message = $params['isRegex'] === true - ? sprintf('%s should be named matching the regex "%s', $subject, $params['classname']) - : sprintf('%s should be named "%s"', $subject, $params['classname']); + ? sprintf('%s should be named matching the regex %s', $subject, $params['classname']) + : sprintf('%s should be named %s', $subject, $params['classname']); return $this->prepareMessage($ruleName, $message); } diff --git a/src/Rule/Assertion/Declaration/ShouldBeReadonly/ShouldBeReadonly.php b/src/Rule/Assertion/Declaration/ShouldBeReadonly/ShouldBeReadonly.php index d9ddffed..a786f07f 100644 --- a/src/Rule/Assertion/Declaration/ShouldBeReadonly/ShouldBeReadonly.php +++ b/src/Rule/Assertion/Declaration/ShouldBeReadonly/ShouldBeReadonly.php @@ -34,9 +34,9 @@ public function __construct( * @param array $tips * @return array */ - protected function applyValidation(string $ruleName, ClassReflection $subject, bool $meetsDeclaration, array $tips): array + protected function applyValidation(string $ruleName, ClassReflection $subject, bool $meetsDeclaration, array $tips, array $params = []): array { - return $this->applyShould($ruleName, $subject, $meetsDeclaration, $tips); + return $this->applyShould($ruleName, $subject, $meetsDeclaration, $tips, $params); } protected function getMessage(string $ruleName, string $subject, array $params = []): string diff --git a/src/Rule/Assertion/Declaration/ShouldHaveOnlyOnePublicMethod/ShouldHaveOnlyOnePublicMethod.php b/src/Rule/Assertion/Declaration/ShouldHaveOnlyOnePublicMethod/ShouldHaveOnlyOnePublicMethod.php index 5b42b86c..cd705a1b 100644 --- a/src/Rule/Assertion/Declaration/ShouldHaveOnlyOnePublicMethod/ShouldHaveOnlyOnePublicMethod.php +++ b/src/Rule/Assertion/Declaration/ShouldHaveOnlyOnePublicMethod/ShouldHaveOnlyOnePublicMethod.php @@ -29,9 +29,9 @@ public function __construct( ); } - protected function applyValidation(string $ruleName, ClassReflection $subject, bool $meetsDeclaration, array $tips): array + protected function applyValidation(string $ruleName, ClassReflection $subject, bool $meetsDeclaration, array $tips, array $params = []): array { - return $this->applyShould($ruleName, $subject, $meetsDeclaration, $tips); + return $this->applyShould($ruleName, $subject, $meetsDeclaration, $tips, $params); } protected function getMessage(string $ruleName, string $subject, array $params = []): string diff --git a/src/Rule/Assertion/Declaration/ShouldNotBeAbstract/ShouldNotBeAbstract.php b/src/Rule/Assertion/Declaration/ShouldNotBeAbstract/ShouldNotBeAbstract.php index 3d9984ce..aa1b9370 100644 --- a/src/Rule/Assertion/Declaration/ShouldNotBeAbstract/ShouldNotBeAbstract.php +++ b/src/Rule/Assertion/Declaration/ShouldNotBeAbstract/ShouldNotBeAbstract.php @@ -29,9 +29,9 @@ public function __construct( ); } - protected function applyValidation(string $ruleName, ClassReflection $subject, bool $meetsDeclaration, array $tips): array + protected function applyValidation(string $ruleName, ClassReflection $subject, bool $meetsDeclaration, array $tips, array $params = []): array { - return $this->applyShouldNot($ruleName, $subject, $meetsDeclaration, $tips); + return $this->applyShouldNot($ruleName, $subject, $meetsDeclaration, $tips, $params); } protected function getMessage(string $ruleName, string $subject, array $params = []): string diff --git a/src/Rule/Assertion/Declaration/ShouldNotBeFinal/ShouldNotBeFinal.php b/src/Rule/Assertion/Declaration/ShouldNotBeFinal/ShouldNotBeFinal.php index 6cf7f0d5..130d6c4b 100644 --- a/src/Rule/Assertion/Declaration/ShouldNotBeFinal/ShouldNotBeFinal.php +++ b/src/Rule/Assertion/Declaration/ShouldNotBeFinal/ShouldNotBeFinal.php @@ -29,9 +29,9 @@ public function __construct( ); } - protected function applyValidation(string $ruleName, ClassReflection $subject, bool $meetsDeclaration, array $tips): array + protected function applyValidation(string $ruleName, ClassReflection $subject, bool $meetsDeclaration, array $tips, array $params = []): array { - return $this->applyShouldNot($ruleName, $subject, $meetsDeclaration, $tips); + return $this->applyShouldNot($ruleName, $subject, $meetsDeclaration, $tips, $params); } protected function getMessage(string $ruleName, string $subject, array $params = []): string diff --git a/src/Rule/Assertion/Declaration/ValidationTrait.php b/src/Rule/Assertion/Declaration/ValidationTrait.php index ffc852b5..870b255f 100644 --- a/src/Rule/Assertion/Declaration/ValidationTrait.php +++ b/src/Rule/Assertion/Declaration/ValidationTrait.php @@ -12,16 +12,17 @@ trait ValidationTrait { /** * @param array $tips + * @param array $params * @return array * @throws ShouldNotHappenException */ - protected function applyShould(string $ruleName, ClassReflection $subject, bool $meetsDeclaration, array $tips): array + protected function applyShould(string $ruleName, ClassReflection $subject, bool $meetsDeclaration, array $tips, array $params): array { $errors = []; if (!$meetsDeclaration) { $ruleError = RuleErrorBuilder::message( - $this->getMessage($ruleName, $subject->getName()) + $this->getMessage($ruleName, $subject->getName(), $params) ); foreach ($tips as $tip) { @@ -35,16 +36,17 @@ protected function applyShould(string $ruleName, ClassReflection $subject, bool /** * @param array $tips + * @param array $params * @return array * @throws ShouldNotHappenException */ - protected function applyShouldNot(string $ruleName, ClassReflection $subject, bool $meetsDeclaration, array $tips): array + protected function applyShouldNot(string $ruleName, ClassReflection $subject, bool $meetsDeclaration, array $tips, array $params): array { $errors = []; if ($meetsDeclaration) { $ruleError = RuleErrorBuilder::message( - $this->getMessage($ruleName, $subject->getName()) + $this->getMessage($ruleName, $subject->getName(), $params) ); foreach ($tips as $tip) { diff --git a/src/Rule/Extractor/Declaration/ClassnameExtractor.php b/src/Rule/Extractor/Declaration/ClassnameExtractor.php index de6aeb8c..0d7f5139 100644 --- a/src/Rule/Extractor/Declaration/ClassnameExtractor.php +++ b/src/Rule/Extractor/Declaration/ClassnameExtractor.php @@ -2,6 +2,7 @@ namespace PHPat\Rule\Extractor\Declaration; +use PHPat\ShouldNotHappenException; use PhpParser\Node; use PHPStan\Analyser\Scope; use PHPStan\Node\InClassNode; @@ -18,10 +19,15 @@ public function getNodeType(): string */ protected function meetsDeclaration(Node $node, Scope $scope, array $params = []): bool { + $pos = strrpos($node->getClassReflection()->getName(), '\\'); + $classname = $pos === false + ? $node->getClassReflection()->getName() + : substr($node->getClassReflection()->getName(), $pos + 1); + if ($params['isRegex'] === true) { - return preg_match($params['classname'], $node->getClassReflection()->getName()) === 1; + return preg_match($params['classname'], $classname) === 1; } - return $node->getClassReflection()->getName() === $params['classname']; + return $classname === $params['classname']; } } diff --git a/src/Test/Builder/AssertionStep.php b/src/Test/Builder/AssertionStep.php index e629ebb6..b7c44e36 100644 --- a/src/Test/Builder/AssertionStep.php +++ b/src/Test/Builder/AssertionStep.php @@ -20,7 +20,7 @@ class AssertionStep extends AbstractStep { - public function shouldBeNamed(string $classname, bool $regex): Rule + public function shouldBeNamed(string $classname, bool $regex = false): Rule { $this->rule->assertion = ShouldBeNamed::class; $this->rule->params = ['isRegex' => $regex, 'classname' => $classname]; diff --git a/tests/architecture/ConfigurationTest.php b/tests/architecture/ConfigurationTest.php index 352d0a0b..39e57b62 100644 --- a/tests/architecture/ConfigurationTest.php +++ b/tests/architecture/ConfigurationTest.php @@ -28,4 +28,13 @@ public function configuration_is_final(): Rule ->shouldBeFinal() ; } + + #[TestRule] + public function configuration_is_called_configuration(): Rule + { + return PHPat::rule() + ->classes(Selector::classname(Configuration::class)) + ->shouldBeNamed('/tio$/', true) + ; + } } diff --git a/tests/unit/rules/ShouldBeNamed/ClassnameTest.php b/tests/unit/rules/ShouldBeNamed/ClassnameTest.php index 49d88c60..1bc8f2c1 100644 --- a/tests/unit/rules/ShouldBeNamed/ClassnameTest.php +++ b/tests/unit/rules/ShouldBeNamed/ClassnameTest.php @@ -5,6 +5,8 @@ use PHPat\Configuration; use PHPat\Rule\Assertion\Declaration\ShouldBeAbstract\AbstractRule; use PHPat\Rule\Assertion\Declaration\ShouldBeAbstract\ShouldBeAbstract; +use PHPat\Rule\Assertion\Declaration\ShouldBeNamed\ClassnameRule; +use PHPat\Rule\Assertion\Declaration\ShouldBeNamed\ShouldBeNamed; use PHPat\Selector\Classname; use PHPat\Statement\Builder\StatementBuilderFactory; use PHPStan\Rules\Rule; @@ -14,7 +16,7 @@ use Tests\PHPat\unit\FakeTestParser; /** - * @extends RuleTestCase + * @extends RuleTestCase * @internal * @coversNothing */ @@ -25,7 +27,7 @@ class ClassnameTest extends RuleTestCase public function testRule(): void { $this->analyse(['tests/fixtures/FixtureClass.php'], [ - [sprintf('%s should be named NotTheFixtureClassClassname', FixtureClass::class), 29], + [sprintf('%s should be named SuperCoolClass', FixtureClass::class), 29], ]); } @@ -33,13 +35,14 @@ protected function getRule(): Rule { $testParser = FakeTestParser::create( self::RULE_NAME, - ShouldBeAbstract::class, + ShouldBeNamed::class, [new Classname(FixtureClass::class, false)], [], - ['isRegex' => false, 'classname' => 'NotTheFixtureClassClassname'] + [], + ['isRegex' => false, 'classname' => 'SuperCoolClass'] ); - return new AbstractRule( + return new ClassnameRule( new StatementBuilderFactory($testParser), new Configuration(false, true, false), $this->createReflectionProvider(), From 939f1bf88802ccfe6fa6dbad01663639a67f2d1d Mon Sep 17 00:00:00 2001 From: Carlos Alandete Sastre Date: Sat, 23 Dec 2023 23:30:29 +0100 Subject: [PATCH 4/9] wip is named --- tests/unit/tips/Relation/MultipleTipTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/tips/Relation/MultipleTipTest.php b/tests/unit/tips/Relation/MultipleTipTest.php index fcf687d3..600b95ea 100644 --- a/tests/unit/tips/Relation/MultipleTipTest.php +++ b/tests/unit/tips/Relation/MultipleTipTest.php @@ -30,8 +30,8 @@ public function testRule(): void \sprintf('%s should not depend on %s', FixtureClass::class, SimpleAttribute::class), 29, <<<'TIPS' - • #tip 1 - • #tip 2 + • tip #1 + • tip #2 TIPS, ], ]); @@ -44,7 +44,7 @@ protected function getRule(): Rule CanOnlyDepend::class, [new Classname(FixtureClass::class, false)], [new Classname(\Attribute::class, false)], - ['#tip 1', '#tip 2'] + ['tip #1', 'tip #2'] ); return new ClassAttributeRule( From 0eb3c0769e913935054561e73856bc0001841964 Mon Sep 17 00:00:00 2001 From: Carlos Alandete Sastre Date: Sat, 23 Dec 2023 23:50:26 +0100 Subject: [PATCH 5/9] wip is named --- ci/phpstan.neon | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ci/phpstan.neon b/ci/phpstan.neon index ca63e370..b174785c 100644 --- a/ci/phpstan.neon +++ b/ci/phpstan.neon @@ -3,3 +3,7 @@ parameters: paths: - ../src - ../tests/unit/rules + ignoreErrors: + - + message: "#no value type specified in iterable type array\\.$#" + path: * From 45cc735abcab36d16539e681169b353ae1041da1 Mon Sep 17 00:00:00 2001 From: Carlos A Sastre Date: Sat, 23 Dec 2023 23:55:49 +0100 Subject: [PATCH 6/9] cs --- .../Assertion/Declaration/ShouldBeNamed/ShouldBeNamed.php | 1 - src/Rule/Assertion/Declaration/ValidationTrait.php | 2 +- src/Rule/Extractor/Declaration/ClassnameExtractor.php | 5 ++--- src/Statement/Builder/DeclarationStatementBuilder.php | 2 +- tests/unit/rules/ShouldBeNamed/ClassnameTest.php | 2 -- 5 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Rule/Assertion/Declaration/ShouldBeNamed/ShouldBeNamed.php b/src/Rule/Assertion/Declaration/ShouldBeNamed/ShouldBeNamed.php index a5d80928..d15c7dd5 100644 --- a/src/Rule/Assertion/Declaration/ShouldBeNamed/ShouldBeNamed.php +++ b/src/Rule/Assertion/Declaration/ShouldBeNamed/ShouldBeNamed.php @@ -5,7 +5,6 @@ use PHPat\Configuration; use PHPat\Rule\Assertion\Declaration\DeclarationAssertion; use PHPat\Rule\Assertion\Declaration\ValidationTrait; -use PHPat\ShouldNotHappenException; use PHPat\Statement\Builder\StatementBuilderFactory; use PHPStan\Reflection\ClassReflection; use PHPStan\Reflection\ReflectionProvider; diff --git a/src/Rule/Assertion/Declaration/ValidationTrait.php b/src/Rule/Assertion/Declaration/ValidationTrait.php index 870b255f..afef0cdb 100644 --- a/src/Rule/Assertion/Declaration/ValidationTrait.php +++ b/src/Rule/Assertion/Declaration/ValidationTrait.php @@ -36,7 +36,7 @@ protected function applyShould(string $ruleName, ClassReflection $subject, bool /** * @param array $tips - * @param array $params + * @param array $params * @return array * @throws ShouldNotHappenException */ diff --git a/src/Rule/Extractor/Declaration/ClassnameExtractor.php b/src/Rule/Extractor/Declaration/ClassnameExtractor.php index 0d7f5139..6acd61c7 100644 --- a/src/Rule/Extractor/Declaration/ClassnameExtractor.php +++ b/src/Rule/Extractor/Declaration/ClassnameExtractor.php @@ -2,7 +2,6 @@ namespace PHPat\Rule\Extractor\Declaration; -use PHPat\ShouldNotHappenException; use PhpParser\Node; use PHPStan\Analyser\Scope; use PHPStan\Node\InClassNode; @@ -19,10 +18,10 @@ public function getNodeType(): string */ protected function meetsDeclaration(Node $node, Scope $scope, array $params = []): bool { - $pos = strrpos($node->getClassReflection()->getName(), '\\'); + $pos = mb_strrpos($node->getClassReflection()->getName(), '\\'); $classname = $pos === false ? $node->getClassReflection()->getName() - : substr($node->getClassReflection()->getName(), $pos + 1); + : mb_substr($node->getClassReflection()->getName(), $pos + 1); if ($params['isRegex'] === true) { return preg_match($params['classname'], $classname) === 1; diff --git a/src/Statement/Builder/DeclarationStatementBuilder.php b/src/Statement/Builder/DeclarationStatementBuilder.php index 30d9de37..d8c2982b 100644 --- a/src/Statement/Builder/DeclarationStatementBuilder.php +++ b/src/Statement/Builder/DeclarationStatementBuilder.php @@ -59,7 +59,7 @@ private function addStatement( } /** - * @param array $rules + * @param array $rules * @return array, array, array}> */ private function extractCurrentAssertion(array $rules): array diff --git a/tests/unit/rules/ShouldBeNamed/ClassnameTest.php b/tests/unit/rules/ShouldBeNamed/ClassnameTest.php index 1bc8f2c1..24a04378 100644 --- a/tests/unit/rules/ShouldBeNamed/ClassnameTest.php +++ b/tests/unit/rules/ShouldBeNamed/ClassnameTest.php @@ -3,8 +3,6 @@ namespace Tests\PHPat\unit\rules\ShouldBeNamed; use PHPat\Configuration; -use PHPat\Rule\Assertion\Declaration\ShouldBeAbstract\AbstractRule; -use PHPat\Rule\Assertion\Declaration\ShouldBeAbstract\ShouldBeAbstract; use PHPat\Rule\Assertion\Declaration\ShouldBeNamed\ClassnameRule; use PHPat\Rule\Assertion\Declaration\ShouldBeNamed\ShouldBeNamed; use PHPat\Selector\Classname; From 0859d059dab2ceca8cbbf8dba48c9ca9d3841c65 Mon Sep 17 00:00:00 2001 From: Carlos Alandete Sastre Date: Sat, 23 Dec 2023 23:58:29 +0100 Subject: [PATCH 7/9] wip is named --- tests/architecture/ConfigurationTest.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tests/architecture/ConfigurationTest.php b/tests/architecture/ConfigurationTest.php index 39e57b62..352d0a0b 100644 --- a/tests/architecture/ConfigurationTest.php +++ b/tests/architecture/ConfigurationTest.php @@ -28,13 +28,4 @@ public function configuration_is_final(): Rule ->shouldBeFinal() ; } - - #[TestRule] - public function configuration_is_called_configuration(): Rule - { - return PHPat::rule() - ->classes(Selector::classname(Configuration::class)) - ->shouldBeNamed('/tio$/', true) - ; - } } From 066e7ed251072f7c86b4367e8e810f59e97e8dd9 Mon Sep 17 00:00:00 2001 From: Carlos Alandete Sastre Date: Sun, 24 Dec 2023 00:04:00 +0100 Subject: [PATCH 8/9] fix --- .../Declaration/ShouldBeInterface/ShouldBeInterface.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Rule/Assertion/Declaration/ShouldBeInterface/ShouldBeInterface.php b/src/Rule/Assertion/Declaration/ShouldBeInterface/ShouldBeInterface.php index 9782aca3..19456541 100644 --- a/src/Rule/Assertion/Declaration/ShouldBeInterface/ShouldBeInterface.php +++ b/src/Rule/Assertion/Declaration/ShouldBeInterface/ShouldBeInterface.php @@ -34,12 +34,12 @@ public function __construct( * @param array $tips * @return array */ - protected function applyValidation(string $ruleName, ClassReflection $subject, bool $meetsDeclaration, array $tips): array + protected function applyValidation(string $ruleName, ClassReflection $subject, bool $meetsDeclaration, array $tips, array $params = []): array { - return $this->applyShould($ruleName, $subject, $meetsDeclaration, $tips); + return $this->applyShould($ruleName, $subject, $meetsDeclaration, $tips, $params); } - protected function getMessage(string $ruleName, string $subject): string + protected function getMessage(string $ruleName, string $subject, array $params = []): string { return $this->prepareMessage( $ruleName, From a19225d1caf046f221ed4d681b9cc5a4bc653c14 Mon Sep 17 00:00:00 2001 From: Carlos Alandete Sastre Date: Sun, 24 Dec 2023 00:05:47 +0100 Subject: [PATCH 9/9] fix --- src/Rule/Extractor/Declaration/InterfaceExtractor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Rule/Extractor/Declaration/InterfaceExtractor.php b/src/Rule/Extractor/Declaration/InterfaceExtractor.php index c46c3a5a..883aec3b 100644 --- a/src/Rule/Extractor/Declaration/InterfaceExtractor.php +++ b/src/Rule/Extractor/Declaration/InterfaceExtractor.php @@ -16,7 +16,7 @@ public function getNodeType(): string /** * @param InClassNode $node */ - protected function meetsDeclaration(Node $node, Scope $scope): bool + protected function meetsDeclaration(Node $node, Scope $scope, array $params = []): bool { return $node->getClassReflection()->isInterface(); }