We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Getting an error if null condition is not explicit.
<?php declare(strict_types = 1); class Bar { public function foo(): ?string { return null; } } class HelloWorld { public function sayHello(Bar $object): string { if ($object->foo()) { return $object->foo(); } return ''; } }
Code above generates an error: https://phpstan.org/r/bc5bd55d-64db-4f6f-a30a-e4fc367e81c7
This works: https://phpstan.org/r/296a2b2d-d3ce-42b7-b479-3293ba43c36a The difference is in condition $object->foo() !== null.
$object->foo() !== null
No errors expected. Or is it a feature? 😄
The text was updated successfully, but these errors were encountered:
Yes, currently a feature. I'll do something about it. Duplicate of #2288 and others.
Sorry, something went wrong.
No branches or pull requests
Bug report
Getting an error if null condition is not explicit.
Code snippet that reproduces the problem
Code above generates an error: https://phpstan.org/r/bc5bd55d-64db-4f6f-a30a-e4fc367e81c7
This works: https://phpstan.org/r/296a2b2d-d3ce-42b7-b479-3293ba43c36a
The difference is in condition
$object->foo() !== null
.Expected output
No errors expected. Or is it a feature? 😄
The text was updated successfully, but these errors were encountered: