|
16 | 16 | use PHPStan\Rules\Rule; |
17 | 17 | use PHPStan\Rules\RuleErrorBuilder; |
18 | 18 | use PHPStan\ShouldNotHappenException; |
19 | | -use PHPStan\Type\CompoundType; |
20 | 19 | use PHPStan\Type\Constant\ConstantStringType; |
21 | | -use PHPStan\Type\Generic\TemplateGenericObjectType; |
22 | | -use PHPStan\Type\StaticType; |
23 | 20 | use PHPStan\Type\VerbosityLevel; |
| 21 | +use function array_filter; |
24 | 22 | use function array_map; |
25 | 23 | use function array_merge; |
26 | 24 | use function count; |
@@ -253,16 +251,13 @@ private function getClassNames(Node $node, Scope $scope): array |
253 | 251 | if (str_starts_with($type->describe(VerbosityLevel::precise()), 'class-string')) { |
254 | 252 | $classStringObjectType = $type->getClassStringObjectType(); |
255 | 253 |
|
256 | | - if ( |
257 | | - !$classStringObjectType instanceof StaticType |
258 | | - && !$classStringObjectType instanceof CompoundType |
259 | | - && !$classStringObjectType instanceof TemplateGenericObjectType |
260 | | - ) { |
261 | | - return array_map( |
262 | | - static fn (string $name): array => [$name, true], |
263 | | - $classStringObjectType->getObjectClassNames(), |
264 | | - ); |
265 | | - } |
| 254 | + return array_map( |
| 255 | + static fn (string $name): array => [$name, true], |
| 256 | + array_filter($classStringObjectType->getObjectClassNames(), function (string $name): bool { |
| 257 | + $reflectionClass = $this->reflectionProvider->getClass($name); |
| 258 | + return !$reflectionClass->isAbstract() && !$reflectionClass->isInterface(); |
| 259 | + }), |
| 260 | + ); |
266 | 261 | } |
267 | 262 |
|
268 | 263 | return array_merge( |
|
0 commit comments