The PHP 7 revolution is well upon us and at the end of the year we should be seeing an official release. To help you prepare for the expected changes, the upcoming version of Zend Studio – Zend Studio 13, includes a new migration tool called PHP 7 Express. PHP 7 Express scans your PHP code for potential compatibility issues with PHP 7 and supplies you with all the information you need to get your projects ready for migration to PHP 7.
For example, it will identify ambiguous expressions introduced with Uniform Variable Syntax, or will warn you of obsolete usages removed in PHP 7 API such as ‘mysql’ or ‘ereg’ functions. Results are displayed in one centralized view and easy to find and fix.
To start using the migration tool, select your project in the PHP Explorer and from the context-menu select the Run PHP 7 Express action. The dialog that pops up allows you to include library folders in the scanning process. If you select this option, directories that are normally not processed (like e.g. vendor) will also be verified for PHP 7 compatibility.
NOTE: PHP 7 Express scans can be applied only to PHP projects with a defined PHP 5.x interpreter
NOTE: The Check library folders check-box will only be visible if your project contains library folders.
Once you hit the OK button, the selected project will be scanned for potential problems after switching to PHP 7. Results are displayed in an additional view called PHP 7 Express. If you are familiar with the Problems view, you will notice that the new view is very similar. The difference is that this new view is focused only on problems related to PHP 7 migration. Double-clicking a problem in the list opens the PHP editor with the corresponding file and line selected.
For problems with dereferencing syntax, Zend Studio proposes smart conversion to unified form, after which source code will retain the PHP 5.x meaning.
To use this option, simply place your cursor on the line in question and press CTRL + 1 (or just press light bulb on the left ruler). From the displayed menu, select Insert braces to retain PHP 5.x meaning. The quick fix will cover the problematic expression with braces.
The PHP 7 Express view can be customized using the Configure Contents… menu option which can be found on the view toolbar (top-right corner of the view). You can then use the Configuration dialog to change the limit for visible elements (by default it’s 100).
PHP 7 Express can be tested with the latest Zend Studio 13 Early Access release. Don’t hesitate and try it out!