diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index a887358f52..a07ea29556 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1383,7 +1383,7 @@ parameters: - message: '#^Doing instanceof PHPStan\\Type\\IterableType is error\-prone and deprecated\. Use Type\:\:isIterable\(\) instead\.$#' identifier: phpstanApi.instanceofType - count: 2 + count: 1 path: src/Type/IterableType.php - diff --git a/src/Type/IterableType.php b/src/Type/IterableType.php index 2e6d26a381..2242c477a5 100644 --- a/src/Type/IterableType.php +++ b/src/Type/IterableType.php @@ -20,6 +20,7 @@ use PHPStan\Type\Traits\UndecidedComparisonCompoundTypeTrait; use Traversable; use function array_merge; +use function get_class; use function sprintf; /** @api */ @@ -167,7 +168,7 @@ public function isAcceptedBy(Type $acceptingType, bool $strictTypes): AcceptsRes public function equals(Type $type): bool { - if (!$type instanceof self) { + if (get_class($type) !== static::class) { return false; } diff --git a/tests/PHPStan/Generics/TemplateTypeFactoryTest.php b/tests/PHPStan/Generics/TemplateTypeFactoryTest.php index 16fe1d24df..58af77cd3b 100644 --- a/tests/PHPStan/Generics/TemplateTypeFactoryTest.php +++ b/tests/PHPStan/Generics/TemplateTypeFactoryTest.php @@ -8,6 +8,7 @@ use PHPStan\Type\Generic\TemplateTypeScope; use PHPStan\Type\Generic\TemplateTypeVariance; use PHPStan\Type\IntegerType; +use PHPStan\Type\IterableType; use PHPStan\Type\MixedType; use PHPStan\Type\ObjectType; use PHPStan\Type\StringType; @@ -66,6 +67,10 @@ public function dataCreate(): array new IntegerType(), ]), ], + [ + new IterableType(new IntegerType(), new StringType()), + new IterableType(new IntegerType(), new StringType()), + ], ]; }