Commit 9a6f484
committed
Fix: PHP 8.0 named parameters compatibility — Tasks 1, 2, 3, and 4
Task 1: Fix reserved keyword parameter names in Core
- Rename wp_is_valid_utf8() fallback branch parameter from $string to $bytes
(utf8.php:51) to match the primary branch and ensure consistency for
PHP 8.0+ named argument callers.
Task 2: Align child class parameter names with abstract parent signatures
- Rename prepare_item_for_response() first parameter to $item in child
controllers to match WP_REST_Controller::prepare_item_for_response($item):
class-wp-rest-abilities-v1-categories-controller.php ($category → $item),
class-wp-rest-abilities-v1-list-controller.php ($ability → $item),
class-wp-rest-global-styles-controller.php ($post → $item),
class-wp-rest-global-styles-revisions-controller.php ($post → $item),
class-wp-rest-menus-controller.php ($term → $item).
Task 3: Audit and wrap call_user_func_array() usage in Core
- Introduce wp_normalize_call_user_func_args() in load.php to strip string
keys from argument arrays before they reach call_user_func_array(), preventing
PHP 8.0+ from misinterpreting them as named arguments.
- Wrap dynamic callback calls where $args could contain non-integer keys:
class-wp-hook.php, class-wp-customize-widgets.php, class-wp-image-editor.php,
class-wp-rest-widgets-controller.php, functions.php, widgets.php, and
wp-admin dispatch sites (ajax-actions, class-wp-screen, dashboard, media,
post, widgets, widgets-form).
- Add a safety comment to class-wp-block-bindings-source.php:86 documenting
why its call_user_func_array() does not need wrapping.
Task 4: Escalate PHPCS rule to error severity
- Update phpcs.xml.dist to escalate
Universal.NamingConventions.NoReservedKeywordParameterNames from warning to
error, preventing future reserved keyword parameter names (string, list,
array, etc.) that break PHP 8.0+ named argument syntax.
See: https://core.trac.wordpress.org/ticket/596491 parent e12ddb3 commit 9a6f484
File tree
22 files changed
+101
-65
lines changed- src
- wp-admin
- includes
- wp-includes
- rest-api/endpoints
22 files changed
+101
-65
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
370 | 379 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2432 | 2432 | | |
2433 | 2433 | | |
2434 | 2434 | | |
2435 | | - | |
| 2435 | + | |
2436 | 2436 | | |
2437 | 2437 | | |
2438 | 2438 | | |
| |||
2451 | 2451 | | |
2452 | 2452 | | |
2453 | 2453 | | |
2454 | | - | |
| 2454 | + | |
2455 | 2455 | | |
2456 | 2456 | | |
2457 | 2457 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
913 | 913 | | |
914 | 914 | | |
915 | 915 | | |
916 | | - | |
| 916 | + | |
917 | 917 | | |
918 | 918 | | |
919 | 919 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1212 | 1212 | | |
1213 | 1213 | | |
1214 | 1214 | | |
1215 | | - | |
| 1215 | + | |
1216 | 1216 | | |
1217 | 1217 | | |
1218 | 1218 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
635 | 635 | | |
636 | 636 | | |
637 | 637 | | |
638 | | - | |
| 638 | + | |
639 | 639 | | |
640 | 640 | | |
641 | 641 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
437 | 437 | | |
438 | 438 | | |
439 | 439 | | |
440 | | - | |
| 440 | + | |
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
276 | | - | |
| 276 | + | |
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
180 | | - | |
| 180 | + | |
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
293 | | - | |
| 293 | + | |
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1631 | 1631 | | |
1632 | 1632 | | |
1633 | 1633 | | |
1634 | | - | |
| 1634 | + | |
1635 | 1635 | | |
1636 | 1636 | | |
1637 | 1637 | | |
| |||
1677 | 1677 | | |
1678 | 1678 | | |
1679 | 1679 | | |
1680 | | - | |
| 1680 | + | |
1681 | 1681 | | |
1682 | 1682 | | |
1683 | 1683 | | |
| |||
0 commit comments