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
[treatPhpDocTypesAsCertain: false] Call to static method Assert::notNull() with DateTime|null will always evaluate to false. #4657
Comments
This bug report is missing a link to reproduction on phpstan.org. It will most likely be closed after manual review. |
I see this is marked as easy fix. Do you have any recommendations on how to fix this? I could try to create a PR and fix it myself :) |
Hi, I thought this would be easily reproducible. This code is equivalent but it doesn't show any error: https://phpstan.org/r/60856b1b-041c-4f7f-bca7-1eb05e228888 Once we have it reproduced with vanilla PHPStan, I'll tell you about the fix. Essentially we'd need |
When you're at it, this one should be really easy to fix: #4650 We just need these lines https://github.com/phpstan/phpstan-src/blob/6f7cadf96c7b55a0df21b51730e4b53ad13a7545/src/Analyser/MutatingScope.php#L757-L758 to call And the test should prove that |
@ondrejmirtes I'm still not sure how to fix this issue. I fixed the other issue in phpstan/phpstan-src#476 but I cannot reproduce my problem without the |
Reproduced: https://phpstan.org/r/f371c7db-7deb-440a-b1f6-398fd8a62ffe I guess the problem is that somewhere around ImpossibleCheckTypeHelper we should call |
Fixed by: phpstan/phpstan-src#477 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug report
Same happens when using PHPUnit's
$this->assertNotNull($command);
together withphpstan/phpstan-phpunit
. So I believe this is not a webmozart / phpunit extension issue.It's interesting because the error correctly says
$value
isDateTime|null
.Code snippet that reproduces the problem
Not possible as
phpstan/phpstan-webmozart-assert
is not installed. It would be great if the official extensions could be enabled on the playground.Expected output
No error.
The text was updated successfully, but these errors were encountered: