Skip to content

Commit 820fe14

Browse files
Fix ObjectType::equals
1 parent d85f2ab commit 820fe14

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-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: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -624,11 +624,7 @@ public function isSuperTypeOf(Type $type): IsSuperTypeOfResult
624624

625625
public function equals(Type $type): bool
626626
{
627-
if (!$type instanceof self) {
628-
return false;
629-
}
630-
631-
if ($type instanceof EnumCaseObjectType) {
627+
if (get_class($this) !== get_class($type)) {
632628
return false;
633629
}
634630

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)