PHP 7.0 has recently introduced the new strict_type parameter declaration and it **must** be the very first declaration in a PHP file.
I use a PHP Framework that has hundreds of files and do not want to add the declaration to each individual PHP file - because that’s what computers are for
I was hoping to add a single line to the .htaccess file which would insert the following declaration into every PHP file:
The declare(strict_types=1) directive must
be the first statement in a file. If it appears anywhere else in the
file it will generate a compiler error. Block mode is also explicitly
disallowed (declare(strict_types=1); is the only allowed form).
Like the encoding directive, but unlike the ticks directive, the strict_types
directive only affects the specific file it is used in, and does not affect either other files which include the file nor other files that are included by the file.
I would think the at the very least you’ll have to run a search/replace on the opening <?php of each file to add in the strict type declaration. Although, you’re not really getting the full benefit unless you refactor the existing code to use the additional type declarations (int, string, float and bool) and declare function/method return types.