-
Notifications
You must be signed in to change notification settings - Fork 529
Support "true" pseudotypes in native unions #1539
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
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.
requires integration of Roave/BetterReflection#1152 into ondrejmirtes/BetterReflection to proceed
@@ -273,4 +273,25 @@ public function testIntersectionTypes(int $phpVersion, array $errors): void | |||
$this->analyse([__DIR__ . '/data/intersection-types.php'], $errors); | |||
} | |||
|
|||
public function dataTrueTypes(): array | |||
{ | |||
return [ |
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.
initially I had the idea to make the new type only available on php 8.2+, but it seems atm we cannot do it in a version dependent way.
maybe this would even be more like a linter task.. leave it like this for now, as I realized thats the way we implemented such types in the past
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.
Allegedly this is gonna be solved in PHP-Parser 5.0 which is gonna make a thick line between Name
and Identifier
dependent on PHP version.
BetterReflection is updated in 1.8.x. |
did some local debugging. the last remainig part is a new PhpParser release, because in the current stable release the on the master branch the necessary stuff is already implemented though |
php-parser was updated with #1690 |
{ | ||
} | ||
|
||
function trueUnionReturn(): true|null |
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.
How are the other two methods tested? I'd expect more assertType calls here.
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.
done
Thank you! |
@staabm Can you please also write some tests for these? Thank you! https://php.watch/versions/8.2/null-false-types |
https://phpstan.org/r/1401ac97-4f3d-4209-a6bf-e3e24e621738 do you mean creating new rules which emit errors in |
No, just type inference tests to see that these standalone types work. |
https://wiki.php.net/rfc/true-type
fixes https://phpstan.org/r/ae4ac09d-f2b0-46c0-ac4b-f8fdbd2a8c96
Prerequisites
true
type asReflectionNamedType#isBuiltIn()
value Roave/BetterReflection#1152