-
Couldn't load subscription status.
- Fork 144
refactor: add declare(strict_types=1)
#379
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
Conversation
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.
Nice to see everything was already working as strict! I think this is a good change. @lonnieezell has been hesitant in the past so let's make sure he has a chance to weigh in.
|
When will this ship to the main repo?? 🤔😂 |
|
If everyone else on the team feels strongly then we should do this then do it. My hesitation has always been based on an incorrect understanding I think. IIRC, this will still cast numeric strings, for example, into ints when called from my code, just not when called within the same file. If I'm remembering that correct then I'm fine. If I'm not, and it forces you to explicitly cast in your own code I find that onerous. I stopped programming in C/C++ years ago and don't have an interest in using Java :) |
|
See https://www.php.net/manual/en/language.types.declarations.php#language.types.declarations.strict
|
|
There is one thing that you need to keep in mind when using the strict_type declaration. It only works for the file that the declaration is placed in. Meaning that when you use a class, which has the strict_type declaration, it can still result in PHP casting primitive value. So keep that in mind when you want to start using this! |
|
Perfect. Then I'm fine. |
|
Yes, these are correct. The good news is that declaring strict has grown massively during the static analysis era, since most SA tools actually end up enforcing proper "strict" handling already. I expect a larger percent of developers than ever to understand the benefits and limitations. Merge complete. On to the main repo! ====€ |
declare_strict_typesrule to php-cs-fixerdeclare(strict_types=1)