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_DOTS must 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