From 4207ab0c63609cdc3291b9c16c9fa01178dda374 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Sun, 17 Apr 2011 07:59:58 +0000 Subject: [PATCH] * (bug 28511) Use [] syntax instead of {} for string offset access --- includes/EditPage.php | 8 +-- includes/Fallback.php | 6 +- includes/GlobalFunctions.php | 2 +- includes/MacBinary.php | 10 +-- includes/User.php | 2 +- includes/WebRequest.php | 2 +- includes/filerepo/ForeignAPIFile.php | 2 +- includes/json/Services_JSON.php | 78 ++++++++++++------------ includes/normal/UtfNormal.php | 40 ++++++------ includes/normal/UtfNormalUtil.php | 4 +- includes/parser/DateFormatter.php | 8 +-- includes/parser/Parser.php | 4 +- includes/specials/SpecialBooksources.php | 10 +-- includes/specials/SpecialUserrights.php | 2 +- 14 files changed, 89 insertions(+), 89 deletions(-) diff --git a/includes/EditPage.php b/includes/EditPage.php index fb6f2bc71e..9b6f6a0ef7 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -2661,7 +2661,7 @@ HTML $result = ""; $working = 0; for( $i = 0; $i < strlen( $invalue ); $i++ ) { - $bytevalue = ord( $invalue{$i} ); + $bytevalue = ord( $invalue[$i] ); if ( $bytevalue <= 0x7F ) { //0xxx xxxx $result .= chr( $bytevalue ); $bytesleft = 0; @@ -2698,13 +2698,13 @@ HTML function unmakesafe( $invalue ) { $result = ""; for( $i = 0; $i < strlen( $invalue ); $i++ ) { - if ( ( substr( $invalue, $i, 3 ) == "&#x" ) && ( $invalue{$i+3} != '0' ) ) { + if ( ( substr( $invalue, $i, 3 ) == "&#x" ) && ( $invalue[$i+3] != '0' ) ) { $i += 3; $hexstring = ""; do { - $hexstring .= $invalue{$i}; + $hexstring .= $invalue[$i]; $i++; - } while( ctype_xdigit( $invalue{$i} ) && ( $i < strlen( $invalue ) ) ); + } while( ctype_xdigit( $invalue[$i] ) && ( $i < strlen( $invalue ) ) ); // Do some sanity checks. These aren't needed for reversability, // but should help keep the breakage down if the editor diff --git a/includes/Fallback.php b/includes/Fallback.php index c5f7c28613..81ca6ad19c 100644 --- a/includes/Fallback.php +++ b/includes/Fallback.php @@ -76,7 +76,7 @@ class Fallback { // This will cut out most of our slow time on Latin-based text, // and 1/2 to 1/3 on East European and Asian scripts. $bytePos = $splitPos; - while ( $bytePos < $byteLen && $str{$bytePos} >= "\x80" && $str{$bytePos} < "\xc0" ) { + while ( $bytePos < $byteLen && $str[$bytePos] >= "\x80" && $str[$bytePos] < "\xc0" ) { ++$bytePos; } $charPos = mb_strlen( substr( $str, 0, $bytePos ) ); @@ -88,7 +88,7 @@ class Fallback { while( $charPos++ < $splitPos ) { ++$bytePos; // Move past any tail bytes - while ( $bytePos < $byteLen && $str{$bytePos} >= "\x80" && $str{$bytePos} < "\xc0" ) { + while ( $bytePos < $byteLen && $str[$bytePos] >= "\x80" && $str[$bytePos] < "\xc0" ) { ++$bytePos; } } @@ -99,7 +99,7 @@ class Fallback { while( $bytePos > 0 && $charPos-- >= $splitPosX ) { --$bytePos; // Move past any tail bytes - while ( $bytePos > 0 && $str{$bytePos} >= "\x80" && $str{$bytePos} < "\xc0" ) { + while ( $bytePos > 0 && $str[$bytePos] >= "\x80" && $str[$bytePos] < "\xc0" ) { --$bytePos; } } diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 73afefaffa..0c88816663 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2714,7 +2714,7 @@ function wfBaseConvert( $input, $sourceBase, $destBase, $pad = 1, $lowercase = t // Decode and validate input string $input = strtolower( $input ); for( $i = 0; $i < strlen( $input ); $i++ ) { - $n = strpos( $digitChars, $input{$i} ); + $n = strpos( $digitChars, $input[$i] ); if( $n === false || $n > $sourceBase ) { return false; } diff --git a/includes/MacBinary.php b/includes/MacBinary.php index 0c38a64110..6643c074e9 100644 --- a/includes/MacBinary.php +++ b/includes/MacBinary.php @@ -110,7 +110,7 @@ class MacBinary { return false; } - if( $head{0} != "\x00" || $head{74} != "\x00" ) { + if( $head[0] != "\x00" || $head[74] != "\x00" ) { wfDebug( "$fname: header bytes 0 and 74 not null\n" ); return false; } @@ -127,7 +127,7 @@ class MacBinary { } } else { $crc = sprintf( "%x != %x", $storedCRC, $calculatedCRC ); - if( $storedCRC == 0 && $head{82} == "\x00" && + if( $storedCRC == 0 && $head[82] == "\x00" && substr( $head, 101, 24 ) == str_repeat( "\x00", 24 ) ) { wfDebug( "$fname: no CRC, looks like MacBinary I\n" ); $this->version = 1; @@ -142,7 +142,7 @@ class MacBinary { } } - $nameLength = ord( $head{1} ); + $nameLength = ord( $head[1] ); if( $nameLength < 1 || $nameLength > 63 ) { wfDebug( "$fname: invalid filename size $nameLength\n" ); return false; @@ -220,7 +220,7 @@ class MacBinary { $len = strlen( $data ); $crc = $seed; for( $i = 0; $i < $len; $i++ ) { - $crc ^= ord( $data{$i} ) << 8; + $crc ^= ord( $data[$i] ) << 8; $crc &= 0xFFFF; $crc = ($crc << 8) ^ $MAGIC[$crc >> 8]; $crc &= 0xFFFF; @@ -257,7 +257,7 @@ class MacBinary { $line = sprintf( "%04x:", $at ); $printable = ''; for( $i = 0; $i < $width && $remaining - $i > 0; $i++ ) { - $byte = ord( $data{$at++} ); + $byte = ord( $data[$at++] ); $line .= sprintf( " %02x", $byte ); $printable .= ($byte >= 32 && $byte <= 126 ) ? chr( $byte ) diff --git a/includes/User.php b/includes/User.php index 3ffd4a9276..4f539a293d 100644 --- a/includes/User.php +++ b/includes/User.php @@ -821,7 +821,7 @@ class User { $digit = mt_rand( 0, $pwlength - 1 ); $np = ''; for ( $i = 0; $i < $pwlength; $i++ ) { - $np .= $i == $digit ? chr( mt_rand( 48, 57 ) ) : $pwchars{ mt_rand( 0, $l ) }; + $np .= $i == $digit ? chr( mt_rand( 48, 57 ) ) : $pwchars[ mt_rand( 0, $l ) ]; } return $np; } diff --git a/includes/WebRequest.php b/includes/WebRequest.php index f76f12c397..41077d30de 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -526,7 +526,7 @@ class WebRequest { if( $hash !== false ) { $base = substr( $base, 0, $hash ); } - if( $base{0} == '/' ) { + if( $base[0] == '/' ) { return $base; } else { // We may get paths with a host prepended; strip it. diff --git a/includes/filerepo/ForeignAPIFile.php b/includes/filerepo/ForeignAPIFile.php index f6ecad238a..a56131a626 100644 --- a/includes/filerepo/ForeignAPIFile.php +++ b/includes/filerepo/ForeignAPIFile.php @@ -196,7 +196,7 @@ class ForeignAPIFile extends File { $handle = opendir( $dir ); if ( $handle ) { while ( false !== ( $file = readdir($handle) ) ) { - if ( $file{0} != '.' ) { + if ( $file[0] != '.' ) { $files[] = $file; } } diff --git a/includes/json/Services_JSON.php b/includes/json/Services_JSON.php index a0433b015d..5261a6ae48 100644 --- a/includes/json/Services_JSON.php +++ b/includes/json/Services_JSON.php @@ -168,7 +168,7 @@ class Services_JSON return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16'); } - $bytes = (ord($utf16{0}) << 8) | ord($utf16{1}); + $bytes = (ord($utf16[0]) << 8) | ord($utf16[1]); switch(true) { case ((0x7F & $bytes) == $bytes): @@ -182,11 +182,11 @@ class Services_JSON return chr(0xC0 | (($bytes >> 6) & 0x1F)) . chr(0x80 | ($bytes & 0x3F)); - case (0xFC00 & $bytes) == 0xD800 && strlen($utf16) >= 4 && (0xFC & ord($utf16{2})) == 0xDC: + case (0xFC00 & $bytes) == 0xD800 && strlen($utf16) >= 4 && (0xFC & ord($utf16[2])) == 0xDC: // return a 4-byte UTF-8 character $char = ((($bytes & 0x03FF) << 10) - | ((ord($utf16{2}) & 0x03) << 8) - | ord($utf16{3})); + | ((ord($utf16[2]) & 0x03) << 8) + | ord($utf16[3])); $char += 0x10000; return chr(0xF0 | (($char >> 18) & 0x07)) . chr(0x80 | (($char >> 12) & 0x3F)) @@ -232,25 +232,25 @@ class Services_JSON case 2: // return a UTF-16 character from a 2-byte UTF-8 char // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr(0x07 & (ord($utf8{0}) >> 2)) - . chr((0xC0 & (ord($utf8{0}) << 6)) - | (0x3F & ord($utf8{1}))); + return chr(0x07 & (ord($utf8[0]) >> 2)) + . chr((0xC0 & (ord($utf8[0]) << 6)) + | (0x3F & ord($utf8[1]))); case 3: // return a UTF-16 character from a 3-byte UTF-8 char // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr((0xF0 & (ord($utf8{0}) << 4)) - | (0x0F & (ord($utf8{1}) >> 2))) - . chr((0xC0 & (ord($utf8{1}) << 6)) - | (0x7F & ord($utf8{2}))); + return chr((0xF0 & (ord($utf8[0]) << 4)) + | (0x0F & (ord($utf8[1]) >> 2))) + . chr((0xC0 & (ord($utf8[1]) << 6)) + | (0x7F & ord($utf8[2]))); case 4: // return a UTF-16 surrogate pair from a 4-byte UTF-8 char - if(ord($utf8{0}) > 0xF4) return ''; # invalid - $char = ((0x1C0000 & (ord($utf8{0}) << 18)) - | (0x03F000 & (ord($utf8{1}) << 12)) - | (0x000FC0 & (ord($utf8{2}) << 6)) - | (0x00003F & ord($utf8{3}))); + if(ord($utf8[0]) > 0xF4) return ''; # invalid + $char = ((0x1C0000 & (ord($utf8[0]) << 18)) + | (0x03F000 & (ord($utf8[1]) << 12)) + | (0x000FC0 & (ord($utf8[2]) << 6)) + | (0x00003F & ord($utf8[3]))); if($char > 0x10FFFF) return ''; # invalid $char -= 0x10000; return chr(0xD8 | (($char >> 18) & 0x03)) @@ -331,7 +331,7 @@ class Services_JSON */ for ($c = 0; $c < $strlen_var; ++$c) { - $ord_var_c = ord($var{$c}); + $ord_var_c = ord($var[$c]); switch (true) { case $ord_var_c == 0x08: @@ -354,18 +354,18 @@ class Services_JSON case $ord_var_c == 0x2F: case $ord_var_c == 0x5C: // double quote, slash, slosh - $ascii .= '\\'.$var{$c}; + $ascii .= '\\'.$var[$c]; break; case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): // characters U-00000000 - U-0000007F (same as ASCII) - $ascii .= $var{$c}; + $ascii .= $var[$c]; break; case (($ord_var_c & 0xE0) == 0xC0): // characters U-00000080 - U-000007FF, mask 110XXXXX // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, ord($var{$c + 1})); + $char = pack('C*', $ord_var_c, ord($var[$c + 1])); $c += 1; $utf16 = $this->utf82utf16($char); $ascii .= sprintf('\u%04s', bin2hex($utf16)); @@ -375,8 +375,8 @@ class Services_JSON // characters U-00000800 - U-0000FFFF, mask 1110XXXX // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2})); + ord($var[$c + 1]), + ord($var[$c + 2])); $c += 2; $utf16 = $this->utf82utf16($char); $ascii .= sprintf('\u%04s', bin2hex($utf16)); @@ -387,9 +387,9 @@ class Services_JSON // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 // These will always return a surrogate pair $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2}), - ord($var{$c + 3})); + ord($var[$c + 1]), + ord($var[$c + 2]), + ord($var[$c + 3])); $c += 3; $utf16 = $this->utf82utf16($char); if($utf16 == '') { @@ -575,7 +575,7 @@ class Services_JSON for ($c = 0; $c < $strlen_chrs; ++$c) { $substr_chrs_c_2 = substr($chrs, $c, 2); - $ord_chrs_c = ord($chrs{$c}); + $ord_chrs_c = ord($chrs[$c]); switch (true) { case $substr_chrs_c_2 == '\b': @@ -605,7 +605,7 @@ class Services_JSON case $substr_chrs_c_2 == '\\/': if (($delim == '"' && $substr_chrs_c_2 != '\\\'') || ($delim == "'" && $substr_chrs_c_2 != '\\"')) { - $utf8 .= $chrs{++$c}; + $utf8 .= $chrs[++$c]; } break; @@ -628,7 +628,7 @@ class Services_JSON break; case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F): - $utf8 .= $chrs{$c}; + $utf8 .= $chrs[$c]; break; case ($ord_chrs_c & 0xE0) == 0xC0: @@ -675,7 +675,7 @@ class Services_JSON } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) { // array, or object notation - if ($str{0} == '[') { + if ($str[0] == '[') { $stk = array(SERVICES_JSON_IN_ARR); $arr = array(); } else { @@ -714,7 +714,7 @@ class Services_JSON $top = end($stk); $substr_chrs_c_2 = substr($chrs, $c, 2); - if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) { + if (($c == $strlen_chrs) || (($chrs[$c] == ',') && ($top['what'] == SERVICES_JSON_SLICE))) { // found a comma that is not inside a string, array, etc., // OR we've reached the end of the character list $slice = substr($chrs, $top['where'], ($c - $top['where'])); @@ -756,37 +756,37 @@ class Services_JSON } - } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) { + } elseif ((($chrs[$c] == '"') || ($chrs[$c] == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) { // found a quote, and we are not inside a string - array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c})); + array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs[$c])); //print("Found start of string at {$c}\n"); - } elseif (($chrs{$c} == $top['delim']) && + } elseif (($chrs[$c] == $top['delim']) && ($top['what'] == SERVICES_JSON_IN_STR) && - (($chrs{$c - 1} != '\\') || - ($chrs{$c - 1} == '\\' && $chrs{$c - 2} == '\\'))) { + (($chrs[$c - 1] != '\\') || + ($chrs[$c - 1] == '\\' && $chrs[$c - 2] == '\\'))) { // found a quote, we're in a string, and it's not escaped array_pop($stk); //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n"); - } elseif (($chrs{$c} == '[') && + } elseif (($chrs[$c] == '[') && in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { // found a left-bracket, and we are in an array, object, or slice array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false)); //print("Found start of array at {$c}\n"); - } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) { + } elseif (($chrs[$c] == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) { // found a right-bracket, and we're in an array array_pop($stk); //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); - } elseif (($chrs{$c} == '{') && + } elseif (($chrs[$c] == '{') && in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { // found a left-brace, and we are in an array, object, or slice array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false)); //print("Found start of object at {$c}\n"); - } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) { + } elseif (($chrs[$c] == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) { // found a right-brace, and we're in an object array_pop($stk); //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); diff --git a/includes/normal/UtfNormal.php b/includes/normal/UtfNormal.php index 116fb8f083..46682ca042 100644 --- a/includes/normal/UtfNormal.php +++ b/includes/normal/UtfNormal.php @@ -210,7 +210,7 @@ class UtfNormal { UtfNormal::loadData(); $len = strlen( $string ); for( $i = 0; $i < $len; $i++ ) { - $c = $string{$i}; + $c = $string[$i]; $n = ord( $c ); if( $n < 0x80 ) { continue; @@ -301,7 +301,7 @@ class UtfNormal { foreach( $matches[1] as $str ) { $chunk = strlen( $str ); - if( $str{0} < "\x80" ) { + if( $str[0] < "\x80" ) { # ASCII chunk: guaranteed to be valid UTF-8 # and in normal form C, so skip over it. $base += $chunk; @@ -319,13 +319,13 @@ class UtfNormal { $len = $chunk + 1; # Counting down is faster. I'm *so* sorry. for( $i = -1; --$len; ) { - $remaining = $tailBytes[$c = $str{++$i}]; + $remaining = $tailBytes[$c = $str[++$i]]; if( $remaining ) { # UTF-8 head byte! $sequence = $head = $c; do { # Look for the defined number of tail bytes... - if( --$len && ( $c = $str{++$i} ) >= "\x80" && $c < "\xc0" ) { + if( --$len && ( $c = $str[++$i] ) >= "\x80" && $c < "\xc0" ) { # Legal tail bytes are nice. $sequence .= $c; } else { @@ -513,7 +513,7 @@ class UtfNormal { $len = strlen( $string ); $out = ''; for( $i = 0; $i < $len; $i++ ) { - $c = $string{$i}; + $c = $string[$i]; $n = ord( $c ); if( $n < 0x80 ) { # ASCII chars never decompose @@ -540,9 +540,9 @@ class UtfNormal { # A lookup table would be slightly faster, # but adds a lot of memory & disk needs. # - $index = ( (ord( $c{0} ) & 0x0f) << 12 - | (ord( $c{1} ) & 0x3f) << 6 - | (ord( $c{2} ) & 0x3f) ) + $index = ( (ord( $c[0] ) & 0x0f) << 12 + | (ord( $c[1] ) & 0x3f) << 6 + | (ord( $c[2] ) & 0x3f) ) - UNICODE_HANGUL_FIRST; $l = intval( $index / UNICODE_HANGUL_NCOUNT ); $v = intval( ($index % UNICODE_HANGUL_NCOUNT) / UNICODE_HANGUL_TCOUNT); @@ -575,7 +575,7 @@ class UtfNormal { $combiners = array(); $lastClass = -1; for( $i = 0; $i < $len; $i++ ) { - $c = $string{$i}; + $c = $string[$i]; $n = ord( $c ); if( $n >= 0x80 ) { if( $n >= 0xf0 ) { @@ -631,7 +631,7 @@ class UtfNormal { $x1 = ord(substr(UTF8_HANGUL_VBASE,0,1)); $x2 = ord(substr(UTF8_HANGUL_TEND,0,1)); for( $i = 0; $i < $len; $i++ ) { - $c = $string{$i}; + $c = $string[$i]; $n = ord( $c ); if( $n < 0x80 ) { # No combining characters here... @@ -691,8 +691,8 @@ class UtfNormal { # #$lIndex = utf8ToCodepoint( $startChar ) - UNICODE_HANGUL_LBASE; #$vIndex = utf8ToCodepoint( $c ) - UNICODE_HANGUL_VBASE; - $lIndex = ord( $startChar{2} ) - 0x80; - $vIndex = ord( $c{2} ) - 0xa1; + $lIndex = ord( $startChar[2] ) - 0x80; + $vIndex = ord( $c[2] ) - 0xa1; $hangulPoint = UNICODE_HANGUL_FIRST + UNICODE_HANGUL_TCOUNT * @@ -710,23 +710,23 @@ class UtfNormal { $startChar <= UTF8_HANGUL_LAST && !$lastHangul ) { # $tIndex = utf8ToCodepoint( $c ) - UNICODE_HANGUL_TBASE; - $tIndex = ord( $c{2} ) - 0xa7; - if( $tIndex < 0 ) $tIndex = ord( $c{2} ) - 0x80 + (0x11c0 - 0x11a7); + $tIndex = ord( $c[2] ) - 0xa7; + if( $tIndex < 0 ) $tIndex = ord( $c[2] ) - 0x80 + (0x11c0 - 0x11a7); # Increment the code point by $tIndex, without # the function overhead of decoding and recoding UTF-8 # - $tail = ord( $startChar{2} ) + $tIndex; + $tail = ord( $startChar[2] ) + $tIndex; if( $tail > 0xbf ) { $tail -= 0x40; - $mid = ord( $startChar{1} ) + 1; + $mid = ord( $startChar[1] ) + 1; if( $mid > 0xbf ) { - $startChar{0} = chr( ord( $startChar{0} ) + 1 ); + $startChar[0] = chr( ord( $startChar[0] ) + 1 ); $mid -= 0x40; } - $startChar{1} = chr( $mid ); + $startChar[1] = chr( $mid ); } - $startChar{2} = chr( $tail ); + $startChar[2] = chr( $tail ); # If there's another jamo char after this, *don't* try to merge it. $lastHangul = 1; @@ -755,7 +755,7 @@ class UtfNormal { $len = strlen( $string ); $out = ''; for( $i = 0; $i < $len; $i++ ) { - $out .= $string{$i}; + $out .= $string[$i]; } return $out; } diff --git a/includes/normal/UtfNormalUtil.php b/includes/normal/UtfNormalUtil.php index e470a8bfb3..bfad709553 100644 --- a/includes/normal/UtfNormalUtil.php +++ b/includes/normal/UtfNormalUtil.php @@ -91,7 +91,7 @@ function utf8ToHexSequence( $str ) { */ function utf8ToCodepoint( $char ) { # Find the length - $z = ord( $char{0} ); + $z = ord( $char[0] ); if ( $z & 0x80 ) { $length = 0; while ( $z & 0x80 ) { @@ -116,7 +116,7 @@ function utf8ToCodepoint( $char ) { # Add in the free bits from subsequent bytes for ( $i=1; $i<$length; $i++ ) { $z <<= 6; - $z |= ord( $char{$i} ) & 0x3f; + $z |= ord( $char[$i] ) & 0x3f; } return $z; diff --git a/includes/parser/DateFormatter.php b/includes/parser/DateFormatter.php index cf5101712a..6559e88660 100644 --- a/includes/parser/DateFormatter.php +++ b/includes/parser/DateFormatter.php @@ -182,8 +182,8 @@ class DateFormatter $bits = array(); $key = $this->keys[$this->mSource]; for ( $p=0; $p < strlen($key); $p++ ) { - if ( $key{$p} != ' ' ) { - $bits[$key{$p}] = $matches[$p+1]; + if ( $key[$p] != ' ' ) { + $bits[$key[$p]] = $matches[$p+1]; } } @@ -224,7 +224,7 @@ class DateFormatter } for ( $p=0; $p < strlen( $format ); $p++ ) { - $char = $format{$p}; + $char = $format[$p]; switch ( $char ) { case 'd': # ISO day of month $text .= $bits['d']; @@ -327,7 +327,7 @@ class DateFormatter * @todo document */ function makeNormalYear( $iso ) { - if ( $iso{0} == '-' ) { + if ( $iso[0] == '-' ) { $text = (intval( substr( $iso, 1 ) ) + 1) . ' BC'; } else { $text = intval( $iso ); diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 28e1cda04d..c367c89ae7 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -2152,7 +2152,7 @@ class Parser { } for ( $i = 0; $i < $shorter; ++$i ) { - if ( $st1{$i} != $st2{$i} ) { + if ( $st1[$i] != $st2[$i] ) { break; } } @@ -2450,7 +2450,7 @@ class Parser { $stack = 0; $len = strlen( $str ); for( $i = 0; $i < $len; $i++ ) { - $c = $str{$i}; + $c = $str[$i]; switch( $state ) { # (Using the number is a performance hack for common cases) diff --git a/includes/specials/SpecialBooksources.php b/includes/specials/SpecialBooksources.php index 13a651d279..33defedb85 100644 --- a/includes/specials/SpecialBooksources.php +++ b/includes/specials/SpecialBooksources.php @@ -72,26 +72,26 @@ class SpecialBookSources extends SpecialPage { if( strlen( $isbn ) == 13 ) { for( $i = 0; $i < 12; $i++ ) { if($i % 2 == 0) { - $sum += $isbn{$i}; + $sum += $isbn[$i]; } else { - $sum += 3 * $isbn{$i}; + $sum += 3 * $isbn[$i]; } } $check = (10 - ($sum % 10)) % 10; - if ($check == $isbn{12}) { + if ($check == $isbn[12]) { return true; } } elseif( strlen( $isbn ) == 10 ) { for($i = 0; $i < 9; $i++) { - $sum += $isbn{$i} * ($i + 1); + $sum += $isbn[$i] * ($i + 1); } $check = $sum % 11; if($check == 10) { $check = "X"; } - if($check == $isbn{9}) { + if($check == $isbn[9]) { return true; } } diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php index a2ef09c6b4..526f756bde 100644 --- a/includes/specials/SpecialUserrights.php +++ b/includes/specials/SpecialUserrights.php @@ -317,7 +317,7 @@ class UserrightsPage extends SpecialPage { return Status::newFatal( 'nouserspecified' ); } - if( $name{0} == '#' ) { + if( $name[0] == '#' ) { // Numeric ID can be specified... // We'll do a lookup for the name internally. $id = intval( substr( $name, 1 ) ); -- 2.20.1