PHP 8.3 is released with new features as 8.0 heads for end of life

PHP 8.3 is released with new features as 8.0 heads for end of life

PHP 8.3 released today into the cold light of day, with fresh features including an Override attribute, JSON validation and typed class constants.

Key features of the latest version include:

  • #[\Override] attribute: verifies that a method marked with this attribute actually has a parent method that is overridden. It protects against typing errors or refactoring where a parent method is removed; such cases will now trigger fatal errors.
  • Typed class constants: a constant declared in a class, interface or trait can now be typed. The RFC for this feature remarks on the “huge efforts put into improving the type system of PHP year after year.” PHP, like JavaScript, is a dynamic language; but there is demand for strong typing and some support for this has gradually been added.
  • Json_validate() function: this checks that a string is valid JSON (JavaScript Object Notation) and is more efficient than json_decode().
  • Deep cloning of read-only properties: this feature was part of a proposal to address “severe shortcomings” in PHP’s support for readonly properties. A proposal that non-readonly classes can extend readonly classes was not approved, but the ability to re-initialize readonly properties during cloning was approved, addressing what the proposal called “a major inconvenience which prevents any non-basic use-cases.” Reinitialization is only possible once, during the execution of the __clone() method.

Tool vendor JetBrains has been quick to support PHP 8.3 with a new release of the PhpStorm IDE. 

A new version of PHP is released approximately every 12 months, with the previous release being 8.2 in December 2022. Each release has two years of active support and one year of security support, so 8.0 – released on 26 Nov 2020 – goes out of security support in a few days, though operating system vendors may have their own support policies that include PHP. It is common for PHP versions that are long out of support to remain in use, and one report earlier this year claimed that a majority of deployments are in this state.

W3Techs reports that PHP is by far the most widely deployed server-side application runtime, despite decline in the number of developers using it. Stats from here.

PHP usage by developers appears to be declining judging by surveys like the annual StackOverflow report, which in 2023 had 18.58 percent of developers reporting that they code in PHP, versus 20.87 percent in 2022 and 26.2 percent in 2020. Nevertheless it remains popular and is the platform used by WordPress, which runs on 43 percent of all websites, according to W3Techs. The same site shows that PHP is used by “76.7% of all websites whose server-side programming language we know.”