Skip to content
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

Use strict type-checking throughout #12

Open
cbj4074 opened this issue Apr 30, 2019 · 2 comments
Open

Use strict type-checking throughout #12

cbj4074 opened this issue Apr 30, 2019 · 2 comments

Comments

@cbj4074
Copy link
Member

cbj4074 commented Apr 30, 2019

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).

@cbj4074
Copy link
Member Author

cbj4074 commented May 1, 2019

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.

@cbj4074
Copy link
Member Author

cbj4074 commented May 2, 2019

In an effort to shed some light on the quandary at hand (where, exactly, to place these declarations), I came across:

https://thevaluable.dev/typing-with-php-7-what-you-shouldnt-do/

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant