-
-
Notifications
You must be signed in to change notification settings - Fork 724
Description
Bug Report
Subject | Details |
---|---|
Rector version | e.g. v0.12.8 |
PHP Fatal error: Uncaught PHPStan\ShouldNotHappenException: Cannot create PHPStan\Type\UnionType with: string|null, string|null in phar:///usr/src/app/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Type/UnionType.php:33
Stack trace:
#0 phar:///usr/src/app/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Type/UnionType.php(47): PHPStan\Type\UnionType::PHPStan\Type{closure}()
#1 /usr/src/app/vendor/rector/rector/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/GetterPropertyTypeInferer.php(94): PHPStan\Type\UnionType->__construct(Array)
#2 /usr/src/app/vendor/rector/rector/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer.php(101): Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer\GetterPropertyTypeInferer->inferProperty(Object(PhpParser\Node\Stmt\Property))
#3 /usr/src/app/vendor/rector/rector/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer.php(73): Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer->getResolvedTypes(Object(PhpParser\Node\Stmt\Property))
#4 /usr/src/app/vendor in phar:///usr/src/app/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Type/UnionType.php on line 33
TypedPropertyRector throws this exception when there is a property that has several getters. In our case the property is serialized differently for different versions using different getters.
Minimal PHP Code Causing Issue
https://getrector.org/demo/1ec5de4d-8241-6310-8403-2d68574ebfd1
Expected Behaviour
It should not fail. Maybe the union types should be merged?