Make WordPress Core

Ticket #50767: 50767-use-self-when-appropriate.patch

File 50767-use-self-when-appropriate.patch, 1.5 KB (added by jrf, 4 years ago)

CS: use self when appropriate * get_default_primary_column_name() is a protected method, so calling it statically with the class name is bad practice. * Similarly this applies when calling a private constructor.

  • src/wp-admin/includes/class-wp-list-table.php

    From 20552710463aa9750da5e556e4206926b83d9c7f Mon Sep 17 00:00:00 2001
    From: jrfnl <jrfnl@users.noreply.github.com>
    Date: Sun, 18 Oct 2020 05:56:59 +0200
    Subject: [PATCH] CS: use `self` when appropriate
    
    * `get_default_primary_column_name()` is a protected method, so calling it statically with the class name is bad practice.
    * Similarly this applies when calling a `private` constructor.
    ---
     src/wp-admin/includes/class-wp-list-table.php | 2 +-
     src/wp-admin/includes/class-wp-screen.php     | 2 +-
     2 files changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/src/wp-admin/includes/class-wp-list-table.php b/src/wp-admin/includes/class-wp-list-table.php
    index 0b20f6be0c..485338e630 100644
    a b class WP_List_Table { 
    10441044                // If the primary column doesn't exist,
    10451045                // fall back to the first non-checkbox column.
    10461046                if ( ! isset( $columns[ $default ] ) ) {
    1047                         $default = WP_List_Table::get_default_primary_column_name();
     1047                        $default = self::get_default_primary_column_name();
    10481048                }
    10491049
    10501050                /**
  • src/wp-admin/includes/class-wp-screen.php

    diff --git a/src/wp-admin/includes/class-wp-screen.php b/src/wp-admin/includes/class-wp-screen.php
    index 57077ed299..9464fabe05 100644
    a b final class WP_Screen { 
    377377                                return $screen;
    378378                        }
    379379                } else {
    380                         $screen     = new WP_Screen();
     380                        $screen     = new self();
    381381                        $screen->id = $id;
    382382                }
    383383