Make WordPress Core

Changeset 54895


Ignore:
Timestamp:
11/29/2022 08:58:26 PM (17 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Always use strict type check for in_array().

This fixes the currently flagged WordPress.PHP.StrictInArray.MissingTrueStrict issues:

  • Not using strict comparison for in_array; supply true for third argument.

These all do comparisons with strings, so all the more reason why it is imperative that a strict comparison is used.

Follow-up to [47550], [47557], [54155], [53480].

Props jrf.
See #56791.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-block-type.php

    r54670 r54895  
    300300     */
    301301    public function __get( $name ) {
    302         if ( ! in_array( $name, $this->deprecated_properties ) ) {
     302        if ( ! in_array( $name, $this->deprecated_properties, true ) ) {
    303303            return;
    304304        }
     
    328328     */
    329329    public function __isset( $name ) {
    330         if ( ! in_array( $name, $this->deprecated_properties ) ) {
     330        if ( ! in_array( $name, $this->deprecated_properties, true ) ) {
    331331            return false;
    332332        }
     
    347347     */
    348348    public function __set( $name, $value ) {
    349         if ( ! in_array( $name, $this->deprecated_properties ) ) {
     349        if ( ! in_array( $name, $this->deprecated_properties, true ) ) {
    350350            $this->{$name} = $value;
    351351            return;
  • trunk/src/wp-includes/pluggable.php

    r54891 r54895  
    28802880        }
    28812881
    2882         if ( in_array( $args['decoding'], array( 'async', 'sync', 'auto' ) ) && ! preg_match( '/\bdecoding\s*=/', $extra_attr ) ) {
     2882        if ( in_array( $args['decoding'], array( 'async', 'sync', 'auto' ), true ) && ! preg_match( '/\bdecoding\s*=/', $extra_attr ) ) {
    28832883            if ( ! empty( $extra_attr ) ) {
    28842884                $extra_attr .= ' ';
Note: See TracChangeset for help on using the changeset viewer.