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


Undefined Behavior Just Not Worth The Effort!
30/04/2025

Some very interesting research has just been published that throws a lot of light on the crazy belief that undefined behavior is useful, essential even, to certain types of optimization rather than th [ ... ]



Action Figure Craze Overruns OpenAI
13/04/2025

If you're on social media, you'll probably have seen a lot of 'action figure' posts, where people show off images of themselves, their dog or their cat in the form of an action figure, complete with s [ ... ]


More News

espbook

 

Comments




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

Last Updated ( Tuesday, 28 November 2023 )