The PHP development team released PHP 8.2.0 on 8 December, making source downloads and Windows binaries available. The update brings readonly classes, richer type declarations and a new object-oriented random-number API, alongside changes that existing applications need to handle.
Composition: Sulat. Unchanged PHP logo by Colin Viebrock, CC BY-SA 4.0.
Readonly moves up to the class
A readonly class makes all its instance properties readonly, reducing repetitive declarations for data objects. Properties must be typed, and dynamic properties are forbidden. Inheritance must also preserve the readonly class declaration, so library authors cannot treat it as a cosmetic change to a public class.
The restriction is shallow: an object stored in a readonly property can still change internally. Readonly prevents replacing the property’s value; it does not freeze every object reachable through it.
Undeclared properties become visible
For ordinary classes, creating an undeclared property now raises a deprecation notice rather than silently adding it. PHP 8.2 still creates the property. This exposes misspellings that previously looked like successful assignments. Declaring intended properties addresses the usual case. stdClass and classes marked AllowDynamicProperties permit dynamic properties. Without those opt-ins, __set can handle a write without adding a property; if it creates an undeclared property itself, the notice still applies.

Types can describe more cases
The release’s type-system additions allow a union to include an intersection, such as a value that implements both of two interfaces or is null. Intersection groups require parentheses. The values null, false and true can also be standalone types.
Check assumptions in existing code
The migration guide records a separate behavior change: functions such as strtolower and strtoupper now use ASCII case conversion without consulting the locale. Code relying on locale-sensitive handling needs review; the guide points to MBString alternatives. str_split also returns an empty array for an empty string, rather than an array containing one empty string.
Discover more from Sulat AI & Tech News
Subscribe to get the latest posts sent to your email.




