[WIP] Add basic support for PHP 8 union types #4505
Merged
+12
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed that running Psalm on PHP 8 results in an error in my build:
The patch in this PR fixes the build, but more work needs to be done. (I'm also unsure about the policy of this package to unstable PHP versions)
I'm very very new with the Psalm codebase, so I'm unsure how to continue. I'm happy to finish this PR if there is some guidance, but also please feel free to take over this PR if that's easier for you :) A list of things I'm stuck with atm:
ReflectionUnionType
class, so the analysis errors. I foundstubs/Php80.php
anddictionaries/CallMap_80_deta.php
. Am I supposed this add that class somewhere? (I've tried doing so, but it didn't seem to do much) For reference, this is theReflectionUnionType
structure: https://wiki.php.net/rfc/union_types_v2#reflectiongetName()
is part ofReflectionType
, it's part ofReflectionNamedType
instead. I couldn't find a way to tell Psalm this.Could not verify return type 'Psalm\Type\Union' for Psalm\Internal\Codebase\Reflection::getPsalmTypeFromReflectionType
I'm unsure why that is, as this method is always returningType\Union
as far as I can see.Reflection
orphp8
. Can you guide my to which test class I should add a new test to cover this?