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


Extend NGINX With The New JavaScript Module
28/10/2024

Inject middleware functionality into NGINX with the expressive power of Javascript. NGINX JavaScript or NJS for short is a dynamic module under which you can use scripting for hooking into the NGINX e [ ... ]



Go At Highest Rank Ever in TIOBE Index
20/11/2024

Go is currently in 7th place in the TIOBE Index for November 2024. Not only is this is the highest position it has ever had, it's percentage rating is almost equal to its all-time-high. Will Go contin [ ... ]


More News

espbook

 

Comments




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

Last Updated ( Tuesday, 28 November 2023 )