'Enabling 'strict_types' globally in PHP 7

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 following line:

<?php declare(strict_types=1);

// All other code here
// ...

So I was wondering, is there any way to enable strict_types globally using something like php.ini or the apache configuration file so I don't have to write this line every time, and if so how could I enable this?



Solution 1:[1]

PHPStorm has an inspection to help you with this:

enter image description here

Solution 2:[2]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jawira
Solution 2