Make WordPress Core


Ignore:
Timestamp:
04/05/2020 03:00:44 AM (5 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-user-query.php

    r47122 r47550  
    757757
    758758        $_orderby = '';
    759         if ( in_array( $orderby, array( 'login', 'nicename', 'email', 'url', 'registered' ) ) ) {
     759        if ( in_array( $orderby, array( 'login', 'nicename', 'email', 'url', 'registered' ), true ) ) {
    760760            $_orderby = 'user_' . $orderby;
    761         } elseif ( in_array( $orderby, array( 'user_login', 'user_nicename', 'user_email', 'user_url', 'user_registered' ) ) ) {
     761        } elseif ( in_array( $orderby, array( 'user_login', 'user_nicename', 'user_email', 'user_url', 'user_registered' ), true ) ) {
    762762            $_orderby = $orderby;
    763763        } elseif ( 'name' == $orderby || 'display_name' == $orderby ) {
     
    829829     */
    830830    public function __get( $name ) {
    831         if ( in_array( $name, $this->compat_fields ) ) {
     831        if ( in_array( $name, $this->compat_fields, true ) ) {
    832832            return $this->$name;
    833833        }
     
    844844     */
    845845    public function __set( $name, $value ) {
    846         if ( in_array( $name, $this->compat_fields ) ) {
     846        if ( in_array( $name, $this->compat_fields, true ) ) {
    847847            return $this->$name = $value;
    848848        }
     
    858858     */
    859859    public function __isset( $name ) {
    860         if ( in_array( $name, $this->compat_fields ) ) {
     860        if ( in_array( $name, $this->compat_fields, true ) ) {
    861861            return isset( $this->$name );
    862862        }
     
    871871     */
    872872    public function __unset( $name ) {
    873         if ( in_array( $name, $this->compat_fields ) ) {
     873        if ( in_array( $name, $this->compat_fields, true ) ) {
    874874            unset( $this->$name );
    875875        }
Note: See TracChangeset for help on using the changeset viewer.