Cloudflare-WordPress icon indicating copy to clipboard operation
Cloudflare-WordPress copied to clipboard

Support for PHP 8

Open Korben00 opened this issue 11 months ago • 7 comments

Description

This pull request includes updates to transition the project's PHP support to version 8.0. These changes are necessary to ensure the project stays compatible with the latest PHP version, providing improved performance, security, and newer language features. The update involves modifications to composer.json, composer.lock, and readme.txt files, alongside code adjustments in src/Integration/DefaultLogger.php to align with PHP 8 standards.

Changes

1. composer.json and composer.lock:

  • Updated PHP requirement to "php": "8.0".
  • Upgraded dependencies to their PHP 8 compatible versions. This includes major version upgrades for packages such as symfony/yaml from ^2.6 to ^5.3, phpunit/phpunit from * to ^9.3, and psr/log from ^1.0 to ^3.0, among others.
  • Adjusted platform config setting to PHP 8.0, ensuring consistency across development and production environments.

2. src/Integration/DefaultLogger.php:

  • Implemented type declarations and return type void for methods log and debug to comply with the PHP 8 standards.
  • Replaced array notation with [] for default parameter values and function return types.
  • Introduced Stringable|string for $message parameter type hinting, leveraging PHP 8's union types and promoting more flexible logging capabilities.

3. readme.txt:

  • Updated the "Requires PHP" version to 8.0 to inform users and contributors about the new PHP version requirement.

Korben00 avatar Mar 06 '24 17:03 Korben00

  • Resolves #490
  • Resolves #470
  • Resolves #445
  • Resolves #528
  • Closes Cloudflare case 3130507

LeoColomb avatar Mar 07 '24 13:03 LeoColomb

Mentioning @aseure, just in case 😊

LeoColomb avatar Mar 10 '24 11:03 LeoColomb

Any time to review ?

Korben00 avatar Mar 21 '24 15:03 Korben00

Hey @Korben00 and @LeoColomb.

Thank you very much for the contribution and your time here.

While we would like to better support PHP 8 in the future, an important user base of this plugin is using PHP 7 installation. Even though this version is indeed outdated, and many Wordpress users would gladly upgrade to PHP 8 (or already did), a non-negligible amount of users will still be using PHP 7 (either because they don't know how to upgrade or because their hosted Wordpress will not upgrade). Due to this and the fact that most users have the plugin auto-upgrade setting enable, I'm concerned about breaking their installations.

I'll let @jacobbednarz comment on this, who perhaps have more insights than I have on this. cc @william-woodhead as well.

aseure avatar Mar 25 '24 10:03 aseure

Indeed, standard practice still today is to keep at least PHP 7.4 in play.

lkraav avatar Mar 25 '24 10:03 lkraav

@aseure @lkraav Thanks for your replies. While I'm personally not a big fan of standard practices actually specific to WordPress, I understand the reasoning. 😊

Thus, we've just submitted another PR (#541) which does not touch the platform version but allows working around the compatibility/conflict issue with the dependencies.

LeoColomb avatar Mar 25 '24 11:03 LeoColomb

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Sep 22 '24 02:09 github-actions[bot]