Make WordPress Core

Changeset 55037


Ignore:
Timestamp:
01/08/2023 01:13:59 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Rename parameters that use reserved keywords in phpunit/tests/compat/mbSubstr.php.

While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.

This commit renames the $string parameter to $input_string in the unit tests for mb_substr() polyfill.

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232], [53236], [53239], [53240], [53242], [53243], [53245], [53246], [53257], [53269], [53270], [53271], [53272], [53273], [53274], [53275], [53276], [53277], [53281], [53283], [53284], [53285], [53287], [53364], [53365], [54927], [54929], [54930], [54931], [54932], [54933], [54938], [54943], [54944], [54945], [54946], [54947], [54948], [54950], [54951], [54952], [54956], [54959], [54960], [54961], [54962], [54964], [54965], [54969], [54970], [54971], [54972], [54996], [55000], [55011], [55013], [55014], [55015], [55016], [55017], [55020], [55021], [55023], [55027], [55028], [55034], [55036].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #56788.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/compat/mbSubstr.php

    r54064 r55037  
    2020         * @dataProvider utf8_substrings
    2121         */
    22         public function test_mb_substr( $string, $start, $length, $expected_character_substring ) {
    23                 $this->assertSame( $expected_character_substring, _mb_substr( $string, $start, $length, 'UTF-8' ) );
     22        public function test_mb_substr( $input_string, $start, $length, $expected_character_substring ) {
     23                $this->assertSame( $expected_character_substring, _mb_substr( $input_string, $start, $length, 'UTF-8' ) );
    2424        }
    2525
    … …  
    2727         * @dataProvider utf8_substrings
    2828         */
    29         public function test_mb_substr_via_regex( $string, $start, $length, $expected_character_substring ) {
     29        public function test_mb_substr_via_regex( $input_string, $start, $length, $expected_character_substring ) {
    3030                _wp_can_use_pcre_u( false );
    31                 $this->assertSame( $expected_character_substring, _mb_substr( $string, $start, $length, 'UTF-8' ) );
     31                $this->assertSame( $expected_character_substring, _mb_substr( $input_string, $start, $length, 'UTF-8' ) );
    3232                _wp_can_use_pcre_u( 'reset' );
    3333        }
    … …  
    3636         * @dataProvider utf8_substrings
    3737         */
    38         public function test_8bit_mb_substr( $string, $start, $length, $expected_character_substring, $expected_byte_substring ) {
    39                 $this->assertSame( $expected_byte_substring, _mb_substr( $string, $start, $length, '8bit' ) );
     38        public function test_8bit_mb_substr( $input_string, $start, $length, $expected_character_substring, $expected_byte_substring ) {
     39                $this->assertSame( $expected_byte_substring, _mb_substr( $input_string, $start, $length, '8bit' ) );
    4040        }
    4141
    … …  
    4848                return array(
    4949                        array(
    50                                 'string'                       => 'баба',
     50                                'input_string'                 => 'баба',
    5151                                'start'                        => 0,
    5252                                'length'                       => 3,
    … …  
    5555                        ),
    5656                        array(
    57                                 'string'                       => 'баба',
     57                                'input_string'                 => 'баба',
    5858                                'start'                        => 0,
    5959                                'length'                       => -1,
    … …  
    6262                        ),
    6363                        array(
    64                                 'string'                       => 'баба',
     64                                'input_string'                 => 'баба',
    6565                                'start'                        => 1,
    6666                                'length'                       => null,
    … …  
    6969                        ),
    7070                        array(
    71                                 'string'                       => 'баба',
     71                                'input_string'                 => 'баба',
    7272                                'start'                        => -3,
    7373                                'length'                       => null,
    … …  
    7676                        ),
    7777                        array(
    78                                 'string'                       => 'баба',
     78                                'input_string'                 => 'баба',
    7979                                'start'                        => -3,
    8080                                'length'                       => 2,
    … …  
    8383                        ),
    8484                        array(
    85                                 'string'                       => 'баба',
     85                                'input_string'                 => 'баба',
    8686                                'start'                        => -1,
    8787                                'length'                       => 2,
    … …  
    9090                        ),
    9191                        array(
    92                                 'string'                       => 'I am your баба',
     92                                'input_string'                 => 'I am your баба',
    9393                                'start'                        => 0,
    9494                                'length'                       => 11,
Note: See TracChangeset for help on using the changeset viewer.