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


Redis Changes License, Rival Fork Launched
03/04/2024

The developers of Redis have announced that they are changing the licensing model for the database. From now on, all future versions of Redis will be released with source-available licenses rather tha [ ... ]



Important Conference Results
17/04/2024

The SIGBOVIK conference has just finished and its proceedings can be downloaded, but only at your peril. You might never see computer science in the same way ever again.


More News

raspberry pi books

 

Comments




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

Last Updated ( Tuesday, 28 November 2023 )