Code on a screen with a blurred background, representing the PHP 8.2 release.

PHP 8.2 added readonly classes, standalone null, true and false types, disjunctive normal form types and deprecated dynamic properties.

PHP 8.2 was released on December 8, 2022. It builds on the readonly properties introduced in PHP 8.1 and continues the language's move toward stronger, more expressive types, while beginning to phase out a long-standing source of subtle bugs.

Readonly classes

PHP 8.1 let individual properties be marked readonly; PHP 8.2 extends that to entire classes. Declaring a class readonly makes all of its properties readonly automatically, which is a concise way to express immutable value objects. This reduces boilerplate and makes the intent, that instances should not change after construction, obvious at a glance.

Standalone null, true and false types

PHP 8.2 allows null, true and false to be used as standalone types in type declarations. Previously these could only appear as part of a union. Being able to declare, for example, a function that returns exactly false in an error case makes signatures more precise and helps static analysis tools reason about code.

Disjunctive normal form types

The release adds disjunctive normal form (DNF) types, which allow combining union and intersection types in a single declaration. This gives developers a way to express more complex type constraints directly in the language rather than relying on documentation or runtime checks.

Deprecating dynamic properties

PHP 8.2 deprecated the creation of dynamic properties, that is, assigning to a property that was never declared on a class. Historically this was allowed silently and was a frequent source of typo-driven bugs. Classes that genuinely need dynamic properties can opt in with an attribute, but the default now nudges developers toward explicit property declarations.

Support timeline

According to php.net, PHP 8.2's initial stable release was December 8, 2022, with active support into the end of 2024 and security fixes into the end of 2026.

See also: PHP 8.3's typed class constants.

Sources

Published date reflects the original event date (2022-12-08). This article is original Skillo editorial written from the sources above; facts were verified in September 2026.

Skillo Staff

Skillo Staff

All stories by: Skillo Staff

Leave a Reply