-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Allow for PhpDoc for macros with union types #1148
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, got a question :)
$type = $this->concatReflectionTypes($reflectionType); | ||
|
||
/** @psalm-suppress UndefinedClass */ | ||
if ($reflectionType && !$reflectionType instanceof \ReflectionUnionType && $reflectionType->allowsNull()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\ReflectionUnionType
I assume in PHP < 8 this will "just work", because a non-existent class check in instanceof
will not trigger any problems?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct!
Is there anything left to do before merging? We're currently using the patch branch in our project since this bug was breaking the ide-helper package. Thanks! |
@mfn you haven't approved this, but did say LGTM so I guess it's okay with you :) |
Thanks for merging! |
The last release was on April 9th. When will this fix be released? I dont want to use |
* Allow for PhpDoc for macros with union types * Replace null coalescing operator * Test init PhpDoc for macros with parameter union types * Allow for PhpDoc for macros with union return types * Add helper method to Macro class * Add changelog entry * Format * Complement changelog with PR link * Add missing return * Fix test for PHP < 8 * Rewrite PHP 8 test using eval() * Remove obsolete test class * Suppress Psalm errors for undefined ReflectionUnionType class * Remove unreachable return statement
Summary
When running the IDE helper on macros with PHP 8 union types, an error
Call to undefined method ReflectionUnionType::getName()
will be thrown. This PR aims to fix that for both the parameter and return types.Type of change
Checklist
composer fix-style