Make WordPress Core


Ignore:
Timestamp:
09/09/2023 09:26:01 AM (8 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/class-wp-query.php

    r56513 r56549  
    34713471                    array_splice( $this->posts, $sticky_offset, 0, array( $sticky_post ) );
    34723472                    // Increment the sticky offset. The next sticky will be placed at this offset.
    3473                     $sticky_offset++;
     3473                    ++$sticky_offset;
    34743474                    // Remove post from sticky posts array.
    34753475                    $offset = array_search( $sticky_post->ID, $sticky_posts, true );
     
    35013501                foreach ( $stickies as $sticky_post ) {
    35023502                    array_splice( $this->posts, $sticky_offset, 0, array( $sticky_post ) );
    3503                     $sticky_offset++;
     3503                    ++$sticky_offset;
    35043504                }
    35053505            }
     
    36213621    public function next_post() {
    36223622
    3623         $this->current_post++;
     3623        ++$this->current_post;
    36243624
    36253625        /** @var WP_Post */
     
    37313731     */
    37323732    public function next_comment() {
    3733         $this->current_comment++;
     3733        ++$this->current_comment;
    37343734
    37353735        /** @var WP_Comment */
Note: See TracChangeset for help on using the changeset viewer.