mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-01 11:14:36 +00:00
Coding Standards: Use strict type check for in_array() and array_search() where strings are involved.
This reduces the number of `WordPress.PHP.StrictInArray.MissingTrueStrict` issues from 486 to 50. Includes minor code layout fixes for better readability. See #49542. git-svn-id: https://develop.svn.wordpress.org/trunk@47550 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -206,7 +206,9 @@ final class WP_Theme implements ArrayAccess {
|
||||
$this->stylesheet = $theme_dir;
|
||||
|
||||
// Correct a situation where the theme is 'some-directory/some-theme' but 'some-directory' was passed in as part of the theme root instead.
|
||||
if ( ! in_array( $theme_root, (array) $wp_theme_directories ) && in_array( dirname( $theme_root ), (array) $wp_theme_directories ) ) {
|
||||
if ( ! in_array( $theme_root, (array) $wp_theme_directories, true )
|
||||
&& in_array( dirname( $theme_root ), (array) $wp_theme_directories, true )
|
||||
) {
|
||||
$this->stylesheet = basename( $this->theme_root ) . '/' . $this->stylesheet;
|
||||
$this->theme_root = dirname( $theme_root );
|
||||
}
|
||||
@@ -475,7 +477,7 @@ final class WP_Theme implements ArrayAccess {
|
||||
'theme_root_uri',
|
||||
);
|
||||
|
||||
return in_array( $offset, $properties );
|
||||
return in_array( $offset, $properties, true );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -574,7 +576,7 @@ final class WP_Theme implements ArrayAccess {
|
||||
'Parent Theme',
|
||||
);
|
||||
|
||||
return in_array( $offset, $keys );
|
||||
return in_array( $offset, $keys, true );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -661,7 +663,7 @@ final class WP_Theme implements ArrayAccess {
|
||||
* @return bool Whether the theme exists.
|
||||
*/
|
||||
public function exists() {
|
||||
return ! ( $this->errors() && in_array( 'theme_not_found', $this->errors()->get_error_codes() ) );
|
||||
return ! ( $this->errors() && in_array( 'theme_not_found', $this->errors()->get_error_codes(), true ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1029,7 +1031,7 @@ final class WP_Theme implements ArrayAccess {
|
||||
* @return string Absolute path of the stylesheet directory.
|
||||
*/
|
||||
public function get_stylesheet_directory() {
|
||||
if ( $this->errors() && in_array( 'theme_root_missing', $this->errors()->get_error_codes() ) ) {
|
||||
if ( $this->errors() && in_array( 'theme_root_missing', $this->errors()->get_error_codes(), true ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user