Call to undefined method ReflectionUnionType::isBuiltin()
Bug Report
| Q | A |
|---|---|
| Version(s) | 4.13.0 |
Summary
The issue is reproduced when calling detectType() with PHP8.3. The function is mentioned as Deprecated in codebase.
File: src/Reflection/ParameterReflection.php Line:81
Error:
Current behavior
How to reproduce
Calling this function detectType() on PHP8.3 throw this error.
Expected behavior
There should be added one check if the function is not available on a particular version, the error should not be thrown.
Proposed Fix (which is working): 1- Instead of if (null !== ($type = $this->parameterReflection->getType()) && $type->isBuiltin()) {
we can fix by adding one check if (null !== ($type = $this->parameterReflection->getType()) && method_exists($type, 'isBuiltin') && $type->isBuiltin()) {
2-
And instead of
if (null !== $type && $type->getName() === 'self') {
we can fix by adding one check
if (null !== $type && method_exists($type, 'getName') && $type->getName() === 'self') {
@glo17680 a failing test is needed
@glo17680 a failing test is needed
@Ocramius please find the failed case with screenshot in the ticket description.
@glo17680 the expectation is for a PHPUnit test to be provided 😁
@glo17680 the expectation is for a PHPUnit test to be provided 😁
@Ocramius I have attached all the required information which I have. I'm not sure for what you are asking for. Can you please confirm if any required information is missing or Is the information provided insufficient to replicate the issue ?
@glo17680 I think it is enough. I will work on it next weekend
Note: a psalm baseline reduction would suffice.
See https://github.com/laminas/laminas-code/blob/33dd0f21ffdc157f56dd8d127fd7e67f79085de9/psalm-baseline.xml#L947-L969