Make WordPress Core

Changeset 16340


Ignore:
Timestamp:
11/13/2010 09:53:55 AM (13 years ago)
Author:
nacin
Message:

Use square brackets instead of braces for string access. props hakre, fixes #13900.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/import.php

    r16008 r16340  
    6363if ($imports_dir) {
    6464    while (($file = readdir($imports_dir)) !== false) {
    65         if ($file{0} == '.') {
     65        if ($file[0] == '.') {
    6666            continue;
    6767        } elseif (substr($file, -4) == '.php') {
  • trunk/wp-admin/includes/media.php

    r16245 r16340  
    12591259
    12601260    foreach ( $form_fields as $id => $field ) {
    1261         if ( $id{0} == '_' )
     1261        if ( $id[0] == '_' )
    12621262            continue;
    12631263
  • trunk/wp-admin/includes/misc.php

    r16298 r16340  
    577577     */
    578578
    579     if ( $path{strlen($path)-1} == '/' ) // recursively return a temporary file path
     579    if ( $path[strlen($path)-1] == '/' ) // recursively return a temporary file path
    580580        return win_is_writable($path . uniqid(mt_rand()) . '.tmp');
    581581    else if ( is_dir($path) )
  • trunk/wp-includes/class-json.php

    r12705 r16340  
    154154        }
    155155
    156         $bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
     156        $bytes = (ord($utf16[0]) << 8) | ord($utf16[1]);
    157157
    158158        switch(true) {
     
    207207                // return a UTF-16 character from a 2-byte UTF-8 char
    208208                // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
    209                 return chr(0x07 & (ord($utf8{0}) >> 2))
    210                     . chr((0xC0 & (ord($utf8{0}) << 6))
    211                         | (0x3F & ord($utf8{1})));
     209                return chr(0x07 & (ord($utf8[0]) >> 2))
     210                    . chr((0xC0 & (ord($utf8[0]) << 6))
     211                        | (0x3F & ord($utf8[1])));
    212212
    213213            case 3:
    214214                // return a UTF-16 character from a 3-byte UTF-8 char
    215215                // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
    216                 return chr((0xF0 & (ord($utf8{0}) << 4))
    217                         | (0x0F & (ord($utf8{1}) >> 2)))
    218                     . chr((0xC0 & (ord($utf8{1}) << 6))
    219                         | (0x7F & ord($utf8{2})));
     216                return chr((0xF0 & (ord($utf8[0]) << 4))
     217                        | (0x0F & (ord($utf8[1]) >> 2)))
     218                    . chr((0xC0 & (ord($utf8[1]) << 6))
     219                        | (0x7F & ord($utf8[2])));
    220220        }
    221221
     
    294294                for ($c = 0; $c < $strlen_var; ++$c) {
    295295
    296                     $ord_var_c = ord($var{$c});
     296                    $ord_var_c = ord($var[$c]);
    297297
    298298                    switch (true) {
     
    317317                        case $ord_var_c == 0x5C:
    318318                            // double quote, slash, slosh
    319                             $ascii .= '\\'.$var{$c};
     319                            $ascii .= '\\'.$var[$c];
    320320                            break;
    321321
    322322                        case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
    323323                            // characters U-00000000 - U-0000007F (same as ASCII)
    324                             $ascii .= $var{$c};
     324                            $ascii .= $var[$c];
    325325                            break;
    326326
     
    334334                            }
    335335
    336                             $char = pack('C*', $ord_var_c, ord($var{$c + 1}));
     336                            $char = pack('C*', $ord_var_c, ord($var[$c + 1]));
    337337                            $c += 1;
    338338                            $utf16 = $this->utf82utf16($char);
     
    349349                            // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
    350350                            $char = pack('C*', $ord_var_c,
    351                                         @ord($var{$c + 1}),
    352                                         @ord($var{$c + 2}));
     351                                        @ord($var[$c + 1]),
     352                                        @ord($var[$c + 2]));
    353353                            $c += 2;
    354354                            $utf16 = $this->utf82utf16($char);
     
    365365                            // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
    366366                            $char = pack('C*', $ord_var_c,
    367                                         ord($var{$c + 1}),
    368                                         ord($var{$c + 2}),
    369                                         ord($var{$c + 3}));
     367                                        ord($var[$c + 1]),
     368                                        ord($var[$c + 2]),
     369                                        ord($var[$c + 3]));
    370370                            $c += 3;
    371371                            $utf16 = $this->utf82utf16($char);
     
    382382                            }
    383383                            $char = pack('C*', $ord_var_c,
    384                                         ord($var{$c + 1}),
    385                                         ord($var{$c + 2}),
    386                                         ord($var{$c + 3}),
    387                                         ord($var{$c + 4}));
     384                                        ord($var[$c + 1]),
     385                                        ord($var[$c + 2]),
     386                                        ord($var[$c + 3]),
     387                                        ord($var[$c + 4]));
    388388                            $c += 4;
    389389                            $utf16 = $this->utf82utf16($char);
     
    400400                            // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
    401401                            $char = pack('C*', $ord_var_c,
    402                                         ord($var{$c + 1}),
    403                                         ord($var{$c + 2}),
    404                                         ord($var{$c + 3}),
    405                                         ord($var{$c + 4}),
    406                                         ord($var{$c + 5}));
     402                                        ord($var[$c + 1]),
     403                                        ord($var[$c + 2]),
     404                                        ord($var[$c + 3]),
     405                                        ord($var[$c + 4]),
     406                                        ord($var[$c + 5]));
    407407                            $c += 5;
    408408                            $utf16 = $this->utf82utf16($char);
     
    578578
    579579                        $substr_chrs_c_2 = substr($chrs, $c, 2);
    580                         $ord_chrs_c = ord($chrs{$c});
     580                        $ord_chrs_c = ord($chrs[$c]);
    581581
    582582                        switch (true) {
     
    608608                                if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
    609609                                ($delim == "'" && $substr_chrs_c_2 != '\\"')) {
    610                                     $utf8 .= $chrs{++$c};
     610                                    $utf8 .= $chrs[++$c];
    611611                                }
    612612                                break;
     
    621621
    622622                            case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
    623                                 $utf8 .= $chrs{$c};
     623                                $utf8 .= $chrs[$c];
    624624                                break;
    625625
     
    668668                    // array, or object notation
    669669
    670                     if ($str{0} == '[') {
     670                    if ($str[0] == '[') {
    671671                        $stk = array(SERVICES_JSON_IN_ARR);
    672672                        $arr = array();
     
    707707                        $substr_chrs_c_2 = substr($chrs, $c, 2);
    708708
    709                         if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
     709                        if (($c == $strlen_chrs) || (($chrs[$c] == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
    710710                            // found a comma that is not inside a string, array, etc.,
    711711                            // OR we've reached the end of the character list
     
    749749                            }
    750750
    751                         } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
     751                        } elseif ((($chrs[$c] == '"') || ($chrs[$c] == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
    752752                            // found a quote, and we are not inside a string
    753                             array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
     753                            array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs[$c]));
    754754                            //print("Found start of string at {$c}\n");
    755755
    756                         } elseif (($chrs{$c} == $top['delim']) &&
     756                        } elseif (($chrs[$c] == $top['delim']) &&
    757757                                ($top['what'] == SERVICES_JSON_IN_STR) &&
    758758                                ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
     
    763763                            //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
    764764
    765                         } elseif (($chrs{$c} == '[') &&
     765                        } elseif (($chrs[$c] == '[') &&
    766766                                in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
    767767                            // found a left-bracket, and we are in an array, object, or slice
     
    769769                            //print("Found start of array at {$c}\n");
    770770
    771                         } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
     771                        } elseif (($chrs[$c] == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
    772772                            // found a right-bracket, and we're in an array
    773773                            array_pop($stk);
    774774                            //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
    775775
    776                         } elseif (($chrs{$c} == '{') &&
     776                        } elseif (($chrs[$c] == '{') &&
    777777                                in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
    778778                            // found a left-brace, and we are in an array, object, or slice
     
    780780                            //print("Found start of object at {$c}\n");
    781781
    782                         } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
     782                        } elseif (($chrs[$c] == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
    783783                            // found a right-brace, and we're in an object
    784784                            array_pop($stk);
  • trunk/wp-includes/class-pop3.php

    r9503 r16340  
    368368        while ( !ereg("^\.\r\n",$line))
    369369        {
    370             if ( $line{0} == '.' ) { $line = substr($line,1); }
     370            if ( $line[0] == '.' ) { $line = substr($line,1); }
    371371            $MsgArray[$count] = $line;
    372372            $count++;
  • trunk/wp-includes/formatting.php

    r16313 r16340  
    9393        $curl = $textarr[$i];
    9494
    95         if ( !empty($curl) && '<' != $curl{0} && '[' != $curl{0}
     95        if ( !empty($curl) && '<' != $curl[0] && '[' != $curl[0]
    9696                && empty($no_texturize_shortcodes_stack) && empty($no_texturize_tags_stack)) {
    9797            // This is not a tag, nor is the texturization disabled
     
    114114             * tag opening
    115115             */
    116             if ('<' == $curl{0})
     116            if ('<' == $curl[0])
    117117                _wptexturize_pushpop_element($curl, $no_texturize_tags_stack, $no_texturize_tags, '<', '>');
    118             elseif ('[' == $curl{0})
     118            elseif ('[' == $curl[0])
    119119                _wptexturize_pushpop_element($curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes, '[', ']');
    120120        }
     
    14991499        for ($i = 0; $i < $stop; $i++) {
    15001500            $content = $textarr[$i];
    1501             if ((strlen($content) > 0) && ('<' != $content{0})) { // If it's not a tag
     1501            if ((strlen($content) > 0) && ('<' != $content[0])) { // If it's not a tag
    15021502                $content = preg_replace_callback($wp_smiliessearch, 'translate_smiley', $content);
    15031503            }
     
    26332633
    26342634        // Fragment has a specifier
    2635         if ( $pattern{$start} == '%' ) {
     2635        if ( $pattern[$start] == '%' ) {
    26362636            // Find numbered arguments or take the next one in order
    26372637            if ( preg_match('/^%(\d+)\$/', $fragment, $matches) ) {
  • trunk/wp-includes/functions.php

    r16303 r16340  
    20822082        return true;
    20832083
    2084     if ( strlen($path) == 0 || $path{0} == '.' )
     2084    if ( strlen($path) == 0 || $path[0] == '.' )
    20852085        return false;
    20862086
  • trunk/wp-includes/pluggable.php

    r16304 r16340  
    16591659    } else {
    16601660        if ( !empty($email) )
    1661             $host = sprintf( "http://%d.gravatar.com", ( hexdec( $email_hash{0} ) % 2 ) );
     1661            $host = sprintf( "http://%d.gravatar.com", ( hexdec( $email_hash[0] ) % 2 ) );
    16621662        else
    16631663            $host = 'http://0.gravatar.com';
  • trunk/wp-includes/post-template.php

    r16334 r16340  
    728728        foreach ( (array) $keys as $key ) {
    729729            $keyt = trim($key);
    730             if ( '_' == $keyt{0} )
     730            if ( '_' == $keyt[0] )
    731731                continue;
    732732            $values = array_map('trim', get_post_custom_values($key));
  • trunk/wp-includes/rewrite.php

    r16069 r16340  
    3535function add_rewrite_tag($tagname, $regex) {
    3636    //validation
    37     if ( strlen($tagname) < 3 || $tagname{0} != '%' || $tagname{strlen($tagname)-1} != '%' )
     37    if ( strlen($tagname) < 3 || $tagname[0] != '%' || $tagname[strlen($tagname)-1] != '%' )
    3838        return;
    3939
  • trunk/wp-includes/theme.php

    r16174 r16340  
    598598        while ( ($theme_dir = readdir($themes_dir)) !== false ) {
    599599            if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) {
    600                 if ( $theme_dir{0} == '.' || $theme_dir == 'CVS' )
     600                if ( $theme_dir[0] == '.' || $theme_dir == 'CVS' )
    601601                    continue;
    602602
     
    621621                    while ( ($theme_subdir = readdir($theme_subdirs)) !== false ) {
    622622                        if ( is_dir( $subdir . '/' . $theme_subdir) && is_readable($subdir . '/' . $theme_subdir) ) {
    623                             if ( $theme_subdir{0} == '.' || $theme_subdir == 'CVS' )
     623                            if ( $theme_subdir[0] == '.' || $theme_subdir == 'CVS' )
    624624                                continue;
    625625
Note: See TracChangeset for help on using the changeset viewer.