PHP 8.2 stops getting security fixes on 31 December 2026. The dates are on the official PHP supported versions page.
I've already written about checking which version your site runs. This one is the next step: the warnings you'll actually see when you switch a copy of your site to PHP 8.4 or 8.5, and what to type to make them go away.
A deprecation isn't an error. The code still runs. PHP is just tapping you on the shoulder and saying "this goes in a future version". Ignore it and one day the tap becomes a slap.
I ran every example below on PHP 8.5 with error_reporting = E_ALL. The messages are copied from what PHP printed.
1. The sneaky nullable parameter (8.4)
```php function greet(string $name = null): string ```
PHP 8.4 and 8.5 say: Implicitly marking parameter $name as nullable is deprecated, the explicit nullable type must be used instead.
The fix is one question mark:
```php function greet(?string $name = null): string ```
Same behaviour. No warning. This is the one I see most in older code.
2. get_class() with nothing in the brackets (8.3)
```php return get_class(); ```
PHP says: Calling get_class() without arguments is deprecated.
Inside a class, use self::class (the class the code is written in) or static::class (the class of the object actually running it). If you meant the object, $this::class works too.
3. The long-winded casts (8.5)
```php $qty = (integer) $input; $paid = (boolean) $flag; ```
PHP 8.5 says: Non-canonical cast (integer) is deprecated, use the (int) cast instead, and the same for (boolean). (double) and (binary) are in the same boat.
Fix: (int), (bool), (float), (string). Shorter, too. Everyone wins.
4. Backticks that run shell commands (8.5)
```php
$out = echo hello;
```
Yes, that runs a shell command. Most people who find it in old code didn't know either.
PHP 8.5 says: The backtick (\`) operator is deprecated, use shell_exec() instead.
Fix: shell_exec('echo hello'). Then ask yourself whether you need to run a shell command from a web page at all. Often the honest answer is no.
5. trigger_error() with E_USER_ERROR (8.4)
```php trigger_error('Stock count missing', E_USER_ERROR); ```
PHP says: Passing E_USER_ERROR to trigger_error() is deprecated since 8.4, throw an exception or call exit with a string message instead.
Fix: throw an exception, which you can also catch and log properly:
```php throw new RuntimeException('Stock count missing'); ```
6. null as an array key (8.5)
```php $key = null; echo $prices[$key] ?? 'none'; ```
PHP 8.5 says: Using null as an array offset is deprecated, use an empty string instead.
This one usually means a value you expected to be set wasn't. Fix the cause where you can. If an empty-string key really is what you meant, say so: $prices[$key ?? ''].
The fixed version, all in one go
This runs on PHP 8.5 with every warning switched on and prints nothing but its output:
```php <?php declare(strict_types=1);
function greet(?string $name = null): string { return 'Hi ' . ($name ?? 'there'); }
final class Invoice { public function who(): string { return static::class; } }
$qty = (int) '42'; $paid = (bool) 1; $prices = ['' => 'no key given', 'tap' => 'in stock']; $key = null;
echo greet(), PHP_EOL; // Hi there echo (new Invoice)->who(), PHP_EOL; // Invoice var_dump($qty, $paid); // int(42) bool(true) echo $prices[$key ?? ''], PHP_EOL; // no key given
try { throw new RuntimeException('Stock count missing'); } catch (RuntimeException $e) { echo 'Caught: ', $e->getMessage(), PHP_EOL; } ```
How to find them all without guessing
- Copy the site to staging and switch the copy to PHP 8.4 or 8.5.
- Set
error_reporting = E_ALL,display_errors = Off,log_errors = Onin php.ini or your hosting panel. - Click through every page that takes money, bookings or enquiries.
- Read the log. Fix. Repeat.
The full lists are in the official migration guides: 8.3 deprecations, 8.4 deprecations and 8.5 deprecations.
If it makes money, it makes sense, and a patched website keeps making it. Seven weeks is plenty, if you start this week.
Which warning turned up most in your logs? I'd bet on number one.
There's more on modernising old code, with tested examples, in my book PHP Done The Correct Way: see the book page or get the paperback on Amazon UK. The free companion code is on PHP AIR too.