Make WordPress Core

Ticket #56791: 56791-fix-spacing-for-incrementors-and-decrementors.patch

File 56791-fix-spacing-for-incrementors-and-decrementors.patch, 8.4 KB (added by jrf, 18 months ago)

Note: this will be enforced by WPCS 3.0.0.

  • src/wp-admin/includes/template.php

    From 73b2d9986625e556d18988b144817cd0bf6af1c4 Mon Sep 17 00:00:00 2001
    From: jrfnl <jrfnl@users.noreply.github.com>
    Date: Fri, 1 Jul 2022 15:30:11 +0200
    Subject: [PATCH] CS: fix spacing for incrementors and decrementors
    
    No space allowed between the operator and the variable it applies to.
    ---
     src/wp-admin/includes/template.php                        | 2 +-
     src/wp-includes/functions.php                             | 2 +-
     src/wp-includes/sitemaps/class-wp-sitemaps-provider.php   | 2 +-
     tests/phpunit/includes/wp-profiler.php                    | 4 ++--
     tests/phpunit/tests/date/theDate.php                      | 2 +-
     tests/phpunit/tests/meta/isProtectedMeta.php              | 8 ++++----
     tests/phpunit/tests/rest-api/rest-sidebars-controller.php | 2 +-
     tests/phpunit/tests/rest-api/rest-widgets-controller.php  | 2 +-
     .../phpunit/tests/rest-api/wpRestMenuItemsController.php  | 4 ++--
     tests/phpunit/tests/theme/wpThemeJsonResolver.php         | 2 +-
     10 files changed, 15 insertions(+), 15 deletions(-)
    
    diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php
    index deecc92c50..3194524717 100644
    a b function _list_meta_row( $entry, &$count ) { 
    626626        }
    627627
    628628        $r = '';
    629         ++ $count;
     629        ++$count;
    630630
    631631        if ( is_serialized( $entry['meta_value'] ) ) {
    632632                if ( is_serialized_string( $entry['meta_value'] ) ) {
  • src/wp-includes/functions.php

    diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
    index 91fc777d82..a1e8bf9863 100644
    a b function wp_date( $format, $timestamp = null, $timezone = null ) { 
    262262                $month         = $wp_locale->get_month( $datetime->format( 'm' ) );
    263263                $weekday       = $wp_locale->get_weekday( $datetime->format( 'w' ) );
    264264
    265                 for ( $i = 0; $i < $format_length; $i ++ ) {
     265                for ( $i = 0; $i < $format_length; $i++ ) {
    266266                        switch ( $format[ $i ] ) {
    267267                                case 'D':
    268268                                        $new_format .= addcslashes( $wp_locale->get_weekday_abbrev( $weekday ), '\\A..Za..z' );
  • src/wp-includes/sitemaps/class-wp-sitemaps-provider.php

    diff --git a/src/wp-includes/sitemaps/class-wp-sitemaps-provider.php b/src/wp-includes/sitemaps/class-wp-sitemaps-provider.php
    index 81464c1bdb..1ff4987eca 100644
    a b abstract class WP_Sitemaps_Provider { 
    107107                $sitemap_types = $this->get_sitemap_type_data();
    108108
    109109                foreach ( $sitemap_types as $type ) {
    110                         for ( $page = 1; $page <= $type['pages']; $page ++ ) {
     110                        for ( $page = 1; $page <= $type['pages']; $page++ ) {
    111111                                $sitemap_entry = array(
    112112                                        'loc' => $this->get_sitemap_url( $type['name'], $page ),
    113113                                );
  • tests/phpunit/includes/wp-profiler.php

    diff --git a/tests/phpunit/includes/wp-profiler.php b/tests/phpunit/includes/wp-profiler.php
    index 17c79ee51b..ce78ba4c8e 100644
    a b class WPProfiler { 
    7373
    7474                if ( isset( $this->profile[ $name ] ) ) {
    7575                        $this->profile[ $name ]['time'] += $time;
    76                         $this->profile[ $name ]['calls'] ++;
     76                        $this->profile[ $name ]['calls']++;
    7777                        $this->profile[ $name ]['cache_cold_hits']    += ( $wp_object_cache->cold_cache_hits - $item['cache_cold_hits'] );
    7878                        $this->profile[ $name ]['cache_warm_hits']    += ( $wp_object_cache->warm_cache_hits - $item['cache_warm_hits'] );
    7979                        $this->profile[ $name ]['cache_misses']       += ( $wp_object_cache->cache_misses - $item['cache_misses'] );
    class WPProfiler { 
    143143                        $sql = preg_replace( '/(WHERE \w+ =) \d+/', '$1 x', $sql );
    144144                        $sql = preg_replace( '/(WHERE \w+ =) \'\[-\w]+\'/', '$1 \'xxx\'', $sql );
    145145
    146                         $out[ $sql ] ++;
     146                        $out[ $sql ]++;
    147147                }
    148148                asort( $out );
    149149                return;
  • tests/phpunit/tests/date/theDate.php

    diff --git a/tests/phpunit/tests/date/theDate.php b/tests/phpunit/tests/date/theDate.php
    index b5fcb793df..2337ab61ec 100644
    a b class Tests_Date_TheDate extends WP_UnitTestCase { 
    8080        }
    8181
    8282        public function count_hook( $input ) {
    83                 $this->hooks_called[ current_filter() ] ++;
     83                $this->hooks_called[ current_filter() ]++;
    8484
    8585                return $input;
    8686        }
  • tests/phpunit/tests/meta/isProtectedMeta.php

    diff --git a/tests/phpunit/tests/meta/isProtectedMeta.php b/tests/phpunit/tests/meta/isProtectedMeta.php
    index c204d381f5..46f20e72fa 100644
    a b class Tests_Meta_isProtectedMeta extends WP_UnitTestCase { 
    1717                $protected_keys = array(
    1818                        array( '_wp_attachment' ),
    1919                );
    20                 for ( $i = 0, $max = 31; $i < $max; $i ++ ) {
     20                for ( $i = 0, $max = 31; $i < $max; $i++ ) {
    2121                        $protected_keys[] = array( chr( $i ) . '_wp_attachment' );
    2222                }
    23                 for ( $i = 127, $max = 159; $i <= $max; $i ++ ) {
     23                for ( $i = 127, $max = 159; $i <= $max; $i++ ) {
    2424                        $protected_keys[] = array( chr( $i ) . '_wp_attachment' );
    2525                }
    2626                $protected_keys[] = array( chr( 95 ) . '_wp_attachment' );
    class Tests_Meta_isProtectedMeta extends WP_UnitTestCase { 
    4242                        array( 'ąŌ_not_so_protected_meta' ),
    4343                );
    4444
    45                 for ( $i = 32, $max = 94; $i <= $max; $i ++ ) {
     45                for ( $i = 32, $max = 94; $i <= $max; $i++ ) {
    4646                        $unprotected_keys[] = array( chr( $i ) . '_wp_attachment' );
    4747                }
    48                 for ( $i = 96, $max = 126; $i <= $max; $i ++ ) {
     48                for ( $i = 96, $max = 126; $i <= $max; $i++ ) {
    4949                        $unprotected_keys[] = array( chr( $i ) . '_wp_attachment' );
    5050                }
    5151
  • tests/phpunit/tests/rest-api/rest-sidebars-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-sidebars-controller.php b/tests/phpunit/tests/rest-api/rest-sidebars-controller.php
    index e15a7f910a..e2745f519f 100644
    a b class WP_Test_REST_Sidebars_Controller extends WP_Test_REST_Controller_Testcase 
    949949                        if ( isset( $item['_links'] ) ) {
    950950                                unset( $data[ $count ]['_links'] );
    951951                        }
    952                         $count ++;
     952                        $count++;
    953953                }
    954954
    955955                return $data;
  • tests/phpunit/tests/rest-api/rest-widgets-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-widgets-controller.php b/tests/phpunit/tests/rest-api/rest-widgets-controller.php
    index 28ac8bc6e3..05ea0cae64 100644
    a b class WP_Test_REST_Widgets_Controller extends WP_Test_REST_Controller_Testcase { 
    15551555                        if ( is_array( $item ) && isset( $item['_links'] ) ) {
    15561556                                unset( $data[ $count ]['_links'] );
    15571557                        }
    1558                         $count ++;
     1558                        $count++;
    15591559                }
    15601560
    15611561                return $data;
  • tests/phpunit/tests/rest-api/wpRestMenuItemsController.php

    diff --git a/tests/phpunit/tests/rest-api/wpRestMenuItemsController.php b/tests/phpunit/tests/rest-api/wpRestMenuItemsController.php
    index 9ef5b87d99..5eecd99d43 100644
    a b class Tests_REST_WpRestMenuItemsController extends WP_Test_REST_Post_Type_Contro 
    375375                $new_menu_id = wp_create_nav_menu( rand_str() );
    376376                $expected    = array();
    377377                $actual      = array();
    378                 for ( $i = 1; $i < 5; $i ++ ) {
     378                for ( $i = 1; $i < 5; $i++ ) {
    379379                        $request = new WP_REST_Request( 'POST', '/wp/v2/menu-items' );
    380380                        $request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
    381381                        $params = $this->set_menu_item_data(
    class Tests_REST_WpRestMenuItemsController extends WP_Test_REST_Post_Type_Contro 
    921921                        foreach ( $taxonomies as $taxonomy ) {
    922922                                $this->assertSame( $taxonomy->name, $links['https://api.w.org/term'][ $num ]['attributes']['taxonomy'] );
    923923                                $this->assertSame( add_query_arg( 'post', $data['id'], rest_url( 'wp/v2/' . $taxonomy->rest_base ) ), $links['https://api.w.org/term'][ $num ]['href'] );
    924                                 $num ++;
     924                                $num++;
    925925                        }
    926926
    927927                        if ( 'post_type' === $data['type'] ) {
  • tests/phpunit/tests/theme/wpThemeJsonResolver.php

    diff --git a/tests/phpunit/tests/theme/wpThemeJsonResolver.php b/tests/phpunit/tests/theme/wpThemeJsonResolver.php
    index 1cbc519255..795b3029aa 100644
    a b class Tests_Theme_wpThemeJsonResolver extends WP_UnitTestCase { 
    648648                $this->assertNotEmpty( $user_cpt, 'User CPT is expected not to be empty.' );
    649649
    650650                $global_styles_query_count = 0;
    651                 for ( $i = 0; $i < 3; $i ++ ) {
     651                for ( $i = 0; $i < 3; $i++ ) {
    652652                        $new_user_cpt = WP_Theme_JSON_Resolver::get_user_data_from_wp_global_styles( $theme );
    653653                        WP_Theme_JSON_Resolver::clean_cached_data();
    654654                        $this->assertSameSets( $user_cpt, $new_user_cpt, "User CPTs do not match on run {$i}." );