Article
Migrating from PHP 8.1 to PHP 8.2
PHP 8.2 upgrade focus: dynamic properties deprecation, utf8_encode/decode, locale-insensitive string functions, and related breaks.
PHP 8.2 is currently in security support until 2026-12-31 (verified 2026-08-09). It is a common production target and the first version many teams meet dynamic-property noise. Sources: migration82, deprecated features.
Dynamic properties deprecated
Assigning undeclared properties on ordinary classes warns unless the class uses #[\AllowDynamicProperties]. stdClass remains exempt. Prefer declared properties—see dynamic properties and error guide.
# LEGACY
class User {}
$u = new User();
$u->email = 'a@example.com'; // deprecated in 8.2
# MODERN
class User {
public string $email;
}
$u = new User();
$u->email = 'a@example.com';
utf8_encode / utf8_decode
Both are deprecated in 8.2. Replace with mbstring/iconv appropriate conversions—detail page utf8_encode/decode.
Locale-insensitive casing
strtolower, strtoupper, and related functions now perform ASCII case conversion regardless of locale. Localized case folding belongs in mbstring APIs.
# MODERN intent for Unicode-aware lowercasing
$lower = mb_strtolower($name, 'UTF-8');
Other sharp edges
str_split('')returns[](was a one-element array of'')FilesystemIterator::SKIP_DOTSmust be set explicitly if you relied on old implicit behavior- Relative callables like
"self::method"are deprecated
Tools: deprecated checker, compatibility checker. Next: 8.2→8.3.
Related reading
- Composer Modernization Center Add Composer to legacy PHP projects, migrate includes to autoloading, set platform constraints, and replace a…
- PHP 5 to Modern PHP: Complete Incremental Migration Guide A deep, production-minded path from PHP 5.x codebases to supported PHP 8.x: removed extensions, charset, PDO,…
- PHP Security Modernization for Legacy Applications Upgrade inherited PHP security practices: prepared statements, password hashing, sessions, CSRF, XSS escaping…
- PHP 7 to PHP 8 Migration Guide Deep guide to PHP 8.0 breaking changes that matter for PHP 7 applications, with upgrade tactics through suppo…
- Inheriting a Legacy PHP Application A first-30-days playbook for developers handed an unfamiliar PHP codebase: runtime truth, risk triage, and sa…