Menu
PHP 8.3 brings typing of class constants

PHP 8.3 brings typing of class constants

Major update to PHP adds support for declaring class, interface, trait, and enum constant types. Readonly properties and randomness also get attention.

Credit: Kevin

PHP 8.3, a major update to the popular server-side web scripting language, offers features such as explicit typing of class constants, deep cloning of readonly properties, and additions to randomness functionality.

Released November 23, PHP 8.3 can be accessed from php.net.

With typed class constants, PHP 8.3 gains support for declaring class, interface, trait, and enum constant types. Class constant type declarations support all type declarations supported by PHP, with the exception of void, callable, and never.  The void and callable types are not supported due to issues discussed in the typed properties v2 RFC. Similarly, never is not applicable in the context of constants.

To enable deep cloning of readonly properties, PHP 8.3 allows readonly properties to be modified once within the magic __clone method. Plus, readonly classes now can be reinitialsed during cloning. PHP 8.3 also lets non-readonly classes extend readonly classes.

Other new features and improvements in PHP 8.3:

  • A new [#\Override] attribute expresses intent in code. If this attribute is added to a method, the engine shall 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 shall be emitted.
  • The command line linter now accepts variadic input for file names to lint.
  • The Random Extension added in PHP 8.2 adds a new method that generates random strings consisting of specific bytes only. This method allows developers to easily generate random identifiers, such as domain names, and numeric strings of arbitrary length.
  • A a new function, json_validate(), indicates whether a string contains valid JSON.
  • Anonymous classes now can be readonly.

PHP 8.2 arrived last December, introducing readonly classes.


Follow Us

Join the newsletter!

Or

Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.

Events

EDGE 2024

Register your interest now for EDGE 2024!

Brand Post

Featured

Slideshows

How MSPs can capitalise on integrating AI into existing services

How MSPs can capitalise on integrating AI into existing services

​Given the pace of change, scale of digitalisation and evolution of generative AI, partners must get ahead of the trends to capture the best use of innovative AI solutions to develop new service opportunities. For MSPs, integrating AI capabilities into existing service portfolios can unlock enhancements in key areas including managed hosting, cloud computing and data centre management. This exclusive Reseller News roundtable in association with rhipe, a Crayon company and VMware, focused on how partners can integrate generative AI solutions into existing service offerings and unlocking new revenue streams.

How MSPs can capitalise on integrating AI into existing services
Access4 holds inaugural A/NZ Annual Conference

Access4 holds inaugural A/NZ Annual Conference

​Access4 held its inaugural Annual Conference in Port Douglass, Queensland, for Australia and New Zealand from 9-11 October, hosting partners from across the region with presentations on Access4 product updates, its 2023 Partner of the Year awards and more.

Access4 holds inaugural A/NZ Annual Conference
Show Comments