Nodea — logo

PHP 7.1

PHP 7.1 is a release of the PHP language shipped in December 2016 that extended the type system introduced in PHP 7.0. While it did not bring as dramatic a performance jump as its predecessor, it added a number of practical mechanisms that make it easier to write precise, self-documenting code.

Why PHP 7.1 mattered

PHP 7.1 refined typing and introduced convenient syntax improvements:

  • nullable types — writing ?int lets you indicate that a value may be of a given type or null;
  • the void return type — explicitly marking functions that return no value;
  • class-constant visibility — public, protected and private modifiers for constants;
  • array destructuring and keys in list() — more convenient unpacking of data from arrays.

These changes, though seemingly cosmetic, made it easier for library and framework authors to build precise interfaces, which translated into fewer bugs in code.

Practical applications

Support for PHP 7.1 ended in 2019, so it is now an obsolete version. During its active life it was a popular choice for projects built on modern frameworks, which quickly began to require nullable types and other additions from the 7.x branch. Applications running on PHP 7.1 today should be updated to a supported version, such as PHP 7.2 or later. Modern hosting and VPS servers offer only currently supported PHP releases.

Its role in maturing the type system

Although PHP 7.1 is often seen as a transitional release between the spectacular PHP 7.0 and later versions, its contribution to the evolution of typing was significant. Nullable types and the void type made it possible to describe function contracts more precisely, so static-analysis tools could catch more errors before the application even ran. It was during this period that static analysis began to become a standard in professional PHP development teams.

Powiązane pojęcia