I\'m currently migrating my website from PHP5 to PHP7, and I\'ve started using the strict typing feature that was added. However this requires me to begin all files with the
This is deliberately not possible, because the implementation adopted after an extremely long discussion of scalar type hints was this one: https://wiki.php.net/rfc/scalar_type_hints_v5
It explicitly gives the choice of how scalar types are checked to the caller of any function, not its author, so that:
It's therefore up to you to tell PHP which files have been written to use strict type mode, and which haven't; and the way to do this is using the declare
statement.
PHPStorm has an inspection to help you with this:
Essentially no.
Because if you only require libraries that used strict mode you will cause an unnecessary separation of packages. Also consider the strict/weak types option is just an extra in PHP.