PHP 8.3 Released
Written by Alex Armstrong   
Tuesday, 28 November 2023

PHP 8.3 has been released with improvements including explicit typing of class constants, deep cloning of readonly properties, and additions to randomness functionality.

PHP began life as a simple scripting language designed to build web pages but has developed into a general server side web language . It is now used for eight out of ten websites using server-side code. 

phplogo

The first improvement to the new release is explicit typing of class constants. The developers say that not being able to declare constant types can be a source of bugs and confusion for class constants: By default, child classes can override class constants of their parents, so sometimes it is not easy to assume what the value and the type of a class constant really is, unless either their defining class or the constant itself is final. The new release adds support for declaring class, interface, trait, as well as enum constant types (collectively called “class constants”).

This release also adds support for fetching dynamic class constants. Previous versions of PHP supported various ways of looking up member's names, but no way to look up class constants. Support for this has now been added.

A new override attribute has also been added. When implementing an interface or inheriting from another class, PHP performs various checks to ensure that implemented methods are compatible with the constraints imposed by the interface or parent class, but hasn't been able to check whether a method is actually intended to implement the interface method or override the parent method or not. The new override attribute, when added to a method, causes the engine to validate that a method with the same name exists in a parent class or any of the implemented interfaces. If no such method exists, a compile time error is emitted.

Readonly properties have also received attention. These were added in PHP 8.1, but the developers say they had some shortcomings that have now been addressed. Specifically, non-readonly classes can now extend readonly classes, and readonly properties can be reinitialized during cloning.

PHP 8.3 is available for download now.

phplogo

More Information

PHP Website

Related Articles

PhpStorm Updated For PHP 8.3

PHP Adds Read-Only Classes

PHP - Essential But Underappreciated

Ten Minutes to PHP

PHP Is Best?

PHP 8.0 Adds Metadata To Classes

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


Remembering Grace Hopper On Her 114th Anniversary
09/12/2024

Today sees the start of Computer Science Education Week and  the 2024 Hour of Code. These educational event are timed to coincide with Grace Hopper's birthday on January 9th, 1906 due to her conc [ ... ]



Discover PostgreSQL How-Tos
16/12/2024

A veritable treasure trove of assorted how-to recipes for PostgreSQL, stored as a Github repository, has been started by Nikolay Samokhvalov, well known in the PostgreSQL world.


More News

espbook

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Tuesday, 28 November 2023 )