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:
Sergey Biryukov
2020-04-05 03:00:44 +00:00
parent 2e589142eb
commit 0b4e2c4604
140 changed files with 584 additions and 484 deletions

View File

@@ -181,7 +181,7 @@ class WP_List_Table {
* @return mixed Property.
*/
public function __get( $name ) {
if ( in_array( $name, $this->compat_fields ) ) {
if ( in_array( $name, $this->compat_fields, true ) ) {
return $this->$name;
}
}
@@ -196,7 +196,7 @@ class WP_List_Table {
* @return mixed Newly-set property.
*/
public function __set( $name, $value ) {
if ( in_array( $name, $this->compat_fields ) ) {
if ( in_array( $name, $this->compat_fields, true ) ) {
return $this->$name = $value;
}
}
@@ -210,7 +210,7 @@ class WP_List_Table {
* @return bool Whether the property is set.
*/
public function __isset( $name ) {
if ( in_array( $name, $this->compat_fields ) ) {
if ( in_array( $name, $this->compat_fields, true ) ) {
return isset( $this->$name );
}
}
@@ -223,7 +223,7 @@ class WP_List_Table {
* @param string $name Property to unset.
*/
public function __unset( $name ) {
if ( in_array( $name, $this->compat_fields ) ) {
if ( in_array( $name, $this->compat_fields, true ) ) {
unset( $this->$name );
}
}
@@ -238,7 +238,7 @@ class WP_List_Table {
* @return mixed|bool Return value of the callback, false otherwise.
*/
public function __call( $name, $arguments ) {
if ( in_array( $name, $this->compat_methods ) ) {
if ( in_array( $name, $this->compat_methods, true ) ) {
return $this->$name( ...$arguments );
}
return false;
@@ -1133,13 +1133,13 @@ class WP_List_Table {
foreach ( $columns as $column_key => $column_display_name ) {
$class = array( 'manage-column', "column-$column_key" );
if ( in_array( $column_key, $hidden ) ) {
if ( in_array( $column_key, $hidden, true ) ) {
$class[] = 'hidden';
}
if ( 'cb' === $column_key ) {
$class[] = 'check-column';
} elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) {
} elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ), true ) ) {
$class[] = 'num';
}
@@ -1329,7 +1329,7 @@ class WP_List_Table {
$classes .= ' has-row-actions column-primary';
}
if ( in_array( $column_name, $hidden ) ) {
if ( in_array( $column_name, $hidden, true ) ) {
$classes .= ' hidden';
}