thephpleague / tactician-bundle

Bundle to integrate Tactician with Symfony projects
MIT License
245 stars 43 forks source link

ReflectionParameter::getClass() is deprecated in PHP8 #124

Closed acasademont closed 3 years ago

acasademont commented 3 years ago

On PHP8 this method is deprecated

https://github.com/thephpleague/tactician-bundle/blob/66b97472915290b93654e60610295660f597ad4e/src/DependencyInjection/HandlerMapping/TypeHintMapping.php#L61

Not sure what's the best way to address it right now

acasademont commented 3 years ago

It's suggested to use the getType() function, that now can return 2 different subclasses, https://www.php.net/manual/en/class.reflectionuniontype.php and https://www.php.net/manual/en/class.reflectionnamedtype.php.

All this is to allow union types, the parameter is now not necessarily unique. This line https://github.com/thephpleague/tactician-bundle/blob/66b97472915290b93654e60610295660f597ad4e/src/DependencyInjection/HandlerMapping/TypeHintMapping.php#L60

would also throw an error if there was a union type, as the isBuiltin() method is only a method of the ReflectionNamedType class (and the same with the getName() method).

A refactor taking into account union types is needed