Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/Collector/ImplementedInterfaceCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace Symplify\PHPStanRules\Tests\Rules\NoSingleInterfaceImplementerRule\Fixture;

abstract class AllowAbstract implements SimpleInterface
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function testRule(array $filePaths, array $expectedErrorMessagesWithLines
public static function provideData(): Iterator
{
yield [[__DIR__ . '/Fixture/SimpleInterface.php'], []];
yield [[__DIR__ . '/Fixture/AllowAbstract.php', __DIR__ . '/Fixture/SimpleInterface.php'], []];

yield [
[
Expand Down