Make WordPress Core


Ignore:
Timestamp:
09/09/2023 09:26:01 AM (3 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use pre-increment/decrement for stand-alone statements.

Note: This is enforced by WPCS 3.0.0:

  1. There should be no space between an increment/decrement operator and the variable it applies to.
  2. Pre-increment/decrement should be favoured over post-increment/decrement for stand-alone statements. “Pre” will in/decrement and then return, “post” will return and then in/decrement. Using the “pre” version is slightly more performant and can prevent future bugs when code gets moved around.

References:

Props jrf.
See #59161, #58831.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-list-util.php

    r56138 r56549  
    118118                                        // Treat object as an array.
    119119                                        if ( array_key_exists( $m_key, $obj ) && ( $m_value == $obj[ $m_key ] ) ) {
    120                                                 $matched++;
     120                                                ++$matched;
    121121                                        }
    122122                                } elseif ( is_object( $obj ) ) {
    123123                                        // Treat object as an object.
    124124                                        if ( isset( $obj->{$m_key} ) && ( $m_value == $obj->{$m_key} ) ) {
    125                                                 $matched++;
     125                                                ++$matched;
    126126                                        }
    127127                                }
Note: See TracChangeset for help on using the changeset viewer.