Hi @TomasVotruba @samsonasik,
I'm currently working on a Fix in phpstan-src on ObjectType::equals (phpstan/phpstan-src#5399)
- ObjectType->equals(GenericObjectType) was true (which is not correct)
- ObjectType->equals(TemplateObjectType) was true (which is worst since TemplateObjectType->equals(ObjectType) was false.
But, with our integration tests it shows that this fix will break
I got confirmation from ondrej that my fix was correct and your implementation had some issues (phpstan/phpstan-src#5399 (comment))
After some investigations, it seems like this is because you rely a lot on Type::equals, for instance here:
https://github.com/rectorphp/rector-downgrade-php/blob/15578226e7d293f224a121dabaa11d8f6e7ab42a/rules/DowngradePhp74/Rector/ClassMethod/DowngradeCovariantReturnTypeRector.php#L239
This had the benefit BEFORE to return true when you compares a FullyQualifiedObjectType (
|
final class FullyQualifiedObjectType extends ObjectType |
) which the ObjectType of the same class. But as soon as the ObjectType::equals will be fixed it will returns false.
I'm not fully sure how to change your implementation, some ideas...
- Using
describe method
- Using
toPhpDocNode
- Using
$child->isSuperTypeOf($parent)
- Overriding
equals method in your custom ObjectType class
Hi @TomasVotruba @samsonasik,
I'm currently working on a Fix in phpstan-src on ObjectType::equals (phpstan/phpstan-src#5399)
But, with our integration tests it shows that this fix will break
I got confirmation from ondrej that my fix was correct and your implementation had some issues (phpstan/phpstan-src#5399 (comment))
After some investigations, it seems like this is because you rely a lot on
Type::equals, for instance here:https://github.com/rectorphp/rector-downgrade-php/blob/15578226e7d293f224a121dabaa11d8f6e7ab42a/rules/DowngradePhp74/Rector/ClassMethod/DowngradeCovariantReturnTypeRector.php#L239
This had the benefit BEFORE to return true when you compares a FullyQualifiedObjectType (
rector/src/StaticTypeMapper/ValueObject/Type/FullyQualifiedObjectType.php
Line 15 in 8e733db
I'm not fully sure how to change your implementation, some ideas...
describemethodtoPhpDocNode$child->isSuperTypeOf($parent)equalsmethod in your custom ObjectType class