-
-
Notifications
You must be signed in to change notification settings - Fork 864
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
False positive on DateTime(Immutable) #5259
Comments
This is expected error, PHPStan does not have hardcoded knowledge there's only two implementations of DateTimeInterface. Use union of the two types instead (in PHPDoc if you're on PHP 7.x): https://phpstan.org/r/0e8fa65d-202a-41d0-9e1e-01941886341a |
But I think phpstan should have this hardcoded knowledge. Custom implementations of DateTimeInterface are not possible. False positive errors should be avoided as much as possible because those are hurting phpstan usability the most. |
Also changing to union types won't help. The DateTimeInterface is coming from a long chain of other code and even third party code.
|
@ondrejmirtes any chance to reconsider this? |
@Tobion I'm not promising PHPStan will understand this in every scenario, but I did a simple fix for your case: phpstan/phpstan-src@5eb96f5 |
Cool, thank you. |
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
Phpstan does not seem to understand that there are only two implementations of DateTimeInterface.
The following code
results in wrong error
Code snippet that reproduces the problem
https://phpstan.org/r/6db83755-bca0-4294-a457-3d38a503aaac
The text was updated successfully, but these errors were encountered: