diff --git a/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php index 7f561aa4e..de2867467 100644 --- a/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php @@ -335,7 +335,7 @@ abstract class ClassLikeAnalyzer extends SourceAnalyzer $classUnion = new Union([new TNamedObject($fq_class_name)]); - foreach ($class_storage->parent_classes as $parent_class) { + foreach ($class_storage->parent_classes + $class_storage->direct_class_interfaces as $parent_class) { $parent_storage = $codebase->classlikes->getStorageFor($parent_class); if ($parent_storage && $parent_storage->inheritors) { if (!UnionTypeComparator::isContainedBy($codebase, $classUnion, $parent_storage->inheritors)) { diff --git a/tests/ClassTest.php b/tests/ClassTest.php index 9504ef226..4a8d7f77d 100644 --- a/tests/ClassTest.php +++ b/tests/ClassTest.php @@ -909,6 +909,34 @@ class ClassTest extends TestCase $b = new BarClass(); PHP, ], + 'InterfaceInheritorIsAllowed' => [ + 'code' => <<<'PHP' + [ + 'code' => <<<'PHP' + 'InvalidExtendClass', 'ignored_issues' => [], ], + 'classCannotImplementIfNotInInheritors' => [ + 'code' => <<<'PHP' + 'InvalidExtendClass', + 'ignored_issues' => [], + ], + 'UnfulfilledInterfaceInheritors' => [ + 'code' => <<<'PHP' + 'InvalidExtendClass', + 'ignored_issues' => [], + ], ]; } }