Make WordPress Core


Ignore:
Timestamp:
09/09/2023 09:26:01 AM (7 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/tests/phpunit/includes/wp-profiler.php

    r56548 r56549  
    7373        if ( isset( $this->profile[ $name ] ) ) {
    7474            $this->profile[ $name ]['time'] += $time;
    75             $this->profile[ $name ]['calls']++;
     75            ++$this->profile[ $name ]['calls'];
    7676            $this->profile[ $name ]['cache_cold_hits']    += ( $wp_object_cache->cold_cache_hits - $item['cache_cold_hits'] );
    7777            $this->profile[ $name ]['cache_warm_hits']    += ( $wp_object_cache->warm_cache_hits - $item['cache_warm_hits'] );
     
    114114            global $wp_actions;
    115115            if ( end( $wp_actions ) === $tag ) {
    116                 $this->stack[ count( $this->stack ) - 1 ]['actions'][ $tag ]++;
     116                ++$this->stack[ count( $this->stack ) - 1 ]['actions'][ $tag ];
    117117            } else {
    118                 $this->stack[ count( $this->stack ) - 1 ]['filters'][ $tag ]++;
     118                ++$this->stack[ count( $this->stack ) - 1 ]['filters'][ $tag ];
    119119            }
    120120        }
     
    124124    public function log_action( $tag ) {
    125125        if ( $this->stack ) {
    126             $this->stack[ count( $this->stack ) - 1 ]['actions'][ $tag ]++;
     126            ++$this->stack[ count( $this->stack ) - 1 ]['actions'][ $tag ];
    127127        }
    128128    }
     
    143143            $sql = preg_replace( '/(WHERE \w+ =) \'\[-\w]+\'/', '$1 \'xxx\'', $sql );
    144144
    145             $out[ $sql ]++;
     145            ++$out[ $sql ];
    146146        }
    147147        asort( $out );
     
    154154        foreach ( $queries as $q ) {
    155155            if ( empty( $q[2] ) ) {
    156                 $out['unknown']++;
     156                ++$out['unknown'];
    157157            } else {
    158                 $out[ $q[2] ]++;
     158                ++$out[ $q[2] ];
    159159            }
    160160        }
Note: See TracChangeset for help on using the changeset viewer.