Skip to content

Conversation

@rodrigoprimo
Copy link
Collaborator

@rodrigoprimo rodrigoprimo commented Dec 12, 2025

I checked the WordPress src/wp-includes/compat.php file for new polyfills that should be added, and here is what I found that was missing in this repository:

WP 6.5 added polyfills for:

WP 6.8 added polyfills for:

WP 6.9 added polyfills for:

Note: The IMAGETYPE_AVIF and IMAGETYPE_HEIF constants are not yet flagged by PHPCompatibility. Since excluding error codes that don't exist yet doesn't trigger errors in PHPCS, we may as well add the exclusions proactively. Unless I'm missing something, I believe PHPCompatibility should be updated to check for these constants. I can prepare a PR for PHPCompatibility to start checking for those constants if that helps.

Note: WP 6.9 also added polyfills for utf8_encode() and utf8_decode(), which were deprecated in PHP 8.2 and will be removed in PHP 9.0. These are intentionally not excluded here, as these functions are deprecated and developers should migrate to mb_convert_encoding(). My understanding is that the WordPress polyfill exists for backward compatibility with legacy code, but PHPCompatibility should still warn about their usage.

Previous PR updating the list of polyfills: #55

@jrfnl
Copy link
Member

jrfnl commented Dec 12, 2025

@rodrigoprimo Thanks for this PR.

Could you please add links to the WP Trac tickets + changesets for each of these changes to the commit message + the PR description to justify these changes and to make reviewing this PR more straight-forward ?

Note: The IMAGETYPE_AVIF and IMAGETYPE_HEIF constants are not yet flagged by PHPCompatibility. Unless I'm missing something, I believe PHPCompatibility should be updated to check for these constants. I can prepare a PR for PHPCompatibility to start checking for those constants if that helps.

Yes it should. Not sure why these are missing, could be that they are part of a larger RFC which hasn't been addressed yet, could be that PHP Core forgot to mention them in the UPGRADING guide/migration guide.

Feel free to open a PR, but please be aware that this will need tracing the changes back to their origins in PHP Core repo to justify the changes.

Note: WP 6.9 also added polyfills for utf8_encode() and utf8_decode(), which were deprecated in PHP 8.2 and will be removed in PHP 9.0. These are intentionally not excluded here, as these functions are deprecated and developers should migrate to mb_convert_encoding(). My understanding is that the WordPress polyfill exists for backward compatibility with legacy code, but PHPCompatibility should still warn about their usage.

Ah, yes, those WP polyfills are laughable as they a) shouldn't exist, b) never polyfill on any known PHP version, so are completely redundant until PHP 9.0 would be released....

Agreed to not exclude the error message related to those.

I checked the WordPress src/wp-includes/compat.php file for new polyfills that should be added and here is what I found that was missing in this repository:

WP 6.5 added polyfills for:
  * `IMAGETYPE_AVIF` and `IMG_AVIF` constants, which were introduced in PHP 8.1. See https://core.trac.wordpress.org/ticket/51228 and https://core.trac.wordpress.org/changeset/57524.

WP 6.8 added polyfills for:
  * `array_find()`, `array_find_key()`, `array_any()` and `array_all()`, which were introduced in PHP 8.4. See https://core.trac.wordpress.org/ticket/62558 and https://core.trac.wordpress.org/changeset/59783.

WP 6.9 added polyfills for:
  * `array_first()` and `array_last()`, which were introduced in PHP 8.5. See https://core.trac.wordpress.org/ticket/63853 and https://core.trac.wordpress.org/changeset/60672.
  * `IMAGETYPE_HEIF` constant, which was introduced in PHP 8.5. See https://core.trac.wordpress.org/ticket/64322 and https://core.trac.wordpress.org/changeset/61328.

Note: The `IMAGETYPE_AVIF` and `IMAGETYPE_HEIF` constants are not yet flagged by PHPCompatibility. Since excluding error codes that don't exist yet doesn't trigger errors in PHPCS, we may as well add the exclusions proactively. Unless I'm missing something, I believe PHPCompatibility should be updated to check for these constants.

Note: WP 6.9 also added polyfills for `utf8_encode()` and `utf8_decode()`, which were deprecated in PHP 8.2 and will be removed in PHP 9.0. These are intentionally not excluded here, as these functions are deprecated and developers should migrate to `mb_convert_encoding()`. My understanding is that the WordPress polyfill exists for backward compatibility with legacy code, but PHPCompatibility should still warn about their usage.
@rodrigoprimo
Copy link
Collaborator Author

Thanks for your feedback, @jrfnl!

Could you please add links to the WP Trac tickets + changesets for each of these changes to the commit message + the PR description to justify these changes and to make reviewing this PR more straight-forward ?

Done

Feel free to open a PR, but please be aware that this will need tracing the changes back to their origins in PHP Core repo to justify the changes.

Here is the PR PHPCompatibility/PHPCompatibility#2022

@jrfnl jrfnl added this to the 3.0.0-alpha2 milestone Dec 15, 2025
Copy link
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @rodrigoprimo !

@jrfnl jrfnl merged commit b423e71 into PHPCompatibility:master Dec 16, 2025
5 checks passed
@rodrigoprimo rodrigoprimo deleted the update-function-list branch December 16, 2025 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants