Make WordPress Core


Ignore:
Timestamp:
09/09/2023 09:26:01 AM (14 months 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/formatting.php

    r56325 r56549  
    477477
    478478            $text .= substr( $text_part, 0, $start ) . $name;
    479             $i++;
     479            ++$i;
    480480        }
    481481
     
    26582658                $tag = '</' . $tag . '>'; // Close tag.
    26592659                array_pop( $tagstack );
    2660                 $stacksize--;
     2660                --$stacksize;
    26612661            } else { // Closing tag not at top, search for it.
    26622662                for ( $j = $stacksize - 1; $j >= 0; $j-- ) {
     
    26652665                        for ( $k = $stacksize - 1; $k >= $j; $k-- ) {
    26662666                            $tagqueue .= '</' . array_pop( $tagstack ) . '>';
    2667                             $stacksize--;
     2667                            --$stacksize;
    26682668                        }
    26692669                        break;
     
    26932693                if ( $stacksize > 0 && ! in_array( $tag, $nestable_tags, true ) && $tagstack[ $stacksize - 1 ] === $tag ) {
    26942694                    $tagqueue = '</' . array_pop( $tagstack ) . '>';
    2695                     $stacksize--;
     2695                    --$stacksize;
    26962696                }
    26972697                $stacksize = array_push( $tagstack, $tag );
     
    30843084            || preg_match( '|^<style[\s>]|i', $piece )
    30853085        ) {
    3086             $nested_code_pre++;
     3086            ++$nested_code_pre;
    30873087        } elseif ( $nested_code_pre
    30883088            && ( '</code>' === strtolower( $piece )
     
    30923092            )
    30933093        ) {
    3094             $nested_code_pre--;
     3094            --$nested_code_pre;
    30953095        }
    30963096
     
    53555355    while ( $i ) {
    53565356        $arg = array_shift( $args );
    5357         $i--;
     5357        --$i;
    53585358        if ( 0 === $i ) {
    53595359            $result .= $l['between_last_two'] . $arg;
Note: See TracChangeset for help on using the changeset viewer.