From 1faa241fb60ab370d8da9a3703d7cef85346360e Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 18 Oct 2020 17:33:07 +0000 Subject: [PATCH] Code Modernization: Use `instanceof` instead of a comparison with `get_class()`. Includes adjusting external libraries which are no longer maintained externally. Props jrf. See #50767. Built from https://develop.svn.wordpress.org/trunk@49194 git-svn-id: http://core.svn.wordpress.org/trunk@48956 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-pclzip.php | 4 ++-- wp-includes/Text/Diff.php | 2 +- wp-includes/class-json.php | 2 +- wp-includes/rest-api.php | 2 +- wp-includes/version.php | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/wp-admin/includes/class-pclzip.php b/wp-admin/includes/class-pclzip.php index 47f2a344a2..8a085f8bd0 100644 --- a/wp-admin/includes/class-pclzip.php +++ b/wp-admin/includes/class-pclzip.php @@ -1171,7 +1171,7 @@ $this->privErrorReset(); // ----- Look if the $p_archive is a PclZip object - if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip')) + if (is_object($p_archive) && $p_archive instanceof pclzip) { // ----- Duplicate the archive @@ -1235,7 +1235,7 @@ } // ----- Look if the $p_archive_to_add is a PclZip object - if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip')) + if (is_object($p_archive_to_add) && $p_archive_to_add instanceof pclzip) { // ----- Merge the archive diff --git a/wp-includes/Text/Diff.php b/wp-includes/Text/Diff.php index ab1c9a26dd..61a9320a0e 100644 --- a/wp-includes/Text/Diff.php +++ b/wp-includes/Text/Diff.php @@ -276,7 +276,7 @@ class Text_Diff { $prevtype = null; foreach ($this->_edits as $edit) { - if ($prevtype == get_class($edit)) { + if ($edit instanceof $prevtype) { trigger_error("Edit sequence is non-optimal", E_USER_ERROR); } $prevtype = get_class($edit); diff --git a/wp-includes/class-json.php b/wp-includes/class-json.php index 66443e1068..036150f1d8 100644 --- a/wp-includes/class-json.php +++ b/wp-includes/class-json.php @@ -918,7 +918,7 @@ class Services_JSON if (class_exists('pear')) { return PEAR::isError($data, $code); - } elseif (is_object($data) && (get_class($data) == 'services_json_error' || + } elseif (is_object($data) && ($data instanceof services_json_error || is_subclass_of($data, 'services_json_error'))) { return true; } diff --git a/wp-includes/rest-api.php b/wp-includes/rest-api.php index bbbeae3532..ed62943309 100644 --- a/wp-includes/rest-api.php +++ b/wp-includes/rest-api.php @@ -2390,7 +2390,7 @@ function rest_get_route_for_term( $term ) { $route = ''; // The only controller that works is the Terms controller. - if ( 'WP_REST_Terms_Controller' === get_class( $controller ) ) { + if ( $controller instanceof WP_REST_Terms_Controller ) { $namespace = 'wp/v2'; $rest_base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name; $route = sprintf( '/%s/%s/%d', $namespace, $rest_base, $term->term_id ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 87b0bddb7f..6f16837d5d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.6-alpha-49193'; +$wp_version = '5.6-alpha-49194'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.