The release of PHP 7 is fast approaching, and there are some breaking changes that will need to be fixed to make sure your codebase is ready. Thankfully, PhpStorm 10 comes with a great inspection you can run to help you be prepared.
The PHP 7 Compatibility Inspection can show you exactly what code is going to cause errors if you are running PHP 7. It is enabled by default in PhpStorm 10.
Here, you can see that the inspection has marked the class name Int because in PHP 7, int, string, float and bool have all become reserved words. This is useful when you’re working on a single file, but it’s inconceivable that you’ll open every file in your codebase to check there are no red squiggles.
Checking your whole codebase is actually easy, because you can manually run inspections against the scope of your choice. Simply select the Run Inspection By Name… option from the Code menu, and then select the PHP 7 Compatibility inspection. You’ll get asked which scope you’d like to run it on, and then see the results from the inspection in the results pane.
Here, you can see that there are a number of validator classes that get bundled with Zend Framework 2 and have names of words that will be reserved in PHP 7. Now we know exactly what we need to fix so we can be prepared when PHP 7 gets released at the end of November.
Develop with pleasure!
– JetBrains PhpStorm Team