diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index aa68ef4..defda12 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -23,16 +23,10 @@ jobs: strategy: fail-fast: false matrix: - php-version: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2"] + php-version: ["8.0", "8.1", "8.2"] experimental: [false] os: [ubuntu-latest] coverage-extension: [pcov] - include: - #- { php-version: '5.3', experimental: false, os: ubuntu-latest, coverage-extension: 'xdebug' } - #- { php-version: '5.4', experimental: false, os: ubuntu-latest, coverage-extension: 'xdebug' } - - { php-version: '5.5', experimental: false, os: ubuntu-latest, coverage-extension: 'xdebug' } - - { php-version: '5.6', experimental: false, os: ubuntu-latest, coverage-extension: 'xdebug' } - - { php-version: '7.1', experimental: false, os: ubuntu-latest, coverage-extension: 'xdebug' } steps: - uses: actions/checkout@v4 - name: Use php ${{ matrix.php-version }} diff --git a/.gitignore b/.gitignore index 291bb86..4dd7d5e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,10 +7,14 @@ **/.vagrant **/auth.json **/nbproject +**/temp.php +**/test.php .phpdoc .phpunit.cache .phpunit.result.cache composer.lock +ecs.php phpunit.xml +rector.php target vendor diff --git a/README.md b/README.md index 84430d0..c3a3868 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ All artifacts are generated in the target directory. Examples are located in the `example` directory. -Start a development server (requires PHP 5.4) using the command: +Start a development server (requires PHP 8.0+) using the command: ``` make server @@ -78,17 +78,17 @@ Create a composer.json in your projects root-directory: ```json { "require": { - "tecnickcom/tc-lib-unicode-data": "dev-master" - }, - "repositories": [ - { - "type": "vcs", - "url": "git@github.com:tecnickcom/tc-lib-unicode-data.git" - } - ] + "tecnickcom/tc-lib-unicode-data": "^2.0" + } } ``` +Or add to an existing project with: + +```bash +composer require tecnickcom/tc-lib-unicode-data ^2.0 +``` + ## Packaging diff --git a/VERSION b/VERSION index 0e98cde..157e54f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.7.33 +2.0.6 diff --git a/composer.json b/composer.json index 214a2ee..1cc5d0d 100644 --- a/composer.json +++ b/composer.json @@ -19,13 +19,13 @@ } ], "require": { - "php": ">=5.4" + "php": ">=8.0" }, "require-dev": { "pdepend/pdepend": "2.13.0", "phpmd/phpmd": "2.13.0", - "phpunit/phpunit": "10.1.2 || 9.6.7 || 8.5.31 || 7.5.20 || 6.5.14 || 5.7.27 || 4.8.36", - "squizlabs/php_codesniffer": "3.7.2 || 2.9.2" + "phpunit/phpunit": "10.1.2 || 9.6.13", + "squizlabs/php_codesniffer": "3.7.2" }, "autoload": { "psr-4": { diff --git a/phpstan.neon b/phpstan.neon index c42b364..bf592ce 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,5 @@ parameters: - level: 5 + level: max paths: - src - test diff --git a/resources/debian/control b/resources/debian/control index f50f000..9d0ee79 100644 --- a/resources/debian/control +++ b/resources/debian/control @@ -10,6 +10,6 @@ Vcs-Git: https://github.com/~#VENDOR#~/~#PROJECT#~.git Package: ~#PKGNAME#~ Provides: php-~#PROJECT#~ Architecture: all -Depends: php (>= 5.4.0), ${misc:Depends} +Depends: php (>= 8.0.0), ${misc:Depends} Description: PHP Unicode definitions PHP library containing Unicode definitions. diff --git a/resources/rpm/rpm.spec b/resources/rpm/rpm.spec index 6669138..bef8324 100644 --- a/resources/rpm/rpm.spec +++ b/resources/rpm/rpm.spec @@ -16,7 +16,7 @@ URL: https://github.com/%{gh_owner}/%{gh_project} BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n) BuildArch: noarch -Requires: php(language) >= 5.4.0 +Requires: php(language) >= 8.0.0 Provides: php-composer(%{c_vendor}/%{gh_project}) = %{version} Provides: php-%{gh_project} = %{version} diff --git a/src/Arabic.php b/src/Arabic.php index 46d2731..8fb3980 100644 --- a/src/Arabic.php +++ b/src/Arabic.php @@ -32,147 +32,146 @@ class Arabic /** * Unicode code for ARABIC QUESTION MARK (U+061F) */ - const QUESTION_MARK = 1567; + public const QUESTION_MARK = 1567; /** * Unicode code for ARABIC LETTER LAM (U+0644) */ - const LAM = 1604; + public const LAM = 1604; /** * Unicode code for ARABIC LETTER HEH (U+0647) */ - const HEH = 1607; + public const HEH = 1607; /** * Unicode code for ARABIC SHADDA (U+0651) */ - const SHADDA = 1617; + public const SHADDA = 1617; /** * Unicode code for ARABIC LIGATURE ALLAH ISOLATED FORM (U+FDF2) */ - const LIGATURE_ALLAH_ISOLATED_FORM = 65010; + public const LIGATURE_ALLAH_ISOLATED_FORM = 65010; /** * Arabic shape substitutions: char code => ([isolated, final, initial, medial]). * - * @var array + * @var array> */ - public static $substitute = array( - 1569 => array(65152), - 1570 => array(65153, 65154, 65153, 65154), - 1571 => array(65155, 65156, 65155, 65156), - 1572 => array(65157, 65158), - 1573 => array(65159, 65160, 65159, 65160), - 1574 => array(65161, 65162, 65163, 65164), - 1575 => array(65165, 65166, 65165, 65166), - 1576 => array(65167, 65168, 65169, 65170), - 1577 => array(65171, 65172), - 1578 => array(65173, 65174, 65175, 65176), - 1579 => array(65177, 65178, 65179, 65180), - 1580 => array(65181, 65182, 65183, 65184), - 1581 => array(65185, 65186, 65187, 65188), - 1582 => array(65189, 65190, 65191, 65192), - 1583 => array(65193, 65194, 65193, 65194), - 1584 => array(65195, 65196, 65195, 65196), - 1585 => array(65197, 65198, 65197, 65198), - 1586 => array(65199, 65200, 65199, 65200), - 1587 => array(65201, 65202, 65203, 65204), - 1588 => array(65205, 65206, 65207, 65208), - 1589 => array(65209, 65210, 65211, 65212), - 1590 => array(65213, 65214, 65215, 65216), - 1591 => array(65217, 65218, 65219, 65220), - 1592 => array(65221, 65222, 65223, 65224), - 1593 => array(65225, 65226, 65227, 65228), - 1594 => array(65229, 65230, 65231, 65232), - 1601 => array(65233, 65234, 65235, 65236), - 1602 => array(65237, 65238, 65239, 65240), - 1603 => array(65241, 65242, 65243, 65244), - 1604 => array(65245, 65246, 65247, 65248), - 1605 => array(65249, 65250, 65251, 65252), - 1606 => array(65253, 65254, 65255, 65256), - 1607 => array(65257, 65258, 65259, 65260), - 1608 => array(65261, 65262, 65261, 65262), - 1609 => array(65263, 65264, 64488, 64489), - 1610 => array(65265, 65266, 65267, 65268), - 1649 => array(64336, 64337), - 1655 => array(64477), - 1657 => array(64358, 64359, 64360, 64361), - 1658 => array(64350, 64351, 64352, 64353), - 1659 => array(64338, 64339, 64340, 64341), - 1662 => array(64342, 64343, 64344, 64345), - 1663 => array(64354, 64355, 64356, 64357), - 1664 => array(64346, 64347, 64348, 64349), - 1667 => array(64374, 64375, 64376, 64377), - 1668 => array(64370, 64371, 64372, 64373), - 1670 => array(64378, 64379, 64380, 64381), - 1671 => array(64382, 64383, 64384, 64385), - 1672 => array(64392, 64393), - 1676 => array(64388, 64389), - 1677 => array(64386, 64387), - 1678 => array(64390, 64391), - 1681 => array(64396, 64397), - 1688 => array(64394, 64395, 64394, 64395), - 1700 => array(64362, 64363, 64364, 64365), - 1702 => array(64366, 64367, 64368, 64369), - 1705 => array(64398, 64399, 64400, 64401), - 1709 => array(64467, 64468, 64469, 64470), - 1711 => array(64402, 64403, 64404, 64405), - 1713 => array(64410, 64411, 64412, 64413), - 1715 => array(64406, 64407, 64408, 64409), - 1722 => array(64414, 64415), - 1723 => array(64416, 64417, 64418, 64419), - 1726 => array(64426, 64427, 64428, 64429), - 1728 => array(64420, 64421), - 1729 => array(64422, 64423, 64424, 64425), - 1733 => array(64480, 64481), - 1734 => array(64473, 64474), - 1735 => array(64471, 64472), - 1736 => array(64475, 64476), - 1737 => array(64482, 64483), - 1739 => array(64478, 64479), - 1740 => array(64508, 64509, 64510, 64511), - 1744 => array(64484, 64485, 64486, 64487), - 1746 => array(64430, 64431), - 1747 => array(64432, 64433) - ); + public const SUBSTITUTE = [ + 1569 => [65152], + 1570 => [65153, 65154, 65153, 65154], + 1571 => [65155, 65156, 65155, 65156], + 1572 => [65157, 65158], + 1573 => [65159, 65160, 65159, 65160], + 1574 => [65161, 65162, 65163, 65164], + 1575 => [65165, 65166, 65165, 65166], + 1576 => [65167, 65168, 65169, 65170], + 1577 => [65171, 65172], + 1578 => [65173, 65174, 65175, 65176], + 1579 => [65177, 65178, 65179, 65180], + 1580 => [65181, 65182, 65183, 65184], + 1581 => [65185, 65186, 65187, 65188], + 1582 => [65189, 65190, 65191, 65192], + 1583 => [65193, 65194, 65193, 65194], + 1584 => [65195, 65196, 65195, 65196], + 1585 => [65197, 65198, 65197, 65198], + 1586 => [65199, 65200, 65199, 65200], + 1587 => [65201, 65202, 65203, 65204], + 1588 => [65205, 65206, 65207, 65208], + 1589 => [65209, 65210, 65211, 65212], + 1590 => [65213, 65214, 65215, 65216], + 1591 => [65217, 65218, 65219, 65220], + 1592 => [65221, 65222, 65223, 65224], + 1593 => [65225, 65226, 65227, 65228], + 1594 => [65229, 65230, 65231, 65232], + 1601 => [65233, 65234, 65235, 65236], + 1602 => [65237, 65238, 65239, 65240], + 1603 => [65241, 65242, 65243, 65244], + 1604 => [65245, 65246, 65247, 65248], + 1605 => [65249, 65250, 65251, 65252], + 1606 => [65253, 65254, 65255, 65256], + 1607 => [65257, 65258, 65259, 65260], + 1608 => [65261, 65262, 65261, 65262], + 1609 => [65263, 65264, 64488, 64489], + 1610 => [65265, 65266, 65267, 65268], + 1649 => [64336, 64337], + 1655 => [64477], + 1657 => [64358, 64359, 64360, 64361], + 1658 => [64350, 64351, 64352, 64353], + 1659 => [64338, 64339, 64340, 64341], + 1662 => [64342, 64343, 64344, 64345], + 1663 => [64354, 64355, 64356, 64357], + 1664 => [64346, 64347, 64348, 64349], + 1667 => [64374, 64375, 64376, 64377], + 1668 => [64370, 64371, 64372, 64373], + 1670 => [64378, 64379, 64380, 64381], + 1671 => [64382, 64383, 64384, 64385], + 1672 => [64392, 64393], + 1676 => [64388, 64389], + 1677 => [64386, 64387], + 1678 => [64390, 64391], + 1681 => [64396, 64397], + 1688 => [64394, 64395, 64394, 64395], + 1700 => [64362, 64363, 64364, 64365], + 1702 => [64366, 64367, 64368, 64369], + 1705 => [64398, 64399, 64400, 64401], + 1709 => [64467, 64468, 64469, 64470], + 1711 => [64402, 64403, 64404, 64405], + 1713 => [64410, 64411, 64412, 64413], + 1715 => [64406, 64407, 64408, 64409], + 1722 => [64414, 64415], + 1723 => [64416, 64417, 64418, 64419], + 1726 => [64426, 64427, 64428, 64429], + 1728 => [64420, 64421], + 1729 => [64422, 64423, 64424, 64425], + 1733 => [64480, 64481], + 1734 => [64473, 64474], + 1735 => [64471, 64472], + 1736 => [64475, 64476], + 1737 => [64482, 64483], + 1739 => [64478, 64479], + 1740 => [64508, 64509, 64510, 64511], + 1744 => [64484, 64485, 64486, 64487], + 1746 => [64430, 64431], + 1747 => [64432, 64433], + ]; /** * Arabic laa letter: (char code => [isolated, final, initial, medial]). * - * @var array + * @var array> */ - public static $laa = array( - 1570 => array(65269, 65270, 65269, 65270), // ALEF (U+0627) with MADDAH ABOVE (U+0653) - 1571 => array(65271, 65272, 65271, 65272), // ALEF (U+0627) with HAMZA ABOVE (U+0654) - 1573 => array(65273, 65274, 65273, 65274), // ALEF (U+0627) with HAMZA BELOW (U+0655) - 1575 => array(65275, 65276, 65275, 65276) // ALEF (U+0627) - ); + public const LAA = [ + 1570 => [65269, 65270, 65269, 65270], // ALEF (U+0627) with MADDAH ABOVE (U+0653) + 1571 => [65271, 65272, 65271, 65272], // ALEF (U+0627) with HAMZA ABOVE (U+0654) + 1573 => [65273, 65274, 65273, 65274], // ALEF (U+0627) with HAMZA BELOW (U+0655) + 1575 => [65275, 65276, 65275, 65276], // ALEF (U+0627) + ]; /** * Array of character substitutions for sequences of two diacritics symbols. * Putting the combining mark and character in the same glyph allows us * to avoid the two marks overlapping each other in an illegible manner. - * second NSM char code => substitution char + * second NSM char code => substitution char. * - * @var array + * @var array */ - public static $diacritic = array( - 1612 => 64606, # Shadda + Dammatan - 1613 => 64607, # Shadda + Kasratan - 1614 => 64608, # Shadda + Fatha - 1615 => 64609, # Shadda + Damma - 1616 => 64610 # Shadda + Kasra - ); - + public const DIACRITIC = [ + 1612 => 64606, // Shadda + Dammatan + 1613 => 64607, // Shadda + Kasratan + 1614 => 64608, // Shadda + Fatha + 1615 => 64609, // Shadda + Damma + 1616 => 64610, // Shadda + Kasra + ]; /** * Array of Arabic end letters * - * @var array + * @var array */ - public static $end = array( + public const END = [ 1569, // HAMZAH (U+621) 1570, // ALEF (U+0627) with MADDAH ABOVE (U+0653) 1571, // ALEF (U+0627) with HAMZA ABOVE (U+0654) @@ -185,6 +184,6 @@ class Arabic 1585, // REH (U+0631) 1586, // ZAIN (U+0632) 1608, // WAW (U+0648) - 1688 // JEH (U+0698) - ); + 1688, // JEH (U+0698) + ]; } diff --git a/src/Bracket.php b/src/Bracket.php index e404457..c724495 100644 --- a/src/Bracket.php +++ b/src/Bracket.php @@ -30,11 +30,11 @@ class Bracket { /** - * Bracket unicode characters (open bracket code => close bracket code) + * Bracket unicode characters (open bracket code => close bracket code). * - * @var array + * @var array */ - public static $open = array( + public const OPEN = [ 0x0028 => 0x0029, // PARENTHESIS 0x005B => 0x005D, // SQUARE BRACKET 0x007B => 0x007D, // CURLY BRACKET @@ -94,15 +94,15 @@ class Bracket 0xFF3B => 0xFF3D, // FULLWIDTH SQUARE BRACKET 0xFF5B => 0xFF5D, // FULLWIDTH CURLY BRACKET 0xFF5F => 0xFF60, // FULLWIDTH WHITE PARENTHESIS - 0xFF62 => 0xFF63 // HALFWIDTH CORNER BRACKET - ); + 0xFF62 => 0xFF63, // HALFWIDTH CORNER BRACKET + ]; /** - * Bracket unicode characters (close bracket code => open bracket code) + * Bracket unicode characters (close bracket code => open bracket code). * - * @var array + * @var array */ - public static $close = array( + public const CLOSE = [ 0x0029 => 0x0028, // PARENTHESIS 0x005D => 0x005B, // SQUARE BRACKET 0x007D => 0x007B, // CURLY BRACKET @@ -162,6 +162,6 @@ class Bracket 0xFF3D => 0xFF3B, // FULLWIDTH SQUARE BRACKET 0xFF5D => 0xFF5B, // FULLWIDTH CURLY BRACKET 0xFF60 => 0xFF5F, // FULLWIDTH WHITE PARENTHESIS - 0xFF63 => 0xFF62 // HALFWIDTH CORNER BRACKET - ); + 0xFF63 => 0xFF62, // HALFWIDTH CORNER BRACKET + ]; } diff --git a/src/Constant.php b/src/Constant.php index 7640893..0e4ed03 100644 --- a/src/Constant.php +++ b/src/Constant.php @@ -43,13 +43,13 @@ class Constant * (U+202A) LEFT-TO-RIGHT EMBEDDING * Treat the following text as embedded left-to-right */ - const LRE = 8234; + public const LRE = 8234; /** * (U+202B) RIGHT-TO-LEFT EMBEDDING * Treat the following text as embedded right-to-left */ - const RLE = 8235; + public const RLE = 8235; /* * Explicit Directional Overrides @@ -64,13 +64,13 @@ class Constant * (U+202D) for LEFT-TO-RIGHT OVERRIDE * Force following characters to be treated as strong left-to-right characters */ - const LRO = 8237; + public const LRO = 8237; /** * (U+202E) RIGHT-TO-LEFT OVERRIDE * Force following characters to be treated as strong right-to-left characters */ - const RLO = 8238; + public const RLO = 8238; /* * Terminating Explicit Directional Embeddings and Overrides @@ -81,7 +81,7 @@ class Constant * (U+202C) POP DIRECTIONAL FORMATTING * End the scope of the last LRE, RLE, RLO, or LRO whose scope has not yet been terminated */ - const PDF = 8236; + public const PDF = 8236; /* * Explicit Directional Isolates @@ -104,20 +104,20 @@ class Constant * (U+2066) LEFT-TO-RIGHT ISOLATE * Treat the following text as isolated and left-to-right */ - const LRI = 8294; + public const LRI = 8294; /** * (U+2067) RIGHT-TO-LEFT ISOLATE * Treat the following text as isolated and right-to-left */ - const RLI = 8295; + public const RLI = 8295; /** * (U+2068) FIRST STRONG ISOLATE * Treat the following text as isolated and in the direction of its first * strong directional character that is not inside a nested isolate */ - const FSI = 8296; + public const FSI = 8296; /* * Terminating Explicit Directional Isolates @@ -131,7 +131,7 @@ class Constant * (U+2069) POP DIRECTIONAL ISOLATE * End the scope of the last LRI, RLI, or FSI */ - const PDI = 8297; + public const PDI = 8297; /* * Implicit Directional Marks @@ -145,19 +145,19 @@ class Constant * (U+200E) LEFT-TO-RIGHT MARK * Left-to-right zero-width character */ - const LRM = 8206; + public const LRM = 8206; /** * (U+200F) RIGHT-TO-LEFT MARK * Right-to-left zero-width non-Arabic character */ - const RLM = 8207; + public const RLM = 8207; /** * (U+061C) ARABIC LETTER MARK * Right-to-left zero-width Arabic character */ - const ALM = 1564; + public const ALM = 1564; /* * Other useful characters @@ -167,10 +167,10 @@ class Constant /** * (U+0020) SPACE */ - const SPACE = 32; + public const SPACE = 32; /** * (U+200C) ZERO WIDTH NON-JOINER */ - const ZERO_WIDTH_NON_JOINER = 8204; + public const ZERO_WIDTH_NON_JOINER = 8204; } diff --git a/src/Encoding.php b/src/Encoding.php index b1f72ae..97ee409 100644 --- a/src/Encoding.php +++ b/src/Encoding.php @@ -34,11 +34,11 @@ class Encoding /** * Font Encoding Maps. * - * @var array + * @var array> */ - public static $map = array( + public const MAP = [ // encoding map for: cp874 - 'cp874' => array( + 'cp874' => [ 0 => '.notdef', 1 => '.notdef', 2 => '.notdef', @@ -294,11 +294,10 @@ class Encoding 252 => '.notdef', 253 => '.notdef', 254 => '.notdef', - 255 => '.notdef' - ), - + 255 => '.notdef', + ], // encoding map for: cp1250 - 'cp1250' => array( + 'cp1250' => [ 0 => '.notdef', 1 => '.notdef', 2 => '.notdef', @@ -554,11 +553,10 @@ class Encoding 252 => 'udieresis', 253 => 'yacute', 254 => 'tcommaaccent', - 255 => 'dotaccent' - ), - + 255 => 'dotaccent', + ], // encoding map for: cp1251 - 'cp1251' => array( + 'cp1251' => [ 0 => '.notdef', 1 => '.notdef', 2 => '.notdef', @@ -814,11 +812,10 @@ class Encoding 252 => 'afii10094', 253 => 'afii10095', 254 => 'afii10096', - 255 => 'afii10097' - ), - + 255 => 'afii10097', + ], // encoding map for: cp1252 - 'cp1252' => array( + 'cp1252' => [ 0 => '.notdef', 1 => '.notdef', 2 => '.notdef', @@ -1074,11 +1071,10 @@ class Encoding 252 => 'udieresis', 253 => 'yacute', 254 => 'thorn', - 255 => 'ydieresis' - ), - + 255 => 'ydieresis', + ], // encoding map for: cp1253 - 'cp1253' => array( + 'cp1253' => [ 0 => '.notdef', 1 => '.notdef', 2 => '.notdef', @@ -1334,11 +1330,10 @@ class Encoding 252 => 'omicrontonos', 253 => 'upsilontonos', 254 => 'omegatonos', - 255 => '.notdef' - ), - + 255 => '.notdef', + ], // encoding map for: cp1254 - 'cp1254' => array( + 'cp1254' => [ 0 => '.notdef', 1 => '.notdef', 2 => '.notdef', @@ -1594,11 +1589,10 @@ class Encoding 252 => 'udieresis', 253 => 'dotlessi', 254 => 'scedilla', - 255 => 'ydieresis' - ), - + 255 => 'ydieresis', + ], // encoding map for: cp1255 - 'cp1255' => array( + 'cp1255' => [ 0 => '.notdef', 1 => '.notdef', 2 => '.notdef', @@ -1854,11 +1848,10 @@ class Encoding 252 => '.notdef', 253 => 'afii299', 254 => 'afii300', - 255 => '.notdef' - ), - + 255 => '.notdef', + ], // encoding map for: cp1256 - 'cp1256' => array( + 'cp1256' => [ 0 => '.notdef', 1 => '.notdef', 2 => '.notdef', @@ -2114,11 +2107,10 @@ class Encoding 252 => 'udieresis', 253 => 'afii299', 254 => 'afii300', - 255 => 'afii57519' - ), - + 255 => 'afii57519', + ], // encoding map for: cp1257 - 'cp1257' => array( + 'cp1257' => [ 0 => '.notdef', 1 => '.notdef', 2 => '.notdef', @@ -2374,11 +2366,10 @@ class Encoding 252 => 'udieresis', 253 => 'zdotaccent', 254 => 'zcaron', - 255 => 'dotaccent' - ), - + 255 => 'dotaccent', + ], // encoding map for: cp1258 - 'cp1258' => array( + 'cp1258' => [ 0 => '.notdef', 1 => '.notdef', 2 => '.notdef', @@ -2634,11 +2625,10 @@ class Encoding 252 => 'udieresis', 253 => 'uhorn', 254 => 'dong', - 255 => 'ydieresis' - ), - + 255 => 'ydieresis', + ], // encoding map for: iso-8859-1 - 'iso-8859-1' => array( + 'iso-8859-1' => [ 0 => '.notdef', 1 => '.notdef', 2 => '.notdef', @@ -2894,11 +2884,10 @@ class Encoding 252 => 'udieresis', 253 => 'yacute', 254 => 'thorn', - 255 => 'ydieresis' - ), - + 255 => 'ydieresis', + ], // encoding map for: iso-8859-2 - 'iso-8859-2' => array( + 'iso-8859-2' => [ 0 => '.notdef', 1 => '.notdef', 2 => '.notdef', @@ -3154,11 +3143,10 @@ class Encoding 252 => 'udieresis', 253 => 'yacute', 254 => 'tcommaaccent', - 255 => 'dotaccent' - ), - + 255 => 'dotaccent', + ], // encoding map for: iso-8859-4 - 'iso-8859-4' => array( + 'iso-8859-4' => [ 0 => '.notdef', 1 => '.notdef', 2 => '.notdef', @@ -3414,11 +3402,10 @@ class Encoding 252 => 'udieresis', 253 => 'utilde', 254 => 'umacron', - 255 => 'dotaccent' - ), - + 255 => 'dotaccent', + ], // encoding map for: iso-8859-5 - 'iso-8859-5' => array( + 'iso-8859-5' => [ 0 => '.notdef', 1 => '.notdef', 2 => '.notdef', @@ -3674,11 +3661,10 @@ class Encoding 252 => 'afii10109', 253 => 'section', 254 => 'afii10110', - 255 => 'afii10193' - ), - + 255 => 'afii10193', + ], // encoding map for: iso-8859-7 - 'iso-8859-7' => array( + 'iso-8859-7' => [ 0 => '.notdef', 1 => '.notdef', 2 => '.notdef', @@ -3934,11 +3920,10 @@ class Encoding 252 => 'omicrontonos', 253 => 'upsilontonos', 254 => 'omegatonos', - 255 => '.notdef' - ), - + 255 => '.notdef', + ], // encoding map for: iso-8859-9 - 'iso-8859-9' => array( + 'iso-8859-9' => [ 0 => '.notdef', 1 => '.notdef', 2 => '.notdef', @@ -4194,11 +4179,10 @@ class Encoding 252 => 'udieresis', 253 => 'dotlessi', 254 => 'scedilla', - 255 => 'ydieresis' - ), - + 255 => 'ydieresis', + ], // encoding map for: iso-8859-11 - 'iso-8859-11' => array( + 'iso-8859-11' => [ 0 => '.notdef', 1 => '.notdef', 2 => '.notdef', @@ -4454,11 +4438,10 @@ class Encoding 252 => '.notdef', 253 => '.notdef', 254 => '.notdef', - 255 => '.notdef' - ), - + 255 => '.notdef', + ], // encoding map for: iso-8859-15 - 'iso-8859-15' => array( + 'iso-8859-15' => [ 0 => '.notdef', 1 => '.notdef', 2 => '.notdef', @@ -4714,11 +4697,10 @@ class Encoding 252 => 'udieresis', 253 => 'yacute', 254 => 'thorn', - 255 => 'ydieresis' - ), - + 255 => 'ydieresis', + ], // encoding map for: iso-8859-16 - 'iso-8859-16' => array( + 'iso-8859-16' => [ 0 => '.notdef', 1 => '.notdef', 2 => '.notdef', @@ -4974,11 +4956,10 @@ class Encoding 252 => 'udieresis', 253 => 'eogonek', 254 => 'tcommaaccent', - 255 => 'ydieresis' - ), - + 255 => 'ydieresis', + ], // encoding map for: koi8-r - 'koi8-r' => array( + 'koi8-r' => [ 0 => '.notdef', 1 => '.notdef', 2 => '.notdef', @@ -5234,11 +5215,10 @@ class Encoding 252 => 'afii10047', 253 => 'afii10043', 254 => 'afii10041', - 255 => 'afii10044' - ), - + 255 => 'afii10044', + ], // encoding map for: koi8-u - 'koi8-u' => array( + 'koi8-u' => [ 0 => '.notdef', 1 => '.notdef', 2 => '.notdef', @@ -5494,11 +5474,10 @@ class Encoding 252 => 'afii10047', 253 => 'afii10043', 254 => 'afii10041', - 255 => 'afii10044' - ), - + 255 => 'afii10044', + ], // encoding map for: symbol - 'symbol' => array( + 'symbol' => [ 0 => '.notdef', 1 => '.notdef', 2 => '.notdef', @@ -5757,7 +5736,7 @@ class Encoding 255 => '.notdef', 1226 => 'registered', 1227 => 'copyright', - 1228 => 'trademark' - ) - ); + 1228 => 'trademark', + ], + ]; } diff --git a/src/Identity.php b/src/Identity.php index f632352..c183673 100644 --- a/src/Identity.php +++ b/src/Identity.php @@ -32,7 +32,7 @@ class Identity /** * ToUnicode map for Identity-H stream */ - const CIDHMAP = << */ - public static $substitute = array( - 8364 => 128, # Euro1 - 338 => 140, # OE - 352 => 138, # Scaron - 376 => 159, # Ydieresis - 381 => 142, # Zcaron2 - 8226 => 149, # bullet3 - 710 => 136, # circumflex - 8224 => 134, # dagger - 8225 => 135, # daggerdbl - 8230 => 133, # ellipsis - 8212 => 151, # emdash - 8211 => 150, # endash - 402 => 131, # florin - 8249 => 139, # guilsinglleft - 8250 => 155, # guilsinglright - 339 => 156, # oe - 8240 => 137, # perthousand - 8222 => 132, # quotedblbase - 8220 => 147, # quotedblleft - 8221 => 148, # quotedblright - 8216 => 145, # quoteleft - 8217 => 146, # quoteright - 8218 => 130, # quotesinglbase - 353 => 154, # scaron - 732 => 152, # tilde - 8482 => 153, # trademark - 382 => 158 # zcaron2 - ); + public const SUBSTITUTE = [ + 8364 => 128, // Euro1 + 338 => 140, // OE + 352 => 138, // Scaron + 376 => 159, // Ydieresis + 381 => 142, // Zcaron2 + 8226 => 149, // bullet3 + 710 => 136, // circumflex + 8224 => 134, // dagger + 8225 => 135, // daggerdbl + 8230 => 133, // ellipsis + 8212 => 151, // emdash + 8211 => 150, // endash + 402 => 131, // florin + 8249 => 139, // guilsinglleft + 8250 => 155, // guilsinglright + 339 => 156, // oe + 8240 => 137, // perthousand + 8222 => 132, // quotedblbase + 8220 => 147, // quotedblleft + 8221 => 148, // quotedblright + 8216 => 145, // quoteleft + 8217 => 146, // quoteright + 8218 => 130, // quotesinglbase + 353 => 154, // scaron + 732 => 152, // tilde + 8482 => 153, // trademark + 382 => 158, // zcaron2 + ]; } diff --git a/src/Mirror.php b/src/Mirror.php index ecf6ba6..a7db19f 100644 --- a/src/Mirror.php +++ b/src/Mirror.php @@ -32,11 +32,11 @@ class Mirror /** * Mirror unicode characters. * For information on bidi mirroring, see UAX #9: - * Bidirectional Algorithm, at http://www.unicode.org/unicode/reports/tr9/ + * Bidirectional Algorithm, at http://www.unicode.org/unicode/reports/tr9/. * - * @var array + * @var array */ - public static $uni = array( + public const UNI = [ 0x0028 => 0x0029, 0x0029 => 0x0028, 0x003C => 0x003E, @@ -388,6 +388,6 @@ class Mirror 0xFF5F => 0xFF60, 0xFF60 => 0xFF5F, 0xFF62 => 0xFF63, - 0xFF63 => 0xFF62 - ); + 0xFF63 => 0xFF62, + ]; } diff --git a/src/Pattern.php b/src/Pattern.php index 9194517..289be56 100644 --- a/src/Pattern.php +++ b/src/Pattern.php @@ -33,7 +33,7 @@ class Pattern * Pattern to test RTL (Righ-To-Left) strings using regular expressions. * (excluding Arabic) */ - const RTL = "/( + public const RTL = "/( \xD6\xBE # R | \xD7[\x80\x83\x86\x90-\xAA\xB0-\xB4] # R | \xDF[\x80-\xAA\xB4\xB5\xBA] # R @@ -52,7 +52,7 @@ class Pattern * Pattern to test Arabic strings using regular expressions. * Ref: http://www.w3.org/International/questions/qa-forms-utf-8 */ - const ARABIC = "/( + public const ARABIC = "/( \xD8[\x80-\x83\x8B\x8D\x9B\x9E\x9F\xA1-\xBA] # AL | \xD9[\x80-\x8A\xAD-\xAF\xB1-\xBF] # AL | \xDA[\x80-\xBF] # AL diff --git a/src/Type.php b/src/Type.php index d76f86c..b9a5d73 100644 --- a/src/Type.php +++ b/src/Type.php @@ -34,47 +34,47 @@ class Type /** * Array of Strong bidirectional character types. * - * @var array + * @var array */ - public static $strong = array( - 'L' => 'L', // Left-to-Right - 'R' => 'R', // Right-to-Left - 'AL' => 'AL' // Right-to-Left Arabic - ); + public const STRONG = [ + 'L' => 'L', // Left-to-Right + 'R' => 'R', // Right-to-Left + 'AL' => 'AL', // Right-to-Left Arabic + ]; /** * Array of Weak bidirectional character types. * - * @var array + * @var array */ - public static $weak = array( - 'EN' => 'EN', // European Number - 'ES' => 'ES', // European Number Separator - 'ET' => 'ET', // European Number Terminator - 'AN' => 'AN', // Arabic Number - 'CS' => 'CS', // Common Number Separator + public const WEAK = [ + 'EN' => 'EN', // European Number + 'ES' => 'ES', // European Number Separator + 'ET' => 'ET', // European Number Terminator + 'AN' => 'AN', // Arabic Number + 'CS' => 'CS', // Common Number Separator 'NSM' => 'NSM', // Nonspacing Mark - 'BN' => 'BN' // Boundary Neutral - ); + 'BN' => 'BN', // Boundary Neutral + ]; /** * Array of Neutral bidirectional character types. * - * @var array + * @var array */ - public static $neutral = array( - 'B' => 'B', // Paragraph Separator - 'S' => 'S', // Segment Separator + public const NEUTRAL = [ + 'B' => 'B', // Paragraph Separator + 'S' => 'S', // Segment Separator 'WS' => 'WS', // Whitespace - 'ON' => 'ON' // Other Neutrals - ); + 'ON' => 'ON', // Other Neutrals + ]; /** - * Array of Explicit formatting codes + * Array of Explicit formatting codes. * - * @var array + * @var array */ - public static $explicit_formatting = array( + public const EXPLICIT_FORMATTING = [ 'LRE' => 8234, // Left-to-Right Embedding 'LRO' => 8237, // Left-to-Right Override 'RLE' => 8235, // Right-to-Left Embedding @@ -83,15 +83,15 @@ class Type 'LRI' => 8294, // Left-to-Right Isolate 'RLI' => 8295, // Right-to-Left Isolate 'FSI' => 8296, // First Strong Isolate - 'PDI' => 8297 // Pop Directional Isolate - ); + 'PDI' => 8297, // Pop Directional Isolate + ]; /** * Array of Unicode types. * - * @var array + * @var array */ - public static $uni = array( + public const UNI = [ 0 => 'BN', 1 => 'BN', 2 => 'BN', @@ -17809,8 +17809,8 @@ class Type 917998 => 'NSM', 917999 => 'NSM', 983040 => 'L', - 1048573 => 'L', - 1048576 => 'L', - 1114109 => 'L' - ); + 1_048_573 => 'L', + 1_048_576 => 'L', + 1_114_109 => 'L', + ]; } diff --git a/test/ArabicTest.php b/test/ArabicTest.php index 5fcf433..f216f5c 100644 --- a/test/ArabicTest.php +++ b/test/ArabicTest.php @@ -31,18 +31,18 @@ */ class ArabicTest extends TestCase { - public function testDiacritic() + public function testDiacritic(): void { - $this->assertEquals(5, count(\Com\Tecnick\Unicode\Data\Arabic::$diacritic)); + $this->assertEquals(5, count(\Com\Tecnick\Unicode\Data\Arabic::DIACRITIC)); } - public function testlaa() + public function testlaa(): void { - $this->assertEquals(4, count(\Com\Tecnick\Unicode\Data\Arabic::$laa)); + $this->assertEquals(4, count(\Com\Tecnick\Unicode\Data\Arabic::LAA)); } - public function testSubstitute() + public function testSubstitute(): void { - $this->assertEquals(76, count(\Com\Tecnick\Unicode\Data\Arabic::$substitute)); + $this->assertEquals(76, count(\Com\Tecnick\Unicode\Data\Arabic::SUBSTITUTE)); } } diff --git a/test/BracketTest.php b/test/BracketTest.php index f4f2a37..5bdcb05 100644 --- a/test/BracketTest.php +++ b/test/BracketTest.php @@ -31,11 +31,11 @@ */ class BracketTest extends TestCase { - public function testOpenClose() + public function testOpenClose(): void { $this->assertEquals( - \Com\Tecnick\Unicode\Data\Bracket::$open, - array_flip(\Com\Tecnick\Unicode\Data\Bracket::$close) + \Com\Tecnick\Unicode\Data\Bracket::OPEN, + array_flip(\Com\Tecnick\Unicode\Data\Bracket::CLOSE) ); } } diff --git a/test/ConstantTest.php b/test/ConstantTest.php index 093a3d7..29aa80e 100644 --- a/test/ConstantTest.php +++ b/test/ConstantTest.php @@ -31,9 +31,9 @@ */ class ConstantTest extends TestCase { - public function testConstants() + public function testConstants(): void { - $oClass = new \ReflectionClass('\Com\Tecnick\Unicode\Data\Constant'); - $this->assertEquals(14, count($oClass->getConstants())); + $reflectionClass = new \ReflectionClass('\\' . \Com\Tecnick\Unicode\Data\Constant::class); + $this->assertEquals(14, count($reflectionClass->getConstants())); } } diff --git a/test/EncodingTest.php b/test/EncodingTest.php index bfc28cd..47a9d1b 100644 --- a/test/EncodingTest.php +++ b/test/EncodingTest.php @@ -31,9 +31,9 @@ */ class EncodingTest extends TestCase { - public function testMap() + public function testMap(): void { - $this->assertEquals(22, count(\Com\Tecnick\Unicode\Data\Encoding::$map)); - $this->assertEquals(256, count(\Com\Tecnick\Unicode\Data\Encoding::$map['iso-8859-1'])); + $this->assertEquals(22, count(\Com\Tecnick\Unicode\Data\Encoding::MAP)); + $this->assertEquals(256, count(\Com\Tecnick\Unicode\Data\Encoding::MAP['iso-8859-1'])); } } diff --git a/test/IdentityTest.php b/test/IdentityTest.php index bc1b133..3f63b57 100644 --- a/test/IdentityTest.php +++ b/test/IdentityTest.php @@ -31,7 +31,7 @@ */ class IdentityTest extends TestCase { - public function testConstants() + public function testConstants(): void { $this->assertEquals('a3f30375025e8570745ff463479522b6', md5(\Com\Tecnick\Unicode\Data\Identity::CIDHMAP)); } diff --git a/test/LatinTest.php b/test/LatinTest.php index 395f347..3a0f6c6 100644 --- a/test/LatinTest.php +++ b/test/LatinTest.php @@ -31,8 +31,8 @@ */ class LatinTest extends TestCase { - public function testMap() + public function testMap(): void { - $this->assertEquals(27, count(\Com\Tecnick\Unicode\Data\Latin::$substitute)); + $this->assertEquals(27, count(\Com\Tecnick\Unicode\Data\Latin::SUBSTITUTE)); } } diff --git a/test/MirrorTest.php b/test/MirrorTest.php index dfe29c6..1a43fcd 100644 --- a/test/MirrorTest.php +++ b/test/MirrorTest.php @@ -31,8 +31,8 @@ */ class MirrorTest extends TestCase { - public function testMap() + public function testMap(): void { - $this->assertEquals(352, count(\Com\Tecnick\Unicode\Data\Mirror::$uni)); + $this->assertEquals(352, count(\Com\Tecnick\Unicode\Data\Mirror::UNI)); } } diff --git a/test/PatternTest.php b/test/PatternTest.php index d41f33d..59f64b9 100644 --- a/test/PatternTest.php +++ b/test/PatternTest.php @@ -31,7 +31,7 @@ */ class PatternTest extends TestCase { - public function testPatterns() + public function testPatterns(): void { $str = 'hello world'; $this->assertEquals(0, preg_match(\Com\Tecnick\Unicode\Data\Pattern::ARABIC, $str)); diff --git a/test/TypeTest.php b/test/TypeTest.php index 2541528..b9197e6 100644 --- a/test/TypeTest.php +++ b/test/TypeTest.php @@ -31,28 +31,28 @@ */ class TypeTest extends TestCase { - public function testStrong() + public function testStrong(): void { - $this->assertEquals(3, count(\Com\Tecnick\Unicode\Data\Type::$strong)); + $this->assertEquals(3, count(\Com\Tecnick\Unicode\Data\Type::STRONG)); } - public function testWeak() + public function testWeak(): void { - $this->assertEquals(7, count(\Com\Tecnick\Unicode\Data\Type::$weak)); + $this->assertEquals(7, count(\Com\Tecnick\Unicode\Data\Type::WEAK)); } - public function testNeutral() + public function testNeutral(): void { - $this->assertEquals(4, count(\Com\Tecnick\Unicode\Data\Type::$neutral)); + $this->assertEquals(4, count(\Com\Tecnick\Unicode\Data\Type::NEUTRAL)); } - public function testExplicitFormatting() + public function testExplicitFormatting(): void { - $this->assertEquals(9, count(\Com\Tecnick\Unicode\Data\Type::$explicit_formatting)); + $this->assertEquals(9, count(\Com\Tecnick\Unicode\Data\Type::EXPLICIT_FORMATTING)); } - public function testUni() + public function testUni(): void { - $this->assertEquals(17720, count(\Com\Tecnick\Unicode\Data\Type::$uni)); + $this->assertEquals(17720, count(\Com\Tecnick\Unicode\Data\Type::UNI)); } }