Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make DateTime::modify() behaviour less annoying
- Loading branch information
1 parent
b5da7ce
commit 7bd9fb7
Showing
2 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7bd9fb7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi. What's the idea behind making this benevolent ?
DateTime::createFromFormat
returnsstatic|false
and not a benevolent union for instance. So why modify is benevolent ?7bd9fb7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VincentLanglet There are situations where the developer know it can never be false, but PHPStan doesn't know that. When I released PHPStan 1.6.6, it became apparent this behaviour is really annoying. In Slevomat's codebase there were dozens of new errors because of this behaviour. For example:
It can never be false, but PHPStan still thought so. That's why in these cases the union type has to be benevolent. That's why I rushed out PHPStan 1.6.7 last night.