Browse Source

Style fixes

multi-byte
J. King 4 years ago
parent
commit
a57dde6dbd
  1. 2
      lib/Encoding/Big5.php
  2. 2
      lib/Encoding/EUCJP.php
  3. 107
      lib/Encoding/Encoder.php
  4. 2
      lib/Encoding/UTF16BE.php
  5. 2
      lib/Encoding/UTF16LE.php
  6. 2
      lib/Encoding/UTF8.php
  7. 1
      tests/cases/Encoding/TestBig5.php
  8. 1
      tests/cases/Encoding/TestEUCJP.php
  9. 1
      tests/cases/Encoding/TestEUCKR.php
  10. 1
      tests/cases/Encoding/TestGB18030.php
  11. 5
      tests/cases/Encoding/TestISO2022JP.php
  12. 3
      tests/cases/Encoding/TestShiftJIS.php
  13. 1
      tests/cases/Encoding/TestSingleByte.php
  14. 1
      tests/cases/Encoding/TestUTF16LE.php
  15. 1
      tests/cases/Encoding/TestUTF8.php
  16. 1
      tests/cases/Encoding/TestXUserDefined.php
  17. 4
      tests/cases/TestEncoding.php

2
lib/Encoding/Big5.php

@ -13,7 +13,7 @@ class Big5 extends AbstractEncoding implements StatelessEncoding {
"big5-hkscs", "big5-hkscs",
"cn-big5", "cn-big5",
"csbig5", "csbig5",
"x-x-big5" "x-x-big5",
]; ];
const TABLE_DOUBLES = [ const TABLE_DOUBLES = [
1133 => [0x00CA, 0x0304], 1133 => [0x00CA, 0x0304],

2
lib/Encoding/EUCJP.php

File diff suppressed because one or more lines are too long

107
lib/Encoding/Encoder.php

@ -22,7 +22,7 @@ class Encoder {
if (!$l || !$l['encoder']) { if (!$l || !$l['encoder']) {
throw new EncoderException("Label '$label' does not have an encoder", Encoder::E_UNAVAILABLE_ENCODER); throw new EncoderException("Label '$label' does not have an encoder", Encoder::E_UNAVAILABLE_ENCODER);
} else { } else {
$this->name = $['name']; $this->name = $s['name'];
$this->fatal = $fatal; $this->fatal = $fatal;
} }
} }
@ -32,41 +32,76 @@ class Encoder {
throw new EncoderException("Encountered code point outside Unicode range ($codePoint)", self::E_INVALID_CODE_POINT); throw new EncoderException("Encountered code point outside Unicode range ($codePoint)", self::E_INVALID_CODE_POINT);
} }
switch ($this->name) { switch ($this->name) {
case "UTF-8": return return UTF8::encode($codePoint, $this->fatal); case "UTF-8":
case "Big5": return Big5::encode($codePoint, $this->fatal); return UTF8::encode($codePoint, $this->fatal);
case "EUC-JP": return EUCJP::encode($codePoint, $this->fatal); case "Big5":
case "EUC-KR": return EUCKR::encode($codePoint, $this->fatal); return Big5::encode($codePoint, $this->fatal);
case "gb18030": return GB18030::encode($codePoint, $this->fatal); case "EUC-JP":
case "GBK": return GBK::encode($codePoint, $this->fatal); return EUCJP::encode($codePoint, $this->fatal);
case "IBM866": return IBM866::encode($codePoint, $this->fatal); case "EUC-KR":
case "ISO-8859-2": return ISO88592::encode($codePoint, $this->fatal); return EUCKR::encode($codePoint, $this->fatal);
case "ISO-8859-3": return ISO88593::encode($codePoint, $this->fatal); case "gb18030":
case "ISO-8859-4": return ISO88594::encode($codePoint, $this->fatal); return GB18030::encode($codePoint, $this->fatal);
case "ISO-8859-5": return ISO88595::encode($codePoint, $this->fatal); case "GBK":
case "ISO-8859-6": return ISO88596::encode($codePoint, $this->fatal); return GBK::encode($codePoint, $this->fatal);
case "ISO-8859-7": return ISO88597::encode($codePoint, $this->fatal); case "IBM866":
case "ISO-8859-8": return ISO88598::encode($codePoint, $this->fatal); return IBM866::encode($codePoint, $this->fatal);
case "ISO-8859-8-I": return ISO88598I::encode($codePoint, $this->fatal); case "ISO-8859-2":
case "ISO-8859-10": return ISO885910::encode($codePoint, $this->fatal); return ISO88592::encode($codePoint, $this->fatal);
case "ISO-8859-13": return ISO885913::encode($codePoint, $this->fatal); case "ISO-8859-3":
case "ISO-8859-14": return ISO885914::encode($codePoint, $this->fatal); return ISO88593::encode($codePoint, $this->fatal);
case "ISO-8859-15": return ISO885915::encode($codePoint, $this->fatal); case "ISO-8859-4":
case "ISO-8859-16": return ISO885916::encode($codePoint, $this->fatal); return ISO88594::encode($codePoint, $this->fatal);
case "KOI8-R": return KOI8R::encode($codePoint, $this->fatal); case "ISO-8859-5":
case "KOI8-U": return KOI8U::encode($codePoint, $this->fatal); return ISO88595::encode($codePoint, $this->fatal);
case "macintosh": return Macintosh::encode($codePoint, $this->fatal); case "ISO-8859-6":
case "Shift_JIS": return ShiftJIS::encode($codePoint, $this->fatal); return ISO88596::encode($codePoint, $this->fatal);
case "windows1250": return Windows1250::encode($codePoint, $this->fatal); case "ISO-8859-7":
case "windows1251": return Windows1251::encode($codePoint, $this->fatal); return ISO88597::encode($codePoint, $this->fatal);
case "windows1252": return Windows1252::encode($codePoint, $this->fatal); case "ISO-8859-8":
case "windows1253": return Windows1253::encode($codePoint, $this->fatal); return ISO88598::encode($codePoint, $this->fatal);
case "windows1254": return Windows1254::encode($codePoint, $this->fatal); case "ISO-8859-8-I":
case "windows1255": return Windows1255::encode($codePoint, $this->fatal); return ISO88598I::encode($codePoint, $this->fatal);
case "windows1256": return Windows1256::encode($codePoint, $this->fatal); case "ISO-8859-10":
case "windows1257": return Windows1257::encode($codePoint, $this->fatal); return ISO885910::encode($codePoint, $this->fatal);
case "windows874": return Windows874::encode($codePoint, $this->fatal); case "ISO-8859-13":
case "x-mac-cyrillic": return XMacCyrillic::encode($codePoint, $this->fatal); return ISO885913::encode($codePoint, $this->fatal);
case "x-user-defined": return XUserDefined::encode($codePoint, $this->fatal); case "ISO-8859-14":
return ISO885914::encode($codePoint, $this->fatal);
case "ISO-8859-15":
return ISO885915::encode($codePoint, $this->fatal);
case "ISO-8859-16":
return ISO885916::encode($codePoint, $this->fatal);
case "KOI8-R":
return KOI8R::encode($codePoint, $this->fatal);
case "KOI8-U":
return KOI8U::encode($codePoint, $this->fatal);
case "macintosh":
return Macintosh::encode($codePoint, $this->fatal);
case "Shift_JIS":
return ShiftJIS::encode($codePoint, $this->fatal);
case "windows1250":
return Windows1250::encode($codePoint, $this->fatal);
case "windows1251":
return Windows1251::encode($codePoint, $this->fatal);
case "windows1252":
return Windows1252::encode($codePoint, $this->fatal);
case "windows1253":
return Windows1253::encode($codePoint, $this->fatal);
case "windows1254":
return Windows1254::encode($codePoint, $this->fatal);
case "windows1255":
return Windows1255::encode($codePoint, $this->fatal);
case "windows1256":
return Windows1256::encode($codePoint, $this->fatal);
case "windows1257":
return Windows1257::encode($codePoint, $this->fatal);
case "windows874":
return Windows874::encode($codePoint, $this->fatal);
case "x-mac-cyrillic":
return XMacCyrillic::encode($codePoint, $this->fatal);
case "x-user-defined":
return XUserDefined::encode($codePoint, $this->fatal);
case "ISO-2022-JP": case "ISO-2022-JP":
if ($codePoint === 0xE || $codePoint === 0xF || $codePoint === 0x1B) { if ($codePoint === 0xE || $codePoint === 0xF || $codePoint === 0x1B) {
return $this->err($codePoint, 0xFFFD); return $this->err($codePoint, 0xFFFD);

2
lib/Encoding/UTF16BE.php

@ -11,6 +11,6 @@ class UTF16BE extends UTF16 {
const NAME = "UTF-16BE"; const NAME = "UTF-16BE";
const LABELS = [ const LABELS = [
"unicodefffe", "unicodefffe",
"utf-16be" "utf-16be",
]; ];
} }

2
lib/Encoding/UTF16LE.php

@ -16,6 +16,6 @@ class UTF16LE extends UTF16 {
"unicode", "unicode",
"unicodefeff", "unicodefeff",
"utf-16", "utf-16",
"utf-16le" "utf-16le",
]; ];
} }

