Skip to content

Commit 3cdcac9

Browse files
Fix ObjectType::equals
1 parent d85f2ab commit 3cdcac9

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

phpstan-baseline.neon

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,12 +1473,6 @@ parameters:
14731473
count: 1
14741474
path: src/Type/ObjectShapeType.php
14751475

1476-
-
1477-
rawMessage: 'Doing instanceof PHPStan\Type\Enum\EnumCaseObjectType is error-prone and deprecated. Use Type::getEnumCases() instead.'
1478-
identifier: phpstanApi.instanceofType
1479-
count: 1
1480-
path: src/Type/ObjectType.php
1481-
14821476
-
14831477
rawMessage: Doing instanceof PHPStan\Type\Generic\GenericObjectType is error-prone and deprecated.
14841478
identifier: phpstanApi.instanceofType
@@ -1488,7 +1482,7 @@ parameters:
14881482
-
14891483
rawMessage: 'Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.'
14901484
identifier: phpstanApi.instanceofType
1491-
count: 3
1485+
count: 2
14921486
path: src/Type/ObjectType.php
14931487

14941488
-

src/Type/ObjectType.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
use function array_map;
5757
use function array_values;
5858
use function count;
59+
use function get_class;
5960
use function implode;
6061
use function in_array;
6162
use function sprintf;
@@ -624,11 +625,7 @@ public function isSuperTypeOf(Type $type): IsSuperTypeOfResult
624625

625626
public function equals(Type $type): bool
626627
{
627-
if (!$type instanceof self) {
628-
return false;
629-
}
630-
631-
if ($type instanceof EnumCaseObjectType) {
628+
if (get_class($type) !== static::class) {
632629
return false;
633630
}
634631

tests/PHPStan/Rules/PhpDoc/WrongVariableNameInVarTagRuleTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,10 @@ public function testGenericSubtype(): void
591591
$this->checkTypeAgainstPhpDocType = true;
592592
$this->strictWideningCheck = true;
593593
$this->analyse([__DIR__ . '/data/generic-subtype.php'], [
594+
[
595+
'PHPDoc tag @var with type GenericSubtype\IRepository<E of GenericSubtype\IEntity> is not subtype of type GenericSubtype\IRepository<GenericSubtype\IEntity>.',
596+
78,
597+
],
594598
[
595599
'PHPDoc tag @var with type GenericSubtype\IRepository<GenericSubtype\Foo> is not subtype of type GenericSubtype\IRepository<GenericSubtype\IEntity>.',
596600
131,

0 commit comments

Comments
 (0)