Make WordPress Core


Ignore:
Timestamp:
04/05/2020 03:00:44 AM (6 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/post-template.php

    r47219 r47550  
    10331033                $url = get_permalink();
    10341034        } else {
    1035                 if ( '' == get_option( 'permalink_structure' ) || in_array( $post->post_status, array( 'draft', 'pending' ) ) ) {
     1035                if ( '' == get_option( 'permalink_structure' ) || in_array( $post->post_status, array( 'draft', 'pending' ), true ) ) {
    10361036                        $url = add_query_arg( 'page', $i, get_permalink() );
    10371037                } elseif ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post->ID ) {
     
    13961396        $args     = wp_parse_args( $args, $defaults );
    13971397
    1398         if ( ! in_array( $args['item_spacing'], array( 'preserve', 'discard' ) ) ) {
     1398        if ( ! in_array( $args['item_spacing'], array( 'preserve', 'discard' ), true ) ) {
    13991399                // Invalid value, fall back to default.
    14001400                $args['item_spacing'] = $defaults['item_spacing'];
     
    18121812        }
    18131813
    1814         if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) ) {
     1814        if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ), true ) ) {
    18151815                return false;
    18161816        }
     
    18531853        }
    18541854
    1855         if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) ) {
     1855        if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ), true ) ) {
    18561856                return false;
    18571857        }
Note: See TracChangeset for help on using the changeset viewer.