You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With regard to which files should include the declaration, further research is required.
I say this because the relevant PHP documentation makes it clear that the declaration affects function calls, not definitions. In other words, blindly jamming the declaration at the top of every class file in the source tree probably isn't the best course of action.
My advice: put this strict type declaration everywhere in your code. Everywhere! Create a snippet in your IDE for it. Each time you create a PHP file, you should put this strict type declaration on top.
Maybe the better question to ask is, what's the downside to doing as the author suggests?
This, of course, requires adding
declare(strict_types=1);
to the top of applicable files.Return types should be enforced consistently, too (this is done in most places, but not everywhere).
The text was updated successfully, but these errors were encountered: