Make WordPress Core

Changeset 51737


Ignore:
Timestamp:
09/07/2021 07:23:00 PM (5 years ago)
Author:
hellofromTonya
Message:

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

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 [32644], [32664], [32798], [38489], [49183], [49197].

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

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

Legend:

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

    r51735 r51737  
    652652         *
    653653         * @since 4.3.0
     654         * @since 5.9.0 Renamed `$comment` to `$item` to match parent class for PHP 8 named parameter support.
    654655         *
    655656         * @global string $comment_status Status for the current listed comments.
    656657         *
    657          * @param WP_Comment $comment     The comment object.
     658         * @param WP_Comment $item        The comment object.
    658659         * @param string     $column_name Current column name.
    659660         * @param string     $primary     Primary column name.
     
    662663         *                or if the current user cannot edit the comment.
    663664         */
    664         protected function handle_row_actions( $comment, $column_name, $primary ) {
     665        protected function handle_row_actions( $item, $column_name, $primary ) {
    665666                global $comment_status;
    666667
     
    673674                }
    674675
     676                // Restores the more descriptive, specific name for use within this method.
     677                $comment            = $item;
    675678                $the_comment_status = wp_get_comment_status( $comment );
    676679
  • trunk/src/wp-admin/includes/class-wp-links-list-table.php

    r51735 r51737  
    318318         *
    319319         * @since 4.3.0
    320          *
    321          * @param object $link        Link being acted upon.
     320         * @since 5.9.0 Renamed `$link` to `$item` to match parent class for PHP 8 named parameter support.
     321         *
     322         * @param object $item        Link being acted upon.
    322323         * @param string $column_name Current column name.
    323324         * @param string $primary     Primary column name.
     
    325326         *                if the current column is not the primary column.
    326327         */
    327         protected function handle_row_actions( $link, $column_name, $primary ) {
     328        protected function handle_row_actions( $item, $column_name, $primary ) {
    328329                if ( $primary !== $column_name ) {
    329330                        return '';
    330331                }
    331332
     333                // Restores the more descriptive, specific name for use within this method.
     334                $link      = $item;
    332335                $edit_link = get_edit_bookmark_link( $link );
    333336
  • trunk/src/wp-admin/includes/class-wp-media-list-table.php

    r51735 r51737  
    828828         *
    829829         * @since 4.3.0
    830          *
    831          * @param WP_Post $post        Attachment being acted upon.
     830         * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support.
     831         *
     832         * @param WP_Post $item        Attachment being acted upon.
    832833         * @param string  $column_name Current column name.
    833834         * @param string  $primary     Primary column name.
     
    835836         *                if the current column is not the primary column.
    836837         */
    837         protected function handle_row_actions( $post, $column_name, $primary ) {
     838        protected function handle_row_actions( $item, $column_name, $primary ) {
    838839                if ( $primary !== $column_name ) {
    839840                        return '';
     
    841842
    842843                $att_title = _draft_or_post_title();
    843 
    844                 return $this->row_actions( $this->_get_row_actions( $post, $att_title ) );
     844                $actions   = $this->_get_row_actions(
     845                        $item, // WP_Post object for an attachment.
     846                        $att_title
     847                );
     848
     849                return $this->row_actions( $actions );
    845850        }
    846851}
  • trunk/src/wp-admin/includes/class-wp-ms-sites-list-table.php

    r51735 r51737  
    669669         *
    670670         * @since 4.3.0
    671          *
    672          * @param array  $blog        Site being acted upon.
     671         * @since 5.9.0 Renamed `$blog` to `$item` to match parent class for PHP 8 named parameter support.
     672         *
     673         * @param array  $item        Site being acted upon.
    673674         * @param string $column_name Current column name.
    674675         * @param string $primary     Primary column name.
     
    676677         *                if the current column is not the primary column.
    677678         */
    678         protected function handle_row_actions( $blog, $column_name, $primary ) {
     679        protected function handle_row_actions( $item, $column_name, $primary ) {
    679680                if ( $primary !== $column_name ) {
    680681                        return '';
    681682                }
    682683
     684                // Restores the more descriptive, specific name for use within this method.
     685                $blog     = $item;
    683686                $blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
    684687
  • trunk/src/wp-admin/includes/class-wp-ms-users-list-table.php

    r51735 r51737  
    500500         *
    501501         * @since 4.3.0
    502          *
    503          * @param WP_User $user        User being acted upon.
     502         * @since 5.9.0 Renamed `$user` to `$item` to match parent class for PHP 8 named parameter support.
     503         *
     504         * @param WP_User $item        User being acted upon.
    504505         * @param string  $column_name Current column name.
    505506         * @param string  $primary     Primary column name.
     
    507508         *                if the current column is not the primary column.
    508509         */
    509         protected function handle_row_actions( $user, $column_name, $primary ) {
     510        protected function handle_row_actions( $item, $column_name, $primary ) {
    510511                if ( $primary !== $column_name ) {
    511512                        return '';
    512513                }
    513514
     515                // Restores the more descriptive, specific name for use within this method.
     516                $user         = $item;
    514517                $super_admins = get_super_admins();
    515518
  • trunk/src/wp-admin/includes/class-wp-posts-list-table.php

    r51735 r51737  
    14031403         *
    14041404         * @since 4.3.0
    1405          *
    1406          * @param WP_Post $post        Post being acted upon.
     1405         * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support.
     1406         *
     1407         * @param WP_Post $item        Post being acted upon.
    14071408         * @param string  $column_name Current column name.
    14081409         * @param string  $primary     Primary column name.
     
    14101411         *                if the current column is not the primary column.
    14111412         */
    1412         protected function handle_row_actions( $post, $column_name, $primary ) {
     1413        protected function handle_row_actions( $item, $column_name, $primary ) {
    14131414                if ( $primary !== $column_name ) {
    14141415                        return '';
    14151416                }
    14161417
     1418                // Restores the more descriptive, specific name for use within this method.
     1419                $post             = $item;
    14171420                $post_type_object = get_post_type_object( $post->post_type );
    14181421                $can_edit_post    = current_user_can( 'edit_post', $post->ID );
  • trunk/src/wp-admin/includes/class-wp-terms-list-table.php

    r51735 r51737  
    462462         *
    463463         * @since 4.3.0
    464          *
    465          * @param WP_Term $tag         Tag being acted upon.
     464         * @since 5.9.0 Renamed `$tag` to `$item` to match parent class for PHP 8 named parameter support.
     465         *
     466         * @param WP_Term $item        Tag being acted upon.
    466467         * @param string  $column_name Current column name.
    467468         * @param string  $primary     Primary column name.
     
    469470         *                if the current column is not the primary column.
    470471         */
    471         protected function handle_row_actions( $tag, $column_name, $primary ) {
     472        protected function handle_row_actions( $item, $column_name, $primary ) {
    472473                if ( $primary !== $column_name ) {
    473474                        return '';
    474475                }
    475476
     477                // Restores the more descriptive, specific name for use within this method.
     478                $tag      = $item;
    476479                $taxonomy = $this->screen->taxonomy;
    477480                $tax      = get_taxonomy( $taxonomy );
Note: See TracChangeset for help on using the changeset viewer.