Get Ready for PHP 7.2

PHP 7.2 will be released on November 30th (the same day as Symfony 4). During the past SymfonyCon Cluj 2017 conference, Sara Golemon, release manager of PHP 7.2, explained that PHP 7.2 is not as revolutionary as PHP 7.0, but it provides a nice 10% performance increase over PHP 7.1 and some code clean-ups.

Making Symfony compatible with PHP 7.2

We started working on PHP 7.2 compatibility more than one year ago and we've been testing Symfony with PHP 7.2 successfully for some months thanks to our tests on Travis CI. All Symfony versions, from 2.7 to the upcoming 3.4 and 4.0, are now fully compatible with PHP 7.2.

The changes needed to achieve this full PHP 7.2 compatibility were minor but spread across our entire code base: #20859, #21389, #22707, #23711, #24509, etc.

Making your applications compatible with PHP 7.2

The PHP project has published a complete migration guide from PHP 7.1 to 7.2. Remi Collet, the other release manager of PHP 7.2, recently published the results of testing hundreds of PHP libraries with PHP 7.2. The most common errors he found were:

  • Using count() on uncountable things (e.g. null).
  • Using object, which is now a reserved word (and can be used to type-hint method arguments).
  • Stricter prototype checking (before PHP 7.2, if a method is defined in an interface, then compatibility was measured only against the interface and any parent method's signature were ignored).

If you can't upgrade to PHP 7.2 yet, you can install the PHP 7.2 Polyfill component in your projects. Polyfills are PHP libraries that let you use some of the features included in modern PHP versions (for example to use PHP 5.5 or 7.0 features in a legacy application that must still use PHP 5.3 for some reason).

The PHP 7.2 polyfill includes several functions (spl_object_id(), stream_isatty(), utf8_encode(), utf8_decode() and sapi_windows_vt100_support() in Windows only) and a new constant (PHP_OS_FAMILY).

Help the Symfony project!

As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.


Comments are closed.

To ensure that comments stay relevant, they are closed for old posts.