Skip to content

Call to undefined method ReflectionUnionType::isBuiltin() #197

Open
@glo17680

Description

@glo17680

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

Screenshot 2023-12-22 at 11 42 52 AM

Error:

Screenshot 2023-12-22 at 1 21 43 PM

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') {

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions