[wp-trac] [WordPress Trac] #56788: PHP 8.0: improvements to allow for named parameters in WP 6.2

WordPress Trac noreply at wordpress.org
Wed Jan 25 01:39:15 UTC 2023


#56788: PHP 8.0: improvements to allow for named parameters in WP 6.2
-------------------------------------------+-----------------------------
 Reporter:  SergeyBiryukov                 |       Owner:  SergeyBiryukov
     Type:  task (blessed)                 |      Status:  accepted
 Priority:  normal                         |   Milestone:  6.2
Component:  General                        |     Version:
 Severity:  normal                         |  Resolution:
 Keywords:  php8 has-patch has-unit-tests  |     Focuses:
-------------------------------------------+-----------------------------

Comment (by SergeyBiryukov):

 In [changeset:"55136" 55136]:
 {{{
 #!CommitTicketReference repository="" revision="55136"
 Coding Standards: Allow some parameters with reserved keywords in `wp-
 includes/compat.php`.

 Parameter names for PHP polyfills in WordPress core need to 100% match the
 native PHP parameter names. Otherwise using named parameters with those
 functions could cause fatal errors for installations where the polyfills
 kick in.

 This commit adds inline comments instructing PHPCS to ignore parameters
 with reserved keywords in the affected functions that should not be
 renamed:
 * `$string` parameter in `mb_substr()` and `mb_strlen()`
 * `$array` parameter in `array_key_first()` and `array_key_last()`

 This resolves a few WPCS warnings along the lines of:
 {{{
 It is recommended not to use reserved keyword "string" as function
 parameter name. Found: $string
 }}}

 Follow-up to [7140], [10707], [17603], [17621], [32114], [52038], [53365].

 Props jrf.
 See #56788, #56791.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56788#comment:80>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list