2
lib/Encoding/UTF8.php

@ -14,7 +14,7 @@ class UTF8 extends AbstractEncoding implements StatelessEncoding {
"unicode20utf8", "unicode20utf8",
"utf-8", "utf-8",
"utf8", "utf8",
"x-unicode20utf8" "x-unicode20utf8",
]; ];
protected $selfSynchronizing = true; protected $selfSynchronizing = true;

1
tests/cases/Encoding/TestBig5.php

@ -136,7 +136,6 @@ class TestBig5 extends \MensBeam\Intl\Test\CoderDecoderTest {
return parent::testIterateThroughAStringAllowingSurrogates($input, $strictExp, $relaxedExp); return parent::testIterateThroughAStringAllowingSurrogates($input, $strictExp, $relaxedExp);
} }
/** /**
* @covers MensBeam\Intl\Encoding\Big5::seekBack * @covers MensBeam\Intl\Encoding\Big5::seekBack
*/ */

1
tests/cases/Encoding/TestEUCJP.php

@ -135,7 +135,6 @@ class TestEUCJP extends \MensBeam\Intl\Test\CoderDecoderTest {
return parent::testIterateThroughAStringAllowingSurrogates($input, $strictExp, $relaxedExp); return parent::testIterateThroughAStringAllowingSurrogates($input, $strictExp, $relaxedExp);
} }
/** /**
* @covers MensBeam\Intl\Encoding\EUCJP::seekBack * @covers MensBeam\Intl\Encoding\EUCJP::seekBack
*/ */

