Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/46' into develop
Browse files Browse the repository at this point in the history
Forward port #46
  • Loading branch information
michalbundyra committed Oct 9, 2019
2 parents 3b0fe1a + 41b3963 commit bb1d921
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Expand Up @@ -44,7 +44,9 @@ All notable changes to this project will be documented in this file, in reverse

### Fixed

- Nothing.
- [#46](https://github.com/zendframework/zend-json/pull/46) changes
curly braces in array and string offset access to square brackets
in order to prevent issues under the upcoming PHP 7.4 release.

## 3.1.1 - 2019-06-18

Expand Down
12 changes: 6 additions & 6 deletions src/Decoder.php
Expand Up @@ -107,7 +107,7 @@ public static function decodeUnicodeString($chrs)
$i += 5;
break;
case ($ordChrsC >= 0x20) && ($ordChrsC <= 0x7F):
$utf8 .= $chrs{$i};
$utf8 .= $chrs[$i];
break;
case ($ordChrsC & 0xE0) == 0xC0:
// characters U-00000080 - U-000007FF, mask 110XXXXX
Expand Down Expand Up @@ -362,7 +362,7 @@ protected function getNextToken()
$i = $this->offset;
$start = $i;

switch ($str{$i}) {
switch ($str[$i]) {
case '{':
$this->token = self::LBRACE;
break;
Expand All @@ -389,7 +389,7 @@ protected function getNextToken()
break;
}

$chr = $str{$i};
$chr = $str[$i];

if ($chr === '"') {
break;
Expand All @@ -406,7 +406,7 @@ protected function getNextToken()
break;
}

$chr = $str{$i};
$chr = $str[$i];
switch ($chr) {
case '"':
$result .= '"';
Expand Down Expand Up @@ -471,7 +471,7 @@ protected function getNextToken()
return ($this->token);
}

$chr = $str{$i};
$chr = $str[$i];

if ($chr !== '-' && $chr !== '.' && ($chr < '0' || $chr > '9')) {
throw new RuntimeException('Illegal Token');
Expand Down Expand Up @@ -521,7 +521,7 @@ protected static function utf162utf8($utf16)
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):
Expand Down
8 changes: 4 additions & 4 deletions src/Encoder.php
Expand Up @@ -585,14 +585,14 @@ protected static function utf82utf16($utf8)
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])));
}

// ignoring UTF-32 for now, sorry
Expand Down

0 comments on commit bb1d921

Please sign in to comment.