Deprecation Notices & Migration Strategy
debt(d5/e5/b7/t7)
Closest to 'specialist tool catches it' (d5). The term's detection_hints.tools lists rector, phpstan, and psalm — all specialist static analysis tools. Deprecations do emit E_DEPRECATED at runtime, but only if error_reporting is configured correctly (a common mistake is suppressing them). They won't surface as compiler/syntax errors or via default linters, so d5 is the right anchor.
Closest to 'touches multiple files / significant refactor in one component' (e5). The quick_fix mentions running Rector to auto-fix deprecations, but common_mistakes highlight that ignoring deprecations across a codebase leads to accumulated changes spanning multiple files and components before a major version upgrade. While Rector automates some fixes, the overall migration process (auditing, fixing, verifying CI) across a full codebase is a multi-file effort, pushing it to e5 rather than e3.
Closest to 'strong gravitational pull' (b7). The why_it_matters field explicitly states that deprecations compound — each ignored notice becomes a potential breaking change at the next major release. This applies across both web and cli contexts (applies_to is broad). The structural weight is high because every future upgrade decision is shaped by the accumulated deprecation debt, and teams must constantly work around or address it.
Closest to 'serious trap' (t7). The misconception field states directly: 'Deprecation notices are just warnings — they can be safely ignored until the next major version.' This contradicts how deprecations actually behave (they become breaking changes), and developers familiar with other ecosystems where warnings are truly advisory will be misled. The common mistake of suppressing E_DEPRECATED reinforces this trap, making it a serious cognitive hazard that contradicts reasonable expectations.
TL;DR
Explanation
PHP uses E_DEPRECATED to warn that a function, parameter, or behaviour will be removed in a future version. E_USER_DEPRECATED is the user-land equivalent. In PHP 8.x, many PHP 7.x patterns trigger deprecations (dynamic properties, ${} string interpolation, implicitly nullable parameters). Best practice: set error_reporting(E_ALL) in dev to surface them, use PHPStan/Psalm to catch them statically, and use Rector to auto-fix them. Run php -d error_reporting=32767 in CI to catch all notices. Never suppress deprecations with @.
Common Misconception
Why It Matters
Common Mistakes
- Suppressing deprecations with @ operator or error_reporting(~E_DEPRECATED).
- Not running Rector to auto-fix deprecations before upgrades.
- Upgrading PHP major versions without first eliminating all deprecations on the previous version.
Code Examples
// PHP 8.2: Dynamic properties deprecated
class User {
// No typed properties defined
}
$u = new User();
$u->name = 'Paul'; // Deprecated: Creation of dynamic property
// Fix: declare the property explicitly
class User {
public string $name = '';
}
// Or add attribute to acknowledge intentional dynamic properties (PHP 8.2+):
#[\AllowDynamicProperties]
class LegacyUser {}