1
tests/cases/Encoding/TestEUCKR.php

@ -136,7 +136,6 @@ class TestEUCKR extends \MensBeam\Intl\Test\CoderDecoderTest {
return parent::testIterateThroughAStringAllowingSurrogates($input, $strictExp, $relaxedExp); return parent::testIterateThroughAStringAllowingSurrogates($input, $strictExp, $relaxedExp);
} }
/** /**
* @covers MensBeam\Intl\Encoding\EUCKR::seekBack * @covers MensBeam\Intl\Encoding\EUCKR::seekBack
*/ */

1
tests/cases/Encoding/TestGB18030.php

@ -144,7 +144,6 @@ class TestGB18030 extends \MensBeam\Intl\Test\CoderDecoderTest {
return parent::testIterateThroughAStringAllowingSurrogates($input, $strictExp, $relaxedExp); return parent::testIterateThroughAStringAllowingSurrogates($input, $strictExp, $relaxedExp);
} }
/** /**
* @covers MensBeam\Intl\Encoding\GB18030::seekBack * @covers MensBeam\Intl\Encoding\GB18030::seekBack
*/ */

5
tests/cases/Encoding/TestISO2022JP.php

@ -7,8 +7,6 @@ declare(strict_types=1);
namespace MensBeam\Intl\TestCase\Encoding; namespace MensBeam\Intl\TestCase\Encoding;
use MensBeam\Intl\Encoding\ISO2022JP; use MensBeam\Intl\Encoding\ISO2022JP;
use MensBeam\Intl\Encoding\Encoding;
use MensBeam\Intl\Encoding\EncoderException;
class TestISO2022JP extends \MensBeam\Intl\Test\CoderDecoderTest { class TestISO2022JP extends \MensBeam\Intl\Test\CoderDecoderTest {
protected $testedClass = ISO2022JP::class; protected $testedClass = ISO2022JP::class;
@ -170,7 +168,6 @@ class TestISO2022JP extends \MensBeam\Intl\Test\CoderDecoderTest {
return parent::testIterateThroughAStringAllowingSurrogates($input, $strictExp, $relaxedExp); return parent::testIterateThroughAStringAllowingSurrogates($input, $strictExp, $relaxedExp);
} }
/** /**
* @covers MensBeam\Intl\Encoding\ISO2022JP::seekBack * @covers MensBeam\Intl\Encoding\ISO2022JP::seekBack
*/ */
@ -196,5 +193,3 @@ class TestISO2022JP extends \MensBeam\Intl\Test\CoderDecoderTest {
} }
} }
} }

