PHP 8.2 Released: Readonly Classes and Standalone Types
PHP 8.2 added readonly classes, standalone null, true and false types, disjunctive normal form types and deprecated dynamic properties.
Historical Archive. This article documents an event from 2022 and is preserved with its original date for reference. It is not current news, and details may have changed since publication.
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.
Related on Skillo
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.
Written by
Skillo Staff
0 Comments
Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.