WordPress.org

Make WordPress Core


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

    r47233 r47550  
    147147    } elseif ( 'attachment' === $post->post_type ) {
    148148        return get_attachment_link( $post, $leavename );
    149     } elseif ( in_array( $post->post_type, get_post_types( array( '_builtin' => false ) ) ) ) {
     149    } elseif ( in_array( $post->post_type, get_post_types( array( '_builtin' => false ) ), true ) ) {
    150150        return get_post_permalink( $post, $leavename, $sample );
    151151    }
     
    166166    $permalink = apply_filters( 'pre_post_link', $permalink, $post, $leavename );
    167167
    168     if ( '' != $permalink && ! in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ) ) ) {
     168    if ( '' != $permalink && ! in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ), true ) ) {
    169169
    170170        $category = '';
     
    276276    $slug = $post->post_name;
    277277
    278     $draft_or_pending = get_post_status( $post ) && in_array( get_post_status( $post ), array( 'draft', 'pending', 'auto-draft', 'future' ) );
     278    $draft_or_pending = get_post_status( $post ) && in_array( get_post_status( $post ), array( 'draft', 'pending', 'auto-draft', 'future' ), true );
    279279
    280280    $post_type = get_post_type_object( $post->post_type );
     
    372372    $post = get_post( $post );
    373373
    374     $draft_or_pending = in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) );
     374    $draft_or_pending = in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ), true );
    375375
    376376    $link = $wp_rewrite->get_page_permastruct();
     
    418418    $post   = get_post( $post );
    419419    $parent = ( $post->post_parent > 0 && $post->post_parent != $post->ID ) ? get_post( $post->post_parent ) : false;
    420     if ( $parent && ! in_array( $parent->post_type, get_post_types() ) ) {
     420    if ( $parent && ! in_array( $parent->post_type, get_post_types(), true ) ) {
    421421        $parent = false;
    422422    }
     
    31833183    }
    31843184
    3185     if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) {
     3185    if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ), true ) ) {
    31863186        if ( is_ssl() && ! is_admin() && 'wp-login.php' !== $pagenow ) {
    31873187            $scheme = 'https';
     
    34983498    $orig_scheme     = $scheme;
    34993499
    3500     if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) {
     3500    if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ), true ) ) {
    35013501        $scheme = is_ssl() && ! is_admin() ? 'https' : 'http';
    35023502    }
Note: See TracChangeset for help on using the changeset viewer.