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:
* [https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#increment-decrement-operators WordPress PHP Coding Standards: Increment/decrement operators]
* [https://github.com/WordPress/WordPress-Coding-Standards/pull/2130 WPCS: PR #2130 Core: add sniffs to check formatting of increment/decrement operators]

Props jrf.
See #59161, #58831.
Built from https://develop.svn.wordpress.org/trunk@56549


git-svn-id: http://core.svn.wordpress.org/trunk@56061 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov
2023-09-09 09:28:26 +00:00
parent d8936a9fe7
commit b80ce60f70
65 changed files with 146 additions and 146 deletions

View File

@@ -2552,7 +2552,7 @@ function gallery_shortcode( $attr ) {
$post = get_post();
static $instance = 0;
$instance++;
++$instance;
if ( ! empty( $attr['ids'] ) ) {
// 'ids' is explicitly ordered, unless you specify otherwise.
@@ -2899,7 +2899,7 @@ function wp_playlist_shortcode( $attr ) {
$post = get_post();
static $instance = 0;
$instance++;
++$instance;
if ( ! empty( $attr['ids'] ) ) {
// 'ids' is explicitly ordered, unless you specify otherwise.
@@ -3213,7 +3213,7 @@ function wp_audio_shortcode( $attr, $content = '' ) {
$post_id = get_post() ? get_the_ID() : 0;
static $instance = 0;
$instance++;
++$instance;
/**
* Filters the default audio shortcode output.
@@ -3432,7 +3432,7 @@ function wp_video_shortcode( $attr, $content = '' ) {
$post_id = get_post() ? get_the_ID() : 0;
static $instance = 0;
$instance++;
++$instance;
/**
* Filters the default video shortcode output.