3
tests/cases/Encoding/TestShiftJIS.php

@ -136,7 +136,6 @@ class TestShiftJIS extends \MensBeam\Intl\Test\CoderDecoderTest {
return parent::testIterateThroughAStringAllowingSurrogates($input, $strictExp, $relaxedExp); return parent::testIterateThroughAStringAllowingSurrogates($input, $strictExp, $relaxedExp);
} }
/** /**
* @covers MensBeam\Intl\Encoding\ShiftJIS::seekBack * @covers MensBeam\Intl\Encoding\ShiftJIS::seekBack
*/ */
@ -208,5 +207,3 @@ class TestShiftJIS extends \MensBeam\Intl\Test\CoderDecoderTest {
} }
} }
} }

1
tests/cases/Encoding/TestSingleByte.php

@ -214,7 +214,6 @@ class TestSingleByte extends \MensBeam\Intl\Test\CoderDecoderTest {
return parent::testIterateThroughAStringAllowingSurrogates($input, $exp, $exp); return parent::testIterateThroughAStringAllowingSurrogates($input, $exp, $exp);
} }
/** /**
* @dataProvider provideClasses * @dataProvider provideClasses
* @coversNothing * @coversNothing

1
tests/cases/Encoding/TestUTF16LE.php

@ -126,7 +126,6 @@ class TestUTF16LE extends \MensBeam\Intl\Test\DecoderTest {
return parent::testIterateThroughAStringAllowingSurrogates($input, $strictExp, $relaxedExp); return parent::testIterateThroughAStringAllowingSurrogates($input, $strictExp, $relaxedExp);
} }
/** /**
* @covers MensBeam\Intl\Encoding\UTF16::seekBack * @covers MensBeam\Intl\Encoding\UTF16::seekBack
*/ */

1
tests/cases/Encoding/TestUTF8.php

@ -136,7 +136,6 @@ class TestUTF8 extends \MensBeam\Intl\Test\CoderDecoderTest {
return parent::testIterateThroughAStringAllowingSurrogates($input, $strictExp, $relaxedExp); return parent::testIterateThroughAStringAllowingSurrogates($input, $strictExp, $relaxedExp);
} }
/** /**
* @covers MensBeam\Intl\Encoding\UTF8::seekBack * @covers MensBeam\Intl\Encoding\UTF8::seekBack
*/ */

1
tests/cases/Encoding/TestXUserDefined.php

@ -117,7 +117,6 @@ class TestXUserDefined extends \MensBeam\Intl\Test\DecoderTest {
return parent::testIterateThroughAStringAllowingSurrogates($input, $strictExp, $relaxedExp); return parent::testIterateThroughAStringAllowingSurrogates($input, $strictExp, $relaxedExp);
} }
/** /**
* @coversNothing * @coversNothing
*/ */

4
tests/cases/TestEncoding.php

@ -49,7 +49,9 @@ class TestEncoding extends \PHPUnit\Framework\TestCase {
} }
$out = []; $out = [];
foreach ($labels as $label => $name) { foreach ($labels as $label => $name) {
$out[] = [(string) $label, ['label' => (string) $label, 'name' => $name, 'class' => $names[$name]]]; $class = $names[$name];
$encoder = !in_array($name, ["UTF-16LE", "UTF-16BE", "replacement"]);
$out[] = [(string) $label, ['label' => (string) $label, 'name' => $name, 'encoder' => $encoder, 'class' => $class]];
} }
return $out; return $out;
} }

Loading…
Cancel
Save