Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
glo17680 opened this issue Dec 22, 2023 · 6 comments
Open

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

glo17680 opened this issue Dec 22, 2023 · 6 comments
Labels
Bug Something isn't working

Comments

@glo17680
Copy link

glo17680 commented Dec 22, 2023

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

@glo17680 glo17680 added the Bug Something isn't working label Dec 22, 2023
@Ocramius
Copy link
Member

@glo17680 a failing test is needed

@glo17680
Copy link
Author

@glo17680 a failing test is needed

@Ocramius please find the failed case with screenshot in the ticket description.

@Ocramius
Copy link
Member

@glo17680 the expectation is for a PHPUnit test to be provided 😁

@glo17680
Copy link
Author

glo17680 commented Dec 22, 2023

@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 ?

@devlubinets
Copy link

@glo17680 I think it is enough.
I will work on it next weekend

@Ocramius
Copy link
Member

Ocramius commented May 3, 2024

Note: a psalm baseline reduction would suffice.

See

<file src="src/Reflection/ParameterReflection.php">
<ArgumentTypeCoercion>
<code><![CDATA[$function->getName()]]></code>
</ArgumentTypeCoercion>
<ImpureMethodCall>
<code>getDocBlock</code>
<code>getDocBlock</code>
<code>getProperty</code>
<code>getTags</code>
</ImpureMethodCall>
<MixedInferredReturnType>
<code>string|null</code>
</MixedInferredReturnType>
<MixedReturnStatement>
<code><![CDATA[$type->getName()]]></code>
</MixedReturnStatement>
<PossiblyUnusedProperty>
<code>$isFromMethod</code>
</PossiblyUnusedProperty>
<UndefinedMethod>
<code>getName</code>
<code>getName</code>
<code>isBuiltin</code>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants