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
Implement conditional parameter types #1264
Conversation
} | ||
|
||
$errors = $this->runAnalyse(__DIR__ . '/data/discussion-7124.php'); | ||
$this->assertCount(4, $errors); |
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.
Please assert which errors are happening here.
$this->assertSame('Parameter #2 $callback of function Discussion7124\filter expects callable(int): bool, Closure(bool): bool given', $errors[0]->getMessage()); | ||
$this->assertSame(52, $errors[0]->getMessage()); | ||
$this->assertSame('Parameter #2 $callback of function Discussion7124\filter expects callable(bool): bool, Closure(int): bool given', $errors[0]->getMessage()); | ||
$this->assertSame(59, $errors[0]->getMessage()); |
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.
What? :) You're asserting the same thing to different values.
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.
I think I was day dreaming a bit when moving some code around 😅
81b7b66
to
be17f0a
Compare
I've refactored "late resolvable types" a bit to make it more future-proof. Stuff like offset access types can reuse much of the logic. |
build/composer-require-checker.json
Outdated
@@ -19,6 +19,7 @@ | |||
"Reflection", | |||
"SPL", | |||
"standard", | |||
"pcntl", |
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.
Did you re-add this stuff intentionally or was it a bad merge/rebase?
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.
Definitely a bad merge
1b7da5f
to
465867b
Compare
Nice cleanup, I really like it :) Thank you! |
8c62388
to
76a48db
Compare
Resolves phpstan/phpstan#7124. Parameter types could in fact already be conditional when using template types, this just implements the same logic as used for return types.
To improve error messages for conditional types in general they're resolved immediately now (when possible)