Skip to content

Commit c4948fe

Browse files
committed
Fixed behavior
1 parent 3d1d93e commit c4948fe

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

src/Rules/Classes/InstantiationRule.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616
use PHPStan\Rules\Rule;
1717
use PHPStan\Rules\RuleErrorBuilder;
1818
use PHPStan\ShouldNotHappenException;
19-
use PHPStan\Type\CompoundType;
2019
use PHPStan\Type\Constant\ConstantStringType;
21-
use PHPStan\Type\Generic\TemplateGenericObjectType;
22-
use PHPStan\Type\StaticType;
2320
use PHPStan\Type\VerbosityLevel;
21+
use function array_filter;
2422
use function array_map;
2523
use function array_merge;
2624
use function count;
@@ -253,16 +251,13 @@ private function getClassNames(Node $node, Scope $scope): array
253251
if (str_starts_with($type->describe(VerbosityLevel::precise()), 'class-string')) {
254252
$classStringObjectType = $type->getClassStringObjectType();
255253

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+
);
266261
}
267262

268263
return array_merge(

0 commit comments

Comments
 (0)