doctrine / common

Doctrine Common
https://www.doctrine-project.org/projects/common.html
MIT License
5.79k stars 294 forks source link

Attempted to call an undefined method named "getName" of class "ReflectionIntersectionType" #948

Closed kopfsalat closed 2 years ago

kopfsalat commented 2 years ago

Hi,

while playing around with php 8.1 on our symfony project I hit the mentioned exception while clearing the cache.

Tested version: doctrine/common 3.1.2 and 3.2.0

Steps to reproduce: type hint a one to many relation with Collection&Selectable (use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Selectable;)

{"message":"Uncaught Error: Call to undefined method ReflectionIntersectionType::getName()","context":{"exception":{"class":"Error","message":"Call to undefined method ReflectionIntersectionType::getName()","code":0,"file":"/var/www/project/htdocs/vendor/doctrine/common/lib/Doctrine/Common/Proxy/ProxyGenerator.php:1148"}},"level":500,"level_name":"CRITICAL","channel":"php","datetime":"2021-12-20T17:28:01.249423+00:00","extra":{}} 17:28:01 CRITICAL [php] Uncaught Error: Call to undefined method ReflectionIntersectionType::getName() ["exception" => Error { …}]

There is a condition to handle ReflectionUnionType in ProxyGenerator but indeed nothing which handles ReflectionIntersectionType.

Best regards, Jeldrik

malarzm commented 2 years ago

Most probably never type will also need some attention as it shouldn't have return anywhere in code. I'm trying to get it fixed for ODM in https://github.com/doctrine/mongodb-odm/pull/2398 and that could later be used for fixing Proxy generation