BRAHMA TECHNOLAB

What’s New in PHP 8.2

Introduction

PHP 8.2 is a major update of the PHP language. It contains many new features, including readonly classes, null, false, and true as stand-alone types, deprecated dynamic properties, performance improvements and more.

Read Only Classes

You can now make the whole class as just read-only.

Disjunctive Normal Form (DNF) Types

DNF types allow us to combine union and intersection types, following a strict rule: when combining union and intersection types, intersection types must be grouped with brackets.

Null, True, and False as Standalone Types

Three new standalone types have been added in PHP 8.2

New Random Extension

The “random” extension provides a new object-oriented API to random number generation. Instead of relying on a globally seeded random number generator (RNG) using the Mersenne Twister algorithm the object-oriented API provides several classes (“Engine”s) providing access to modern algorithms that store their state within objects to allow for multiple independent seedable sequences.

Constant in Traits

You cannot access the constant through the name of the trait, but, you can access the constant through the class that uses the trait.

Deprecate dynamic properties

The creation of dynamic properties is deprecated to help avoid mistakes and typos, unless the class opts in by using the #[\AllowDynamicProperties] attribute. stdClass allows dynamic properties.

Usage of the __get/__set magic methods is not affected by this change.

LET’S DISCUSS YOUR PROJECT

Comments are closed.

Snehal

Typically replies within a day

Hello, Welcome to BRAHMA TECHNOLAB. Please click below button for chatting us through Skype.