WordPress.org

Make WordPress Core

Changeset 51735


Ignore:
Timestamp:
09/07/2021 06:18:10 PM (3 months ago)
Author:
hellofromTonya
Message:

Code Modernization: Fix parameter name mismatches for parent/child classes in WP_List_Table::column_cb().

Matches the method signatures of the parent class and each child class.

Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

For readability:

  • @since clearly specifies the original parameter name and its new name as well as why the change happened
  • in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.

Follow-up to [15632], [30679], [31210], [32740], [32753], [32754], [32755], [32756], [32757].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.

Location:
trunk/src/wp-admin/includes
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-comments-list-table.php

    r51734 r51735  
    869869
    870870    /**
    871      * @param WP_Comment $comment The comment object.
    872      */
    873     public function column_cb( $comment ) {
     871     * @since 5.9.0 Renamed `$comment` to `$item` to match parent class for PHP 8 named parameter support.
     872     *
     873     * @param WP_Comment $item The comment object.
     874     */
     875    public function column_cb( $item ) {
     876        // Restores the more descriptive, specific name for use within this method.
     877        $comment = $item;
     878
    874879        if ( $this->user_can ) {
    875880            ?>
  • trunk/src/wp-admin/includes/class-wp-links-list-table.php

    r51734 r51735  
    167167     *
    168168     * @since 4.3.0
    169      *
    170      * @param object $link The current link object.
    171      */
    172     public function column_cb( $link ) {
     169     * @since 5.9.0 Renamed `$link` to `$item` to match parent class for PHP 8 named parameter support.
     170     *
     171     * @param object $item The current link object.
     172     */
     173    public function column_cb( $item ) {
     174        // Restores the more descriptive, specific name for use within this method.
     175        $link = $item;
     176
    173177        ?>
    174178        <label class="screen-reader-text" for="cb-select-<?php echo $link->link_id; ?>">
  • trunk/src/wp-admin/includes/class-wp-media-list-table.php

    r51734 r51735  
    388388     *
    389389     * @since 4.3.0
    390      *
    391      * @param WP_Post $post The current WP_Post object.
    392      */
    393     public function column_cb( $post ) {
     390     * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support.
     391     *
     392     * @param WP_Post $item The current WP_Post object.
     393     */
     394    public function column_cb( $item ) {
     395        // Restores the more descriptive, specific name for use within this method.
     396        $post = $item;
     397
    394398        if ( current_user_can( 'edit_post', $post->ID ) ) {
    395399            ?>
  • trunk/src/wp-admin/includes/class-wp-ms-sites-list-table.php

    r51734 r51735  
    397397     *
    398398     * @since 4.3.0
    399      *
    400      * @param array $blog Current site.
    401      */
    402     public function column_cb( $blog ) {
     399     * @since 5.9.0 Renamed `$blog` to `$item` to match parent class for PHP 8 named parameter support.
     400     *
     401     * @param array $item Current site.
     402     */
     403    public function column_cb( $item ) {
     404        // Restores the more descriptive, specific name for use within this method.
     405        $blog = $item;
     406
    403407        if ( ! is_main_site( $blog['blog_id'] ) ) :
    404408            $blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
  • trunk/src/wp-admin/includes/class-wp-ms-themes-list-table.php

    r51734 r51735  
    506506     *
    507507     * @since 4.3.0
    508      *
    509      * @param WP_Theme $theme The current WP_Theme object.
    510      */
    511     public function column_cb( $theme ) {
     508     * @since 5.9.0 Renamed `$theme` to `$item` to match parent class for PHP 8 named parameter support.
     509     *
     510     * @param WP_Theme $item The current WP_Theme object.
     511     */
     512    public function column_cb( $item ) {
     513        // Restores the more descriptive, specific name for use within this method.
     514        $theme       = $item;
    512515        $checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) );
    513516        ?>
  • trunk/src/wp-admin/includes/class-wp-ms-users-list-table.php

    r51734 r51735  
    228228     *
    229229     * @since 4.3.0
    230      *
    231      * @param WP_User $user The current WP_User object.
    232      */
    233     public function column_cb( $user ) {
     230     * @since 5.9.0 Renamed `$user` to `$item` to match parent class for PHP 8 named parameter support.
     231     *
     232     * @param WP_User $item The current WP_User object.
     233     */
     234    public function column_cb( $item ) {
     235        // Restores the more descriptive, specific name for use within this method.
     236        $user = $item;
     237
    234238        if ( is_super_admin( $user->ID ) ) {
    235239            return;
  • trunk/src/wp-admin/includes/class-wp-posts-list-table.php

    r51734 r51735  
    972972     *
    973973     * @since 4.3.0
    974      *
    975      * @param WP_Post $post The current WP_Post object.
    976      */
    977     public function column_cb( $post ) {
     974     * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support.
     975     *
     976     * @param WP_Post $item The current WP_Post object.
     977     */
     978    public function column_cb( $item ) {
     979        // Restores the more descriptive, specific name for use within this method.
     980        $post = $item;
    978981        $show = current_user_can( 'edit_post', $post->ID );
    979982
  • trunk/src/wp-admin/includes/class-wp-terms-list-table.php

    r51734 r51735  
    365365
    366366    /**
    367      * @param WP_Term $tag Term object.
     367     * @since 5.9.0 Renamed `$tag` to `$item` to match parent class for PHP 8 named parameter support.
     368     *
     369     * @param WP_Term $item Term object.
    368370     * @return string
    369371     */
    370     public function column_cb( $tag ) {
     372    public function column_cb( $item ) {
     373        // Restores the more descriptive, specific name for use within this method.
     374        $tag = $item;
     375
    371376        if ( current_user_can( 'delete_term', $tag->term_id ) ) {
    372377            return sprintf(
Note: See TracChangeset for help on using the changeset viewer.