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.

git-svn-id: https://develop.svn.wordpress.org/trunk@49194 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-10-18 17:31:37 +00:00
parent 97b2f07d2e
commit 422a9049b5
4 changed files with 5 additions and 5 deletions

View File

@ -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

View File

@ -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);

View File

@ -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;
}

View File

@ -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 );