Deprecated & Removed PHP Functions
debt(d3/e3/b5/t5)
Closest to 'default linter catches the common case' (d3). The term's detection_hints lists rector, phpstan, and php-deprecation-detector as tools that can catch deprecated function usage with automated=yes. These are standard tooling in modern PHP projects and catch deprecations reliably. Slightly better than d5 because PHPStan is increasingly default in PHP CI pipelines, though not as instant as a syntax error.
Closest to 'simple parameterised fix' (e3). The quick_fix states 'run rector/rector with PHP_80 PHP_83 sets to auto-migrate deprecated patterns' — rector can automatically transform most deprecated patterns to their modern equivalents. While some deprecated functions require manual thought (e.g., replacing mysql_* with PDO), most are straightforward replacements handled by automated tooling within a single component.
Closest to 'persistent productivity tax' (b5). Deprecated functions apply across all PHP contexts (web, cli, queue-worker per applies_to), creating ongoing maintenance weight. Legacy codebases with mysql_*, each(), or magic_quotes references require consistent attention during PHP upgrades. The burden isn't architectural (b7-b9) since replacements exist, but it's more than localised (b3) because deprecations accumulate across the entire codebase and block major version upgrades.
Closest to 'notable trap' (t5). The misconception field explicitly states: 'Deprecated means removed' — developers incorrectly believe deprecated functions no longer work, when in fact they still execute but emit E_DEPRECATED notices. Combined with common_mistakes noting that default PHP config hides these notices, developers don't realize their code is accumulating upgrade debt until they attempt a PHP version bump and face breaking changes.
Also Known As
TL;DR
Explanation
PHP evolves quickly; common removed functions include mysql_* (removed in PHP 7.0 — use PDO or mysqli), ereg_* (removed PHP 7.0 — use preg_*), create_function (removed PHP 8.0 — use closures), each() (removed PHP 8.0), and magic_quotes_* (removed PHP 7.4). Deprecated functions generate E_DEPRECATED warnings and will be removed in a future version. Regular audits with php -l, PHPStan, or PHP_CodeSniffer help identify usage. Static analysis tools can be configured to flag calls to known deprecated functions.
Common Misconception
Why It Matters
Common Mistakes
- Not running PHP with E_DEPRECATED enabled — deprecated calls produce no visible errors in default config.
- Using each(), reset(), current() in loops — deprecated in PHP 7.2 and removed later.
- Relying on magic_quotes, register_globals, or mysql_* functions in legacy codebases without an upgrade plan.
- Not checking the PHP migration guides before upgrading — each major version deprecates a significant list.
Code Examples
// Deprecated mysql_* functions — removed in PHP 7:
$conn = mysql_connect('localhost', 'user', 'pass');
$result = mysql_query('SELECT * FROM users', $conn);
while ($row = mysql_fetch_assoc($result)) { /* ... */ }
// Use mysqli or PDO instead
// PHP 7.x removals:
// mysql_*() → PDO or mysqli
// ereg() → preg_match()
// split() → explode() or preg_split()
// PHP 8.0 removals:
// each() → foreach / array_key_first()
// create_function() → anonymous function
// PHP 8.1 deprecations:
// Passing null to non-nullable params
// PHP 8.2 deprecations:
// Dynamic properties (use #[AllowDynamicProperties] or declare explicitly)
// PHP 8.4 deprecations:
// Implicitly nullable params: fn(string $s = null) → fn(string|null $s = null)
// Detect deprecations in CI:
error_reporting(E_ALL); // catches E_DEPRECATED
// PHPStan deprecation rules:
$ composer require --dev phpstan/phpstan-deprecation-rules