Make WordPress Core

Ticket #54728: 54728.4.diff

File 54728.4.diff, 14.2 KB (added by azouamauriac, 3 years ago)

Fix (WordPress.PHP.StrictComparisons.LooseComparison) ; and fix typo RE: https://developer.wordpress.org/coding-standards/inline-documentation-standards/php/#language

  • src/wp-includes/category-template.php

     
    555555        }
    556556
    557557        // Descendants of exclusions should be excluded too.
    558         if ( true == $parsed_args['hierarchical'] ) {
     558        if ( true === $parsed_args['hierarchical'] ) {
    559559                $exclude_tree = array();
    560560
    561561                if ( $parsed_args['exclude_tree'] ) {
  • src/wp-includes/option.php

     
    10911091                $cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE[ 'wp-settings-' . $user_id ] );
    10921092
    10931093                // No change or both empty.
    1094                 if ( $cookie == $settings ) {
     1094                if ( $cookie === $settings ) {
    10951095                        return;
    10961096                }
    10971097
  • src/wp-includes/category.php

     
    149149        foreach ( $categories as $category ) {
    150150                $path        = '/' . $leaf_path;
    151151                $curcategory = $category;
    152                 while ( ( 0 != $curcategory->parent ) && ( $curcategory->parent != $curcategory->term_id ) ) {
     152                while ( ( 0 !== $curcategory->parent ) && ( $curcategory->parent !== $curcategory->term_id ) ) {
    153153                        $curcategory = get_term( $curcategory->parent, 'category' );
    154154
    155155                        if ( is_wp_error( $curcategory ) ) {
     
    159159                        $path = '/' . $curcategory->slug . $path;
    160160                }
    161161
    162                 if ( $path == $full_path ) {
     162                if ( $path === $full_path ) {
    163163                        $category = get_term( $category->term_id, 'category', $output );
    164164                        _make_cat_compat( $category );
    165165
  • src/wp-includes/taxonomy.php

     
    22282228        if ( count( $taxonomies ) > 1 ) {
    22292229                foreach ( $taxonomies as $index => $taxonomy ) {
    22302230                        $t = get_taxonomy( $taxonomy );
    2231                         if ( isset( $t->args ) && is_array( $t->args ) && array_merge( $args, $t->args ) != $args ) {
     2231                        if ( isset( $t->args ) && is_array( $t->args ) && array_merge( $args, $t->args ) !== $args ) {
    22322232                                unset( $taxonomies[ $index ] );
    22332233                                $terms = array_merge( $terms, wp_get_object_terms( $object_ids, $taxonomy, array_merge( $args, $t->args ) ) );
    22342234                        }
     
    34653465                        }
    34663466                }
    34673467
    3468                 if ( array_filter( $object_types, 'post_type_exists' ) == $object_types ) {
     3468                if ( array_filter( $object_types, 'post_type_exists' ) === $object_types ) {
    34693469                        // Only post types are attached to this taxonomy.
    34703470                        _update_post_term_count( $terms, $taxonomy );
    34713471                } else {
  • src/wp-includes/rewrite.php

     
    144144}
    145145
    146146/**
    147  * Add a new rewrite tag (like %postname%).
     147 * Adds a new rewrite tag (like %postname%).
    148148 *
    149149 * The `$query` parameter is optional. If it is omitted you must ensure that you call
    150150 * this on, or before, the {@see 'init'} hook. This is because `$query` defaults to
     
    191191}
    192192
    193193/**
    194  * Add permalink structure.
     194 * Adds permalink structure.
    195195 *
    196196 * @since 3.0.0
    197197 *
     
    210210        if ( ! is_array( $args ) ) {
    211211                $args = array( 'with_front' => $args );
    212212        }
    213         if ( func_num_args() == 4 ) {
     213        if ( func_num_args() === 4 ) {
    214214                $args['ep_mask'] = func_get_arg( 3 );
    215215        }
    216216
     
    237237}
    238238
    239239/**
    240  * Add a new feed type like /atom1/.
     240 * Adds a new feed type like /atom1/.
    241241 *
    242242 * @since 2.1.0
    243243 *
     
    265265}
    266266
    267267/**
    268  * Remove rewrite rules and then recreate rewrite rules.
     268 * Removes rewrite rules and then recreate rewrite rules.
    269269 *
    270270 * @since 3.0.0
    271271 *
     
    283283}
    284284
    285285/**
    286  * Add an endpoint, like /trackback/.
     286 * Adds an endpoint, like /trackback/.
    287287 *
    288288 * Adding an endpoint creates extra rewrite rules for each of the matching
    289289 * places specified by the provided bitmask. For example:
     
    357357
    358358
    359359/**
    360  * Resolve numeric slugs that collide with date permalinks.
     360 * Resolves numeric slugs that collide with date permalinks.
    361361 *
    362362 * Permalinks of posts with numeric slugs can sometimes look to WP_Query::parse_query()
    363363 * like a date archive, as when your permalink structure is `/%year%/%postname%/` and
     
    473473}
    474474
    475475/**
    476  * Examine a URL and try to determine the post ID it represents.
     476 * Examines a URL and try to determine the post ID it represents.
    477477 *
    478478 * Checks are supposedly from the hosted site blog.
    479479 *
     
    584584
    585585                // If the requesting file is the anchor of the match,
    586586                // prepend it to the path info.
    587                 if ( ! empty( $url ) && ( $url != $request ) && ( strpos( $match, $url ) === 0 ) ) {
     587                if ( ! empty( $url ) && ( $url !== $request ) && ( strpos( $match, $url ) === 0 ) ) {
    588588                        $request_match = $url . '/' . $request;
    589589                }
    590590
  • src/wp-includes/post-template.php

     
    99 */
    1010
    1111/**
    12  * Display the ID of the current item in the WordPress Loop.
     12 * Displays the ID of the current item in the WordPress Loop.
    1313 *
    1414 * @since 0.71
    1515 */
     
    1818}
    1919
    2020/**
    21  * Retrieve the ID of the current item in the WordPress Loop.
     21 * Retrieves the ID of the current item in the WordPress Loop.
    2222 *
    2323 * @since 2.1.0
    2424 *
     
    3030}
    3131
    3232/**
    33  * Display or retrieve the current post title with optional markup.
     33 * Displays or retrieve the current post title with optional markup.
    3434 *
    3535 * @since 0.71
    3636 *
     
    4242function the_title( $before = '', $after = '', $echo = true ) {
    4343        $title = get_the_title();
    4444
    45         if ( strlen( $title ) == 0 ) {
     45        if ( strlen( $title ) === 0 ) {
    4646                return;
    4747        }
    4848
     
    5656}
    5757
    5858/**
    59  * Sanitize the current title when retrieving or displaying.
     59 * Sanitizes the current title when retrieving or displaying.
    6060 *
    6161 * Works like the_title(), except the parameters can be in a string or
    6262 * an array. See the function for what can be override in the $args parameter.
     
    8888
    8989        $title = get_the_title( $parsed_args['post'] );
    9090
    91         if ( strlen( $title ) == 0 ) {
     91        if ( strlen( $title ) === 0 ) {
    9292                return;
    9393        }
    9494
     
    103103}
    104104
    105105/**
    106  * Retrieve post title.
     106 * Retrieves post title.
    107107 *
    108108 * If the post is protected and the visitor is not an admin, then "Protected"
    109109 * will be displayed before the post title. If the post is private, then
     
    172172}
    173173
    174174/**
    175  * Display the Post Global Unique Identifier (guid).
     175 * Displays the Post Global Unique Identifier (guid).
    176176 *
    177177 * The guid will appear to be a link, but should not be used as a link to the
    178178 * post. The reason you should not use it as a link, is because of moving the
     
    204204}
    205205
    206206/**
    207  * Retrieve the Post Global Unique Identifier (guid).
     207 * Retrieves the Post Global Unique Identifier (guid).
    208208 *
    209209 * The guid will appear to be a link, but should not be used as an link to the
    210210 * post. The reason you should not use it as a link, is because of moving the
     
    233233}
    234234
    235235/**
    236  * Display the post content.
     236 * Displays the post content.
    237237 *
    238238 * @since 0.71
    239239 *
     
    256256}
    257257
    258258/**
    259  * Retrieve the post content.
     259 * Retrieves the post content.
    260260 *
    261261 * @since 0.71
    262262 * @since 5.2.0 Added the `$post` parameter.
     
    340340                $content = array( $content );
    341341        }
    342342
    343         if ( false !== strpos( $_post->post_content, '<!--noteaser-->' ) && ( ! $elements['multipage'] || 1 == $elements['page'] ) ) {
     343        if ( false !== strpos( $_post->post_content, '<!--noteaser-->' ) && ( ! $elements['multipage'] || 1 === $elements['page'] ) ) {
    344344                $strip_teaser = true;
    345345        }
    346346
     
    376376}
    377377
    378378/**
    379  * Display the post excerpt.
     379 * Displays the post excerpt.
    380380 *
    381381 * @since 0.71
    382382 */
     
    957957                        $output .= $parsed_args['before'];
    958958                        for ( $i = 1; $i <= $numpages; $i++ ) {
    959959                                $link = $parsed_args['link_before'] . str_replace( '%', $i, $parsed_args['pagelink'] ) . $parsed_args['link_after'];
    960                                 if ( $i != $page || ! $more && 1 == $page ) {
     960                                if ( $i !== $page || ! $more && 1 === $page ) {
    961961                                        $link = _wp_link_page( $i ) . $link . '</a>';
    962962                                } elseif ( $i === $page ) {
    963963                                        $link = '<span class="post-page-numbers current" aria-current="' . esc_attr( $parsed_args['aria_current'] ) . '">' . $link . '</span>';
     
    10331033        $post       = get_post();
    10341034        $query_args = array();
    10351035
    1036         if ( 1 == $i ) {
     1036        if ( 1 === $i ) {
    10371037                $url = get_permalink();
    10381038        } else {
    10391039                if ( ! get_option( 'permalink_structure' ) || in_array( $post->post_status, array( 'draft', 'pending' ), true ) ) {
    10401040                        $url = add_query_arg( 'page', $i, get_permalink() );
    1041                 } elseif ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post->ID ) {
     1041                } elseif ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) === $post->ID ) {
    10421042                        $url = trailingslashit( get_permalink() ) . user_trailingslashit( "$wp_rewrite->pagination_base/" . $i, 'single_paged' );
    10431043                } else {
    10441044                        $url = trailingslashit( get_permalink() ) . user_trailingslashit( $i, 'single_paged' );
     
    10631063//
    10641064
    10651065/**
    1066  * Retrieve post custom meta data field.
     1066 * Retrieves post custom meta data field.
    10671067 *
    10681068 * @since 1.5.0
    10691069 *
     
    10841084}
    10851085
    10861086/**
    1087  * Display a list of post custom fields.
     1087 * Displays a list of post custom fields.
    10881088 *
    10891089 * @since 1.2.0
    10901090 *
     
    11331133//
    11341134
    11351135/**
    1136  * Retrieve or display a list of pages as a dropdown (select list).
     1136 * Retrieves or display a list of pages as a dropdown (select list).
    11371137 *
    11381138 * @since 2.1.0
    11391139 * @since 4.2.0 The `$value_field` argument was added.
     
    12241224}
    12251225
    12261226/**
    1227  * Retrieve or display a list of pages (or hierarchical post type items) in list (li) format.
     1227 * Retrieves or display a list of pages (or hierarchical post type items) in list (li) format.
    12281228 *
    12291229 * @since 1.5.0
    12301230 * @since 4.7.0 Added the `item_spacing` argument.
     
    15131513//
    15141514
    15151515/**
    1516  * Retrieve HTML list content for page list.
     1516 * Retrieves HTML list content for page list.
    15171517 *
    15181518 * @uses Walker_Page to create HTML list content.
    15191519 * @since 2.1.0
     
    15441544}
    15451545
    15461546/**
    1547  * Retrieve HTML dropdown (select) content for page list.
     1547 * Retrieves HTML dropdown (select) content for page list.
    15481548 *
    15491549 * @since 2.1.0
    15501550 * @since 5.3.0 Formalized the existing `...$args` parameter by adding it
     
    15741574//
    15751575
    15761576/**
    1577  * Display an attachment page link using an image or icon.
     1577 * Displays an attachment page link using an image or icon.
    15781578 *
    15791579 * @since 2.0.0
    15801580 *
     
    15961596}
    15971597
    15981598/**
    1599  * Retrieve an attachment page link using an image or icon, if possible.
     1599 * Retrieves an attachment page link using an image or icon, if possible.
    16001600 *
    16011601 * @since 2.5.0
    16021602 * @since 4.4.0 The `$id` parameter can now accept either a post ID or `WP_Post` object.
     
    16581658}
    16591659
    16601660/**
    1661  * Wrap attachment in paragraph tag before content.
     1661 * Wraps attachment in paragraph tag before content.
    16621662 *
    16631663 * @since 2.0.0
    16641664 *
     
    17111711//
    17121712
    17131713/**
    1714  * Retrieve protected post password form content.
     1714 * Retrieves protected post password form content.
    17151715 *
    17161716 * @since 1.0.0
    17171717 *
     
    17711771                return (bool) $page_template;
    17721772        }
    17731773
    1774         if ( $template == $page_template ) {
     1774        if ( $template === $page_template ) {
    17751775                return true;
    17761776        }
    17771777
     
    18131813}
    18141814
    18151815/**
    1816  * Retrieve formatted date timestamp of a revision (linked to that revisions's page).
     1816 * Retrieves formatted date timestamp of a revision (linked to that revisions's page).
    18171817 *
    18181818 * @since 2.6.0
    18191819 *
     
    18541854}
    18551855
    18561856/**
    1857  * Retrieve formatted date timestamp of a revision (linked to that revisions's page).
     1857 * Retrieves formatted date timestamp of a revision (linked to that revisions's page).
    18581858 *
    18591859 * @since 3.6.0
    18601860 *
     
    19181918}
    19191919
    19201920/**
    1921  * Display a list of a post's revisions.
     1921 * Displays a list of a post's revisions.
    19221922 *
    19231923 * Can output either a UL with edit links or a TABLE with diff interface, and
    19241924 * restore action links.
  • src/wp-includes/class-wp-simplepie-file.php

     
    5656                                $args['headers'] = $this->headers;
    5757                        }
    5858
    59                         if ( SIMPLEPIE_USERAGENT != $this->useragent ) { // Use default WP user agent unless custom has been specified.
     59                        if ( SIMPLEPIE_USERAGENT !== $this->useragent ) { // Use default WP user agent unless custom has been specified.
    6060                                $args['user-agent'] = $this->useragent;
    6161                        }
    6262
  • src/wp-includes/class-wp-rewrite.php

     
    13981398                // Extra permastructs.
    13991399                foreach ( $this->extra_permastructs as $permastructname => $struct ) {
    14001400                        if ( is_array( $struct ) ) {
    1401                                 if ( count( $struct ) == 2 ) {
     1401                                if ( count( $struct ) === 2 ) {
    14021402                                        $rules = $this->generate_rewrite_rules( $struct[0], $struct[1] );
    14031403                                } else {
    14041404                                        $rules = $this->generate_rewrite_rules( $struct['struct'], $struct['ep_mask'], $struct['paged'], $struct['feed'], $struct['forcomments'], $struct['walk_dirs'], $struct['endpoints'] );
     
    16621662                        $index = false === strpos( $query, '?' ) ? strlen( $query ) : strpos( $query, '?' );
    16631663                        $front = substr( $query, 0, $index );
    16641664
    1665                         $external = $front != $this->index;
     1665                        $external = $front !== $this->index;
    16661666                }
    16671667
    16681668                // "external" = it doesn't correspond to index.php.
     
    17931793                if ( ! is_array( $args ) ) {
    17941794                        $args = array( 'with_front' => $args );
    17951795                }
    1796                 if ( func_num_args() == 4 ) {
     1796                if ( func_num_args() === 4 ) {
    17971797                        $args['ep_mask'] = func_get_arg( 3 );
    17981798                }
    17991799
     
    19311931         * @param string $permalink_structure Permalink structure.
    19321932         */
    19331933        public function set_permalink_structure( $permalink_structure ) {
    1934                 if ( $permalink_structure != $this->permalink_structure ) {
     1934                if ( $permalink_structure !== $this->permalink_structure ) {
    19351935                        $old_permalink_structure = $this->permalink_structure;
    19361936                        update_option( 'permalink_structure', $permalink_structure );
    19371937