nextras / orm-phpstan

PHPStan extension for Nextras Orm
https://nextras.org/orm
MIT License
11 stars 6 forks source link

Call to undefined method PHPStan\Type\UnionType::getClassName() #19

Closed mrceperka closed 3 years ago

mrceperka commented 3 years ago

nextras/orm 4.0, nextras/orm-phpstan 0.6.1, phpstan/phpstan 0.12.30

Fatal error: Uncaught Error: Call to undefined method PHPStan\Type\UnionType::getClassName() in /var/docker/vendor/nextras/orm-phpstan/src/Types/RepositoryReturnTypeExtension.php:76
Stack trace:
#0 phar:///var/docker/vendor/phpstan/phpstan/phpstan/src/Analyser/MutatingScope.php(2527): Nextras\OrmPhpStan\Types\RepositoryReturnTypeExtension->getTypeFromMethodCall(Object(PHPStan\Reflection\ObjectTypeMethodReflection), Object(PhpParser\Node\Expr\MethodCall), Object(PHPStan\Analyser\MutatingScope))
#1 phar:///var/docker/vendor/phpstan/phpstan/phpstan/src/Analyser/MutatingScope.php(1196): PHPStan\Analyser\MutatingScope->methodCallReturnType(Object(PHPStan\Type\ObjectType), Object(PHPStan\Type\ObjectType), 'findAll', Object(PhpParser\Node\Expr\MethodCall))
#2 phar:///var/docker/vendor/phpstan/phpstan/phpstan/src/Type/TypeTraverser.php(47): PHPStan\Analyser\MutatingScope->PHPStan\Analyser\{closure}(Object(PHPStan\Type\ObjectType), Array)
#3 phar:///var/docker/vendor/phpstan/phpstan/phpstan/src/Type/UnionType.php(415): PHPStan\Typ in /var/docker/vendor/nextras/orm-phpstan/src/Types/RepositoryReturnTypeExtension.php on line 76

I don't get it why this error even occurs. This should not ever happen, because it's protected by assert right? https://github.com/nextras/orm-phpstan/blob/master/src/Types/RepositoryReturnTypeExtension.php#L74

But for some WEIRD reason, assert passes. image image

Code that probably caused this error:

/** @var ChannelPredefinedDataAdformFormatRepository|ChannelPredefinedDataSmartRepository|null $repository */
$repository = null;