Runtime Briefing — PHP 8.2 Introduces Readonly Classes
PHP 8.2.0 went GA on 8 December 2022 with readonly classes, standalone true/false/null types, and dynamic property deprecation, requiring application teams to validate language changes and extension support.
Executive briefing: The PHP project released PHP 8.2.0 on , continuing rapid language evolution focused on stronger typing and developer ergonomics.
Feature highlights
- Readonly classes. Entire classes can now be declared readonly, locking down properties for domain models.
- Standalone types.
true,false, andnullmay be used as dedicated type declarations, improving API contracts. - SensitiveParameter attribute. Built-in attribute redacts secrets from stack traces and logs.
- Dynamic property deprecation. Accessing undeclared properties triggers deprecation notices ahead of PHP 9 removals.
Adoption steps
- Update Composer constraints and ensure framework dependencies (Laravel, Symfony, WordPress) publish PHP 8.2-compatible releases.
- Run application test suites with
error_reporting=E_ALLto uncover dynamic property usage that must be refactored. - Enable the
SensitiveParameterattribute for logging middleware handling credentials or tokens.