3 ms·
I think that the biggest win with this feature, is not that PHP will do more runtime type checks, but that the syntax is valid. The past years we've seen sever
by brendt_gd 7y ago
I think that the biggest win with this feature, is not that PHP will do more runtime type checks, but that the syntax is valid.
The past years we've seen several static analysers become more and more popular in the PHP community. Tools like phpstan (https://github.com/phpstan/phpstan https://github.com/phpstan/phpstan) and psalm by Vimeo (https://github.com/vimeo/psalm https://github.com/vimeo/psalm).
Allowing this syntax is a great way to write cleaner code that can be statically analysed, which is far more superior than the runtime type checker.
- TazeTSchnitzel 7y agoHaving them checked at runtime is still important (I say this as someone who was involved in scalar types getting declarations finally), because it means that the types can't end up inaccurate without being noticed, weak typing can be supported with certainty (you always get the type you ask for), and as a bonus the runtime can perform optimisations (elided type checks).