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
Fix subtracting types from union template types #2652
Conversation
You've opened the pull request against the latest branch 1.11.x. If your code is relevant on 1.10.x and you want it to be released sooner, please rebase your pull request and change its target to 1.10.x. |
ec957a9
to
1a3519e
Compare
1a3519e
to
e0aef00
Compare
FYI @rvanvelzen I described an issue here phpstan/phpstan#9925 (reply in thread), I think it's up your alley to fix it :)
If you decide to look at it that would be great! |
@@ -1341,6 +1341,7 @@ public function dataFileAsserts(): iterable | |||
yield from $this->gatherAssertTypes(__DIR__ . '/data/nullsafe-vs-scalar.php'); | |||
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-8517.php'); | |||
yield from $this->gatherAssertTypes(__DIR__ . '/../Rules/Functions/data/bug-9803.php'); | |||
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-9939.php'); |
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.
This needs to be put in PHP_VERSION_ID
if.
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.
Also it's better to put in some random place in the middle, because at the end it's more likely to have conflict when merging into 1.11.x
@@ -0,0 +1,63 @@ | |||
<?php declare(strict_types = 1); |
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.
This needs // lint >= 8.1
e0aef00
to
9bf7780
Compare
Thank you! |
Maybe a simplified test case instead of that bloated one? This is also PHP-version independent <?php declare(strict_types = 1);
/**
* @template T of string|array<string>
*/
class C {
/**
* @param T $a
*/
public function foo($a): string {
if (is_array($a)) {
return "";
}
\PHPStan\Testing\assertType('T of string (class C, argument)', $a);
return (string) $a;
}
} |
Fix phpstan/phpstan#9939