Make WordPress Core


Ignore:
Timestamp:
05/16/2020 06:40:52 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict comparison where static strings are involved.

This reduces the number of WordPress.PHP.StrictComparisons.LooseComparison issues in half, from 1897 to 890.

Includes minor code layout fixes for better readability.

See #49542.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/kses.php

    r47550 r47808  
    776776        // Remove quotes surrounding $value.
    777777        // Also guarantee correct quoting in $string for this one attribute.
    778         if ( '' == $value ) {
     778        if ( '' === $value ) {
    779779            $quote = '';
    780780        } else {
    781781            $quote = $value[0];
    782782        }
    783         if ( '"' == $quote || "'" == $quote ) {
     783        if ( '"' === $quote || "'" === $quote ) {
    784784            if ( substr( $value, -1 ) != $quote ) {
    785785                return '';
     
    10401040
    10411041    // It matched a ">" character.
    1042     if ( substr( $string, 0, 1 ) != '<' ) {
     1042    if ( '<' !== substr( $string, 0, 1 ) ) {
    10431043        return '&gt;';
    10441044    }
    10451045
    10461046    // Allow HTML comments.
    1047     if ( '<!--' == substr( $string, 0, 4 ) ) {
     1047    if ( '<!--' === substr( $string, 0, 4 ) ) {
    10481048        $string = str_replace( array( '<!--', '-->' ), '', $string );
    10491049        while ( ( $newstring = wp_kses( $string, $allowed_html, $allowed_protocols ) ) != $string ) {
    10501050            $string = $newstring;
    10511051        }
    1052         if ( '' == $string ) {
     1052        if ( '' === $string ) {
    10531053            return '';
    10541054        }
     
    10791079
    10801080    // No attributes are allowed for closing elements.
    1081     if ( '' != $slash ) {
     1081    if ( '' !== $slash ) {
    10821082        return "</$elem>";
    10831083    }
     
    11651165    $allowed_attr = $allowed_html[ $element_low ];
    11661166
    1167     if ( ! isset( $allowed_attr[ $name_low ] ) || '' == $allowed_attr[ $name_low ] ) {
     1167    if ( ! isset( $allowed_attr[ $name_low ] ) || '' === $allowed_attr[ $name_low ] ) {
    11681168        /*
    11691169         * Allow `data-*` attributes.
     
    11901190    }
    11911191
    1192     if ( 'style' == $name_low ) {
     1192    if ( 'style' === $name_low ) {
    11931193        $new_value = safecss_filter_attr( $value );
    11941194
     
    16101610
    16111611    $string = preg_replace( '/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', $string );
    1612     if ( 'remove' == $options['slash_zero'] ) {
     1612    if ( 'remove' === $options['slash_zero'] ) {
    16131613        $string = preg_replace( '/\\\\+0+/', '', $string );
    16141614    }
     
    16891689        $string   = trim( $string2[1] );
    16901690        $protocol = wp_kses_bad_protocol_once2( $string2[0], $allowed_protocols );
    1691         if ( 'feed:' == $protocol ) {
     1691        if ( 'feed:' === $protocol ) {
    16921692            if ( $count > 2 ) {
    16931693                return '';
     
    22452245    $css = '';
    22462246    foreach ( $css_array as $css_item ) {
    2247         if ( '' == $css_item ) {
     2247        if ( '' === $css_item ) {
    22482248            continue;
    22492249        }
     
    23032303        // Remove any CSS containing containing \ ( & } = or comments, except for url() useage checked above.
    23042304        if ( $found && ! preg_match( '%[\\\(&=}]|/\*%', $css_test_string ) ) {
    2305             if ( '' != $css ) {
     2305            if ( '' !== $css ) {
    23062306                $css .= ';';
    23072307            }
Note: See TracChangeset for help on using the changeset viewer.