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
Level 7: has* checks #534
Comments
I was unable to find duplicates while searching, so I reported this just to make sure it is reported. :-) |
@hultberg That's expected behavior. TypeScript would report the same error. |
Hi, this would require a new type of an extension - "type-specifying extension" to help PHPStan make sure that something is of a specific type after a function or method is called. But for now, I recommend you the following structure:
If you ask |
This is already possible on dev-master. The Type-specifying extension support will be released as part of 0.10 during Q2 2018. See some examples on how to write type-specifying extensions:
Let me know if you need any help with writing such an extension. |
Consider the following code:
Here, phpstan will report the following error:
I can understand this error as I have declared getObj to return null or HelloWorld instance, however, this can never occur because of my hasObj check, but phpstan does not seem to understand this. Is this a bug or feature request?
https://phpstan.org/r/2c5f7204f766e044cf3bb54192c84b2e
Cheers
The text was updated successfully, but these errors were encountered: