diff --git a/src/Collector/ImplementedInterfaceCollector.php b/src/Collector/ImplementedInterfaceCollector.php index 5b97a12e..21bfe0f0 100644 --- a/src/Collector/ImplementedInterfaceCollector.php +++ b/src/Collector/ImplementedInterfaceCollector.php @@ -18,12 +18,17 @@ public function getNodeType(): string /** * @param Class_ $node - * @return string[] + * @return string[]|null */ - public function processNode(Node $node, Scope $scope): array + public function processNode(Node $node, Scope $scope): ?array { $implementedInterfaceNames = []; + // skip abstract classes, as they can enforce child implementations + if ($node->isAbstract()) { + return null; + } + foreach ($node->implements as $implement) { $implementedInterfaceNames[] = $implement->toString(); } diff --git a/tests/Rules/NoSingleInterfaceImplementerRule/Fixture/AllowAbstract.php b/tests/Rules/NoSingleInterfaceImplementerRule/Fixture/AllowAbstract.php new file mode 100644 index 00000000..a67c3395 --- /dev/null +++ b/tests/Rules/NoSingleInterfaceImplementerRule/Fixture/AllowAbstract.php @@ -0,0 +1,9 @@ +