DEV Community

Felipe Elia
Felipe Elia

Posted on • Originally published at felipeelia.dev

Will PHP 7.2 be the minimum required version for WP 6.2?

Yes, this is real! It seems that starting from WordPress 6.2 the minimum PHP version required by WP will be 7.2. The last change in that aspect of the software was made in May 2019, for WordPress 5.2.

The update did not happen before because the team set 5% as the maximum threshold of version usage. According to this ticket, PHP 5.6 usage finally dropped below that. As PHP doesn't have version 6 and versions 7.0 and 7.1 have usage numbers even lower, the minimum version would be bumped to PHP 7.2. The numbers are also available on the Stats page of WP.org.

As of 17 Dec 2022 [...]:

PHP 5.6 is at 4.99% of all WordPress sites
PHP 7.0 is at 2.68%
PHP 7.1 is at 1.82%

https://core.trac.wordpress.org/ticket/57345

WordPress and PHP's timeline

To increase backward compatibility, WordPress adopts a strict policy regarding minimum PHP versions. PHP 5.2, for example, had its final version released in January 2011 but it was supported by WP until 2019.

PHP 5.6 reached its end of life in December 2018 and today, 4 years later, it is still the minimum required version by WordPress. If the change really happens, we will be still behind: PHP 7.2 saw its last version released in November 2020, two years ago.

Out of curiosity, while I write this post, the oldest version still receiving updates is PHP 8.0, with end-of-life planned for November 2023. The latest version, 8.2, was released this month and will receive security updates until December 2025.

PHP End Of Life End of Support By WP
PHP 5.2 01/2011 05/2019 (WP 5.2)
PHP 5.6 12/2018 ??/2023 (WP 6.2)
PHP 7.2 11/2020
PHP 8.0 (current version) 11/2023

What the PHP version changes for WordPress

Beyond improvements in security and speed, changing the PHP version also makes available a set of new features, modernizing the codebase and decreasing the chances of bugs.

You can see the full list of features that would be available in these three links: PHP 7.0, PHP 7.1, and PHP 7.2. Below you can see just some examples of what we would get just setting PHP 7.0 as the minimum:

Return type declarations

Since PHP 7.0 it is possible to declare the type returned by a function or method:

function example( array ...$arrays ): array {}

Although it is common in some other languages, type declarations (for parameters and return) can be something new to some.

The biggest advantage of this feature is static analysis of code: even without executing the code, it is possible to identify if example() is being called without expecting an array. If that is the case, the error can be detected and fixed before any other test is executed.

The majority of IDEs already have that function built in nowadays.

Null coalescing operator (??)

Instead of writing

$username = isset( $_GET['user'] ) ? $_GET['user'] : 'nobody';

it would be possible to write its simplified version:

$username = $_GET['user'] ?? 'nobody';

Spaceship operator (<=>)

Commonly used for comparison functions, this operator returns -1, 0, or 1 depending on the comparison result.

echo 1 <=> 1; // 0
echo 1 <=> 2; // -1
echo 2 <=> 1; // 1

PHP 8 Compatibility and WordPress Versions

Keeping compatibility with a so wide range of versions makes things harder. Compatibility with PHP 8 (8.0, 8.1, and 8.2) is still in Beta. Will dropping support to PHP 5.6 give enough room to focus on PHP 8.x? Let's hope so!

And you, did you already update your PHP site version?

Top comments (3)

Collapse
 
tw2113 profile image
Michael Beckwith

Not set in stone, but would be a great step forward. Abandoning 7.4 would be a HUGE step backwards at this point, thus why 7.2 is chosen.

Collapse
 
felipeelia profile image
Felipe Elia

Yeah but even if we just raise it to 7.0 I'd already consider it a win (and also an indicator to both developer and admin users that WP is trying to keep up with PHP versions and that is something they need to pay attention to.) Thanks for the comment :)

Collapse
 
calliko profile image
Токмаков Александр

Обновил до 8.1