Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (7 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/db/charset.php

    r46586 r47122  
    7373                        ),
    7474                        'ascii'                                 => array(
    75                                 // ascii gets special treatment, make sure it's covered
     75                                // ascii gets special treatment, make sure it's covered.
    7676                                'charset'  => 'ascii',
    7777                                'value'    => 'Hello World',
    … …  
    8383                        ),
    8484                        'ascii_char_length'                     => array(
    85                                 // ascii gets special treatment, make sure it's covered
     85                                // ascii gets special treatment, make sure it's covered.
    8686                                'charset'  => 'ascii',
    8787                                'value'    => str_repeat( 'A', 11 ),
    … …  
    9393                        ),
    9494                        'ascii_byte_length'                     => array(
    95                                 // ascii gets special treatment, make sure it's covered
     95                                // ascii gets special treatment, make sure it's covered.
    9696                                'charset'  => 'ascii',
    9797                                'value'    => str_repeat( 'A', 11 ),
    … …  
    103103                        ),
    104104                        'utf8'                                  => array(
    105                                 // utf8 only allows <= 3-byte chars
     105                                // utf8 only allows <= 3-byte chars.
    106106                                'charset'  => 'utf8',
    107107                                'value'    => "H€llo\xf0\x9f\x98\x88World¢",
    … …  
    113113                        ),
    114114                        'utf8_23char_length'                    => array(
    115                                 // utf8 only allows <= 3-byte chars
     115                                // utf8 only allows <= 3-byte chars.
    116116                                'charset'  => 'utf8',
    117117                                'value'    => str_repeat( '²3', 10 ),
    … …  
    123123                        ),
    124124                        'utf8_23byte_length'                    => array(
    125                                 // utf8 only allows <= 3-byte chars
     125                                // utf8 only allows <= 3-byte chars.
    126126                                'charset'  => 'utf8',
    127127                                'value'    => str_repeat( '²3', 10 ),
    … …  
    133133                        ),
    134134                        'utf8_3char_length'                     => array(
    135                                 // utf8 only allows <= 3-byte chars
     135                                // utf8 only allows <= 3-byte chars.
    136136                                'charset'  => 'utf8',
    137137                                'value'    => str_repeat( '3', 11 ),
    … …  
    143143                        ),
    144144                        'utf8_3byte_length'                     => array(
    145                                 // utf8 only allows <= 3-byte chars
     145                                // utf8 only allows <= 3-byte chars.
    146146                                'charset'  => 'utf8',
    147147                                'value'    => str_repeat( '3', 11 ),
    … …  
    153153                        ),
    154154                        'utf8mb3'                               => array(
    155                                 // utf8mb3 should behave the same an utf8
     155                                // utf8mb3 should behave the same an utf8.
    156156                                'charset'  => 'utf8mb3',
    157157                                'value'    => "H€llo\xf0\x9f\x98\x88World¢",
    … …  
    163163                        ),
    164164                        'utf8mb3_23char_length'                 => array(
    165                                 // utf8mb3 should behave the same an utf8
     165                                // utf8mb3 should behave the same an utf8.
    166166                                'charset'  => 'utf8mb3',
    167167                                'value'    => str_repeat( '²3', 10 ),
    … …  
    173173                        ),
    174174                        'utf8mb3_23byte_length'                 => array(
    175                                 // utf8mb3 should behave the same an utf8
     175                                // utf8mb3 should behave the same an utf8.
    176176                                'charset'  => 'utf8mb3',
    177177                                'value'    => str_repeat( '²3', 10 ),
    … …  
    183183                        ),
    184184                        'utf8mb3_3char_length'                  => array(
    185                                 // utf8mb3 should behave the same an utf8
     185                                // utf8mb3 should behave the same an utf8.
    186186                                'charset'  => 'utf8mb3',
    187187                                'value'    => str_repeat( '3', 11 ),
    … …  
    193193                        ),
    194194                        'utf8mb3_3byte_length'                  => array(
    195                                 // utf8mb3 should behave the same an utf8
     195                                // utf8mb3 should behave the same an utf8.
    196196                                'charset'  => 'utf8mb3',
    197197                                'value'    => str_repeat( '3', 10 ),
    … …  
    203203                        ),
    204204                        'utf8mb4'                               => array(
    205                                 // utf8mb4 allows 4-byte characters, too
     205                                // utf8mb4 allows 4-byte characters, too.
    206206                                'charset'  => 'utf8mb4',
    207207                                'value'    => "H€llo\xf0\x9f\x98\x88World¢",
    … …  
    213213                        ),
    214214                        'utf8mb4_234char_length'                => array(
    215                                 // utf8mb4 allows 4-byte characters, too
     215                                // utf8mb4 allows 4-byte characters, too.
    216216                                'charset'  => 'utf8mb4',
    217217                                'value'    => str_repeat( '²3𝟜', 10 ),
    … …  
    223223                        ),
    224224                        'utf8mb4_234byte_length'                => array(
    225                                 // utf8mb4 allows 4-byte characters, too
     225                                // utf8mb4 allows 4-byte characters, too.
    226226                                'charset'  => 'utf8mb4',
    227227                                'value'    => str_repeat( '²3𝟜', 10 ),
    … …  
    233233                        ),
    234234                        'utf8mb4_4char_length'                  => array(
    235                                 // utf8mb4 allows 4-byte characters, too
     235                                // utf8mb4 allows 4-byte characters, too.
    236236                                'charset'  => 'utf8mb4',
    237237                                'value'    => str_repeat( '𝟜', 11 ),
    … …  
    243243                        ),
    244244                        'utf8mb4_4byte_length'                  => array(
    245                                 // utf8mb4 allows 4-byte characters, too
     245                                // utf8mb4 allows 4-byte characters, too.
    246246                                'charset'  => 'utf8mb4',
    247247                                'value'    => str_repeat( '𝟜', 10 ),
    … …  
    327327                                'length'   => false,
    328328                                // Don't set 'ascii' => true/false.
    329                                 // That's a different codepath than it being unset even if
    330                                 // three's only only ASCII in the value.
     329                                // That's a different codepath than it being unset
     330                                // even if there's only ASCII in the value.
    331331                        ),
    332332                        'cp1251_char_length'                    => array(
    … …  
    406406                        ),
    407407                        'false'                                 => array(
    408                                 // false is a column with no character set (ie, a number column)
     408                                // False is a column with no character set (i.e. a number column).
    409409                                'charset'  => false,
    410410                                'value'    => 100,
    … …  
    415415
    416416                if ( function_exists( 'mb_convert_encoding' ) ) {
    417                         // big5 is a non-Unicode multibyte charset
    418                         $utf8      = "a\xe5\x85\xb1b"; // UTF-8 Character 20849
     417                        // big5 is a non-Unicode multibyte charset.
     418                        $utf8      = "a\xe5\x85\xb1b"; // UTF-8 Character 20849.
    419419                        $big5      = mb_convert_encoding( $utf8, 'BIG-5', 'UTF-8' );
    420420                        $conv_utf8 = mb_convert_encoding( $big5, 'UTF-8', 'BIG-5' );
    421                         // Make sure PHP's multibyte conversions are working correctly
     421                        // Make sure PHP's multibyte conversions are working correctly.
    422422                        $this->assertNotEquals( $utf8, $big5 );
    423423                        $this->assertEquals( $utf8, $conv_utf8 );
    … …  
    536536                }
    537537
    538                 // 'value' and 'format' are $data, 'charset' ends up as part of $expected
     538                // 'value' and 'format' are $data, 'charset' ends up as part of $expected.
    539539
    540540                $no_string_fields = array(
    … …  
    564564                );
    565565
    566                 // This is the same data used in process_field_charsets_for_nonexistent_table()
     566                // This is the same data used in process_field_charsets_for_nonexistent_table().
    567567                $non_ascii_string_fields = array(
    568568                        'post_content' => array(
    … …  
    648648                }
    649649
    650                 // Invalid 3-byte and 4-byte sequences
     650                // Invalid 3-byte and 4-byte sequences.
    651651                $value    = "H€llo\xe0\x80\x80World\xf0\xff\xff\xff¢";
    652652                $expected = 'H€lloWorld¢';
    … …  
    865865                $data       = array(
    866866                        array(
    867                                 // binary tables don't get stripped
    868                                 '( a VARCHAR(50) CHARACTER SET utf8, b BINARY )', // create
    869                                 "('foo\xf0\x9f\x98\x88bar', 'foo')",              // query
    870                                 "('foo\xf0\x9f\x98\x88bar', 'foo')",               // expected result
     867                                // Binary tables don't get stripped.
     868                                '( a VARCHAR(50) CHARACTER SET utf8, b BINARY )', // Create.
     869                                "('foo\xf0\x9f\x98\x88bar', 'foo')",              // Query.
     870                                "('foo\xf0\x9f\x98\x88bar', 'foo')",              // Expected result.
    871871                        ),
    872872                        array(
    873                                 // utf8/utf8mb4 tables default to utf8
     873                                // utf8/utf8mb4 tables default to utf8.
    874874                                '( a VARCHAR(50) CHARACTER SET utf8, b VARCHAR(50) CHARACTER SET utf8mb4 )',
    875875                                "('foo\xf0\x9f\x98\x88bar', 'foo')",
    … …  
    965965                        array(
    966966                                // utf8_bin tables don't need extra sanity checking.
    967                                 '( a VARCHAR(50) COLLATE utf8_bin )', // create
    968                                 true,                                  // expected result
     967                                '( a VARCHAR(50) COLLATE utf8_bin )', // Create.
     968                                true,                                 // Expected result.
    969969                        ),
    970970                        array(
    … …  
    10351035                global $wpdb;
    10361036
    1037                 // TEXT column
     1037                // TEXT column.
    10381038                $stripped = $wpdb->strip_invalid_text_for_column( $wpdb->comments, 'comment_content', str_repeat( 'A', 65536 ) );
    10391039                $this->assertEquals( 65535, strlen( $stripped ) );
    10401040
    1041                 // VARCHAR column
     1041                // VARCHAR column.
    10421042                $stripped = $wpdb->strip_invalid_text_for_column( $wpdb->comments, 'comment_agent', str_repeat( 'A', 256 ) );
    10431043                $this->assertEquals( 255, strlen( $stripped ) );
Note: See TracChangeset for help on using the changeset viewer.