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

WordPress Trac noreply at wordpress.org
Mon Jan 30 15:22:31 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:"55163" 55163]:
 {{{
 #!CommitTicketReference repository="" revision="55163"
 Code Modernization: Allow some parameters with reserved keywords in `wp-
 includes/class-wp-text-diff-renderer-*.php`.

 This commit adds inline comments instructing PHPCS to ignore parameters
 with reserved keywords in the affected methods that should not be renamed:
 * `$string` parameter in `WP_Text_Diff_Renderer_inline::_splitOnWords()`
 * `$final` parameter in `WP_Text_Diff_Renderer_Table::_changed()` and
 `::interleave_changed_lines()`

 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
 It is recommended not to use reserved keyword "final" as function
 parameter name. Found: $final
 }}}

 The two `WP_Text_Diff_Renderer_*` classes in question extend the
 `Text_Diff_Renderer_inline` and `Text_Diff_Renderer` classes from the
 `Text_Diff` package and should have the same parameters as the parent
 class methods, per the Task 1 section of ticket #51553.

 The `Text_Diff` library currently included in WordPress core is no longer
 kept in sync with the upstream project and can be considered “adopted”, so
 the `$string` and `$final` parameters in the  parent class methods can
 technically be renamed, e.g. to `$input_string` and `$modified`,
 respectively.

 However, the “final” wording is also used to represent modified content in
 other parts the library, so it is more internally consistent to keep these
 parameters as is for now.

 Follow-up to [7747], [38352], [55136].

 See #56788.
 }}}

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


More information about the wp-trac mailing list