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
Given the method
/** @return T|null */ final public function randValue(): mixed
In a generic Collection. Then using that method somewhere:
Collection
private function rand(): ?User { return $this->collection->randValue(); }
yields the error: Method User::rand() never returns null so it can be removed from the return type..
Method User::rand() never returns null so it can be removed from the return type.
https://phpstan.org/r/a70699a3-6415-4bc6-8247-7b55a57040dc
No errors.
PHPStan still helps a lot :)
The text was updated successfully, but these errors were encountered:
Apparently PHPStan thinks mixed return type never returns null: https://phpstan.org/r/a4940517-dc71-4766-89c8-0bb774b95b63
mixed
null
But it can: https://3v4l.org/ANhir
Sorry, something went wrong.
@Jeroeny After the latest commit in dev-master, PHPStan now reports different result with your code snippet:
@@ @@ -73: Method User::rand() never returns null so it can be removed from the return type. +No errors
phpstan/phpstan-src@4a2e2ef
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.
No branches or pull requests
Bug report
Given the method
In a generic
Collection
. Then using that method somewhere:yields the error:
Method User::rand() never returns null so it can be removed from the return type.
.Code snippet that reproduces the problem
https://phpstan.org/r/a70699a3-6415-4bc6-8247-7b55a57040dc
Expected output
No errors.
Did PHPStan help you today? Did it make you happy in any way?
PHPStan still helps a lot :)
The text was updated successfully, but these errors were encountered: