How a WordPress Web Development Company and User Can Prepare for PHP 8?

Released on November 26, 2020, PHP 8 is the next major update to the most-loved scripting language. Unlike previous versions that were lenient and did not have an adverse effect on the WordPress ecosystem, this new update shows some breaking changes that could affect backward compatibility. Besides, PHP 8 version has eliminated many features that were deprecated in PHP 7.x. Hence, a WordPress web development company and user need to look into what changes have been brought by the new version and how they can impact WordPress sites.

What is the Current Status of WordPress Core?

WordPress Core software officially aims to be compatible with PHP 8 in the 5.6 release which will be released on December 8, 2020. However, this doesn’t mean that upgrading to PHP 8 when 5.6 is released is safe. WordPress is dependent on one theme and a collection of plugins to function as a blog or website. It is possible to know the state of PHP 8 support within the larger ecosystem that includes themes, plugins, etc. Therefore, WordPress 5.6 is considered as beta compatible with PHP 8. This means that until most major plugins and themes are compatible with PHP 8, WordPress cannot be considered fully compatible with the version.

A WordPress development company and user need to get ready for the breaking changes that PHP 8 comes with.

The Most Worrisome Breaking Changes that PHP 8 Includes

Many WordPress plugin development companies like Yoast have been preparing for this major update for a little while now. Some of the breaking changes that the new version includes are:

i. Breaking Changes

1. PHP 8 uses much stricter typing on internal PHP

· Consistent type errors

· Arithmetic operator type checks

· Named parameters

· Magic methods type checks

· Numeric string handling

· API changes that might cause type errors

2. Warnings converted to error exceptions

· Reclassified engine warnings

· Error level changes unrelated to RFC’s

· Fatal error for incompatible method signatures

3. Default error reporting level

4. 7.x deprecation

ii. Compatibility Issues

1. Static analysis tools

· Scanning WordPress with PHPCompatibility

· Scanning WordPress with PHPStan

· Scanning WordPress with Exakat

2. Testing

· Getting the automated tests run on PHP 8

· Running the tests on PHP 8 for WP Core

· Code Coverage

3. Testing plugins and themes

· Unit tests

· Integration tests

4. Compatibility of external WordPress dependencies

5. Impact on the theme and plugin ecosystem


Besides these, where migrating from PHP 5.6 to PHP 7 was simple, moving from PHP 7.x to PHP 8 is very painful, especially for outdated codebases, like WordPress and many of its plugins. For well-typed codebases or codebases that are up-to-date with the latest PHP versions, there won’t be a big problem.

So, whether it is WordPress theme development or WordPress plugin development, developers must make sure that the WordPress themes and plugins are compatible with the PHP 8 version.

How to Prepare for PHP 8

Considering the drastic effects of PHP on the WordPress theme and plugin ecosystem, here are some of the ways by which a WordPress development company and user can follow to get ready for PHP 8. But before that, developers must first know and understand the breaking changes caused by PHP 8.

Tools that can be used to help look for compatibility issues:

  • Follow linting rules on the PHP 8 version over their code, either by using the php -l command, ensuring to iterate over all files, or via PHP Parallel Lint.

  • Run PHPCompatibility over their code. It’s worth noting that almost all PHP 8 related sniffs are in the upcoming version 10.0.0 of PHPCompatibility. So, users need to use the develop branch or via Composer dev-develop until version 10.0.0 is released.

  • Perform the unit or integration tests for the theme or plugin on PHP 8 and fix things that crop up as errors. For this, make sure that the test suite is first made compatible with PHPUnit 9.3+. The PHPUnit Polyfills package and WP Test Utils package, published under the Yoast GitHub organization, can help with this. It should also be noted that considerable test coverage is essential to make this reliable.

  • Perform the WordPress unit tests and WordPress e2e tests with your activated plugin, and then fix the issues that come up.

  • Make sure to check the ‘strict’ code coverage of the above-mentioned tests is high enough and if not, you can add more tests to achieve the maximum test coverage.

  • In case there are no tests, you can test everything manually, focusing more on the ‘unhappy paths’, and expect to get a more comprehensive bug report for a predictable future. Moreover, it is probably a good time to implement unit or integration tests for your theme or plugin to ensure flawless WordPress theme development and WordPress plugin development.

By implementing all these practices, a WordPress development company and user can make sure that the WordPress plugins and themes as well as outdated codebases are fully compatible with PHP 8 version.

Don’t Wait, for Now, is the Right Time

Presently, WordPress is only officially aiming to prepare for PHP 8 ready until 5.6 is released in early December. So, this means that most of the WordPress hosting companies are going to offer upgrades to their clients once WordPress core software is compatible. So, a WordPress web development company and user have some to test plugins and themes and get them ready. However, the time is running out, so the earlier you prepare the better.