laminas / laminas-di

Automated dependency injection for PSR-11 containers
https://docs.laminas.dev/laminas-di/
BSD 3-Clause "New" or "Revised" License
36 stars 20 forks source link

PARAMETER: Update `isBuiltin()` to account for Union and Intersection ReflectionType #53

Closed sjokkateer closed 2 years ago

sjokkateer commented 2 years ago
Q A
Documentation no
Bugfix yes/no
BC Break no
New Feature no
RFC no
QA no

Description

This PR resolves a phpstan error when using PHP >= 8.0, php version used: PHP 8.0.19 (cli). The error:

 ------ ---------------------------------------------------------- 
  Line   Parameter.php                                             
 ------ ---------------------------------------------------------- 
  88     Call to an undefined method ReflectionType::isBuiltin().  
 ------ ---------------------------------------------------------- 

The error message originated in the Parameter::isBuiltin() at L#88 because it is possible that a ReflectionParameter::class object is passed to the constructor that has a type, but is of the type: ReflectionUnionType::class in PHP 8.0 or ReflectionIntersectionType::class in PHP 8.1 and up.

To test this behavior, two dummy classes are added within the test namespace, one containing a union type, the other an intersection type, both tested for their respective versions of PHP.

Please let me know what you think of the suggested additions!