Make WordPress Core


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

    r46661 r47550  
    344344     */
    345345    public function __isset( $name ) {
    346         if ( in_array( $name, $this->post_fields ) && 0 !== (int) $this->comment_post_ID ) {
     346        if ( in_array( $name, $this->post_fields, true ) && 0 !== (int) $this->comment_post_ID ) {
    347347            $post = get_post( $this->comment_post_ID );
    348348            return property_exists( $post, $name );
     
    361361     */
    362362    public function __get( $name ) {
    363         if ( in_array( $name, $this->post_fields ) ) {
     363        if ( in_array( $name, $this->post_fields, true ) ) {
    364364            $post = get_post( $this->comment_post_ID );
    365365            return $post->$name;
Note: See TracChangeset for help on using the changeset viewer.