From 445b0797b7c90a4924c84a22dbd01112134a3ee0 Mon Sep 17 00:00:00 2001 From: Joshua Gigg Date: Tue, 13 Aug 2024 13:12:12 +0100 Subject: [PATCH] :art: Use PER-CS coding standards --- .php-cs-fixer.dist.php | 3 +- build/BuildMetadataFromXml.php | 8 +- build/MetadataFilter.php | 4 +- src/CountryCodeToRegionCodeMap.php | 1370 ++++++++--------- src/CountryCodeToRegionCodeMapForTesting.php | 190 +-- src/PhoneNumberUtil.php | 12 +- src/RegexBasedMatcher.php | 4 +- src/ShortNumbersRegionCodeSet.php | 484 +++--- tests/Issues/CodeCoverageTest.php | 2 +- .../Issues/RegionCodeCaseInsensitiveTest.php | 12 +- 10 files changed, 1042 insertions(+), 1047 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index adb1dd4ae..09ac3df80 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -8,8 +8,7 @@ $config = new PhpCsFixer\Config(); return $config->setRules( [ - '@PSR2' => true, - '@PSR12' => true, + '@PER-CS' => true, '@PHP81Migration' => true, 'single_quote' => true, 'no_unused_imports' => true, diff --git a/build/BuildMetadataFromXml.php b/build/BuildMetadataFromXml.php index 286d1b308..e22f8db10 100644 --- a/build/BuildMetadataFromXml.php +++ b/build/BuildMetadataFromXml.php @@ -184,7 +184,7 @@ public static function loadTerritoryTagMetadata( ): PhoneMetadata { $metadata = new PhoneMetadata(); $metadata->setId($regionCode); - $metadata->setCountryCode((int)$element->getAttribute(self::COUNTRY_CODE)); + $metadata->setCountryCode((int) $element->getAttribute(self::COUNTRY_CODE)); if ($element->hasAttribute(self::LEADING_DIGITS)) { $metadata->setLeadingDigits(self::validateRE($element->getAttribute(self::LEADING_DIGITS))); } @@ -450,8 +450,8 @@ private static function parsePossibleLengthStringToSet(string $possibleLengthStr if (\count($minMax) !== 2) { throw new \RuntimeException("Ranges must have exactly one - character: missing for {$possibleLengthString}."); } - $min = (int)$minMax[0]; - $max = (int)$minMax[1]; + $min = (int) $minMax[0]; + $max = (int) $minMax[1]; // We don't even accept [6-7] since we prefer the shorter 6,7 variant; for a range to be in // use the hyphen needs to replace at least one digit. if ($max - $min < 2) { @@ -471,7 +471,7 @@ private static function parsePossibleLengthStringToSet(string $possibleLengthStr if (!\is_numeric($length)) { throw new \RuntimeException("For input string \"{$length}\""); } - $lengthSet[] = (int)$length; + $lengthSet[] = (int) $length; } } return $lengthSet; diff --git a/build/MetadataFilter.php b/build/MetadataFilter.php index 61cdf0767..549ca9358 100644 --- a/build/MetadataFilter.php +++ b/build/MetadataFilter.php @@ -56,9 +56,7 @@ class MetadataFilter /** * @param array $blackList */ - public function __construct(protected array $blackList = []) - { - } + public function __construct(protected array $blackList = []) {} public static function forLiteBuild(): static { diff --git a/src/CountryCodeToRegionCodeMap.php b/src/CountryCodeToRegionCodeMap.php index d32423a28..7be5884f7 100644 --- a/src/CountryCodeToRegionCodeMap.php +++ b/src/CountryCodeToRegionCodeMap.php @@ -16,690 +16,690 @@ class CountryCodeToRegionCodeMap // indicated with "isMainCountryForCode" in the metadata should be first. public const COUNTRY_CODE_TO_REGION_CODE_MAP = [ - 1 => [ - 'US', - 'AG', - 'AI', - 'AS', - 'BB', - 'BM', - 'BS', - 'CA', - 'DM', - 'DO', - 'GD', - 'GU', - 'JM', - 'KN', - 'KY', - 'LC', - 'MP', - 'MS', - 'PR', - 'SX', - 'TC', - 'TT', - 'VC', - 'VG', - 'VI', - ], - 7 => [ - 'RU', - 'KZ', - ], - 20 => [ - 'EG', - ], - 27 => [ - 'ZA', - ], - 30 => [ - 'GR', - ], - [ - 'NL', - ], - [ - 'BE', - ], - [ - 'FR', - ], - [ - 'ES', - ], - 36 => [ - 'HU', - ], - 39 => [ - 'IT', - 'VA', - ], - [ - 'RO', - ], - [ - 'CH', - ], - 43 => [ - 'AT', - ], - [ - 'GB', - 'GG', - 'IM', - 'JE', - ], - [ - 'DK', - ], - [ - 'SE', - ], - [ - 'NO', - 'SJ', - ], - [ - 'PL', - ], - [ - 'DE', - ], - 51 => [ - 'PE', - ], - [ - 'MX', - ], - [ - 'CU', - ], - [ - 'AR', - ], - [ - 'BR', - ], - [ - 'CL', - ], - [ - 'CO', - ], - [ - 'VE', - ], - 60 => [ - 'MY', - ], - [ - 'AU', - 'CC', - 'CX', - ], - [ - 'ID', - ], - [ - 'PH', - ], - [ - 'NZ', - ], - [ - 'SG', - ], - [ - 'TH', - ], - 81 => [ - 'JP', - ], - [ - 'KR', - ], - 84 => [ - 'VN', - ], - 86 => [ - 'CN', - ], - 90 => [ - 'TR', - ], - [ - 'IN', - ], - [ - 'PK', - ], - [ - 'AF', - ], - [ - 'LK', - ], - [ - 'MM', - ], - 98 => [ - 'IR', - ], - 211 => [ - 'SS', - ], - [ - 'MA', - 'EH', - ], - [ - 'DZ', - ], - 216 => [ - 'TN', - ], - 218 => [ - 'LY', - ], - 220 => [ - 'GM', - ], - [ - 'SN', - ], - [ - 'MR', - ], - [ - 'ML', - ], - [ - 'GN', - ], - [ - 'CI', - ], - [ - 'BF', - ], - [ - 'NE', - ], - [ - 'TG', - ], - [ - 'BJ', - ], - [ - 'MU', - ], - [ - 'LR', - ], - [ - 'SL', - ], - [ - 'GH', - ], - [ - 'NG', - ], - [ - 'TD', - ], - [ - 'CF', - ], - [ - 'CM', - ], - [ - 'CV', - ], - [ - 'ST', - ], - [ - 'GQ', - ], - [ - 'GA', - ], - [ - 'CG', - ], - [ - 'CD', - ], - [ - 'AO', - ], - [ - 'GW', - ], - [ - 'IO', - ], - [ - 'AC', - ], - [ - 'SC', - ], - [ - 'SD', - ], - [ - 'RW', - ], - [ - 'ET', - ], - [ - 'SO', - ], - [ - 'DJ', - ], - [ - 'KE', - ], - [ - 'TZ', - ], - [ - 'UG', - ], - [ - 'BI', - ], - [ - 'MZ', - ], - 260 => [ - 'ZM', - ], - [ - 'MG', - ], - [ - 'RE', - 'YT', - ], - [ - 'ZW', - ], - [ - 'NA', - ], - [ - 'MW', - ], - [ - 'LS', - ], - [ - 'BW', - ], - [ - 'SZ', - ], - [ - 'KM', - ], - 290 => [ - 'SH', - 'TA', - ], - [ - 'ER', - ], - 297 => [ - 'AW', - ], - [ - 'FO', - ], - [ - 'GL', - ], - 350 => [ - 'GI', - ], - [ - 'PT', - ], - [ - 'LU', - ], - [ - 'IE', - ], - [ - 'IS', - ], - [ - 'AL', - ], - [ - 'MT', - ], - [ - 'CY', - ], - [ - 'FI', - 'AX', - ], - [ - 'BG', - ], - 370 => [ - 'LT', - ], - [ - 'LV', - ], - [ - 'EE', - ], - [ - 'MD', - ], - [ - 'AM', - ], - [ - 'BY', - ], - [ - 'AD', - ], - [ - 'MC', - ], - [ - 'SM', - ], - 380 => [ - 'UA', - ], - [ - 'RS', - ], - [ - 'ME', - ], - [ - 'XK', - ], - 385 => [ - 'HR', - ], - [ - 'SI', - ], - [ - 'BA', - ], - 389 => [ - 'MK', - ], - 420 => [ - 'CZ', - ], - [ - 'SK', - ], - 423 => [ - 'LI', - ], - 500 => [ - 'FK', - ], - [ - 'BZ', - ], - [ - 'GT', - ], - [ - 'SV', - ], - [ - 'HN', - ], - [ - 'NI', - ], - [ - 'CR', - ], - [ - 'PA', - ], - [ - 'PM', - ], - [ - 'HT', - ], - 590 => [ - 'GP', - 'BL', - 'MF', - ], - [ - 'BO', - ], - [ - 'GY', - ], - [ - 'EC', - ], - [ - 'GF', - ], - [ - 'PY', - ], - [ - 'MQ', - ], - [ - 'SR', - ], - [ - 'UY', - ], - [ - 'CW', - 'BQ', - ], - 670 => [ - 'TL', - ], - 672 => [ - 'NF', - ], - [ - 'BN', - ], - [ - 'NR', - ], - [ - 'PG', - ], - [ - 'TO', - ], - [ - 'SB', - ], - [ - 'VU', - ], - [ - 'FJ', - ], - [ - 'PW', - ], - [ - 'WF', - ], - [ - 'CK', - ], - [ - 'NU', - ], - 685 => [ - 'WS', - ], - [ - 'KI', - ], - [ - 'NC', - ], - [ - 'TV', - ], - [ - 'PF', - ], - [ - 'TK', - ], - [ - 'FM', - ], - [ - 'MH', - ], - 800 => [ - '001', - ], - 808 => [ - '001', - ], - 850 => [ - 'KP', - ], - 852 => [ - 'HK', - ], - [ - 'MO', - ], - 855 => [ - 'KH', - ], - [ - 'LA', - ], - 870 => [ - '001', - ], - 878 => [ - '001', - ], - 880 => [ - 'BD', - ], - [ - '001', - ], - [ - '001', - ], - [ - '001', - ], - 886 => [ - 'TW', - ], - 888 => [ - '001', - ], - 960 => [ - 'MV', - ], - [ - 'LB', - ], - [ - 'JO', - ], - [ - 'SY', - ], - [ - 'IQ', - ], - [ - 'KW', - ], - [ - 'SA', - ], - [ - 'YE', - ], - [ - 'OM', - ], - 970 => [ - 'PS', - ], - [ - 'AE', - ], - [ - 'IL', - ], - [ - 'BH', - ], - [ - 'QA', - ], - [ - 'BT', - ], - [ - 'MN', - ], - [ - 'NP', - ], - 979 => [ - '001', - ], - 992 => [ - 'TJ', - ], - [ - 'TM', - ], - [ - 'AZ', - ], - [ - 'GE', - ], - [ - 'KG', - ], - 998 => [ - 'UZ', - ], -]; + 1 => [ + 'US', + 'AG', + 'AI', + 'AS', + 'BB', + 'BM', + 'BS', + 'CA', + 'DM', + 'DO', + 'GD', + 'GU', + 'JM', + 'KN', + 'KY', + 'LC', + 'MP', + 'MS', + 'PR', + 'SX', + 'TC', + 'TT', + 'VC', + 'VG', + 'VI', + ], + 7 => [ + 'RU', + 'KZ', + ], + 20 => [ + 'EG', + ], + 27 => [ + 'ZA', + ], + 30 => [ + 'GR', + ], + [ + 'NL', + ], + [ + 'BE', + ], + [ + 'FR', + ], + [ + 'ES', + ], + 36 => [ + 'HU', + ], + 39 => [ + 'IT', + 'VA', + ], + [ + 'RO', + ], + [ + 'CH', + ], + 43 => [ + 'AT', + ], + [ + 'GB', + 'GG', + 'IM', + 'JE', + ], + [ + 'DK', + ], + [ + 'SE', + ], + [ + 'NO', + 'SJ', + ], + [ + 'PL', + ], + [ + 'DE', + ], + 51 => [ + 'PE', + ], + [ + 'MX', + ], + [ + 'CU', + ], + [ + 'AR', + ], + [ + 'BR', + ], + [ + 'CL', + ], + [ + 'CO', + ], + [ + 'VE', + ], + 60 => [ + 'MY', + ], + [ + 'AU', + 'CC', + 'CX', + ], + [ + 'ID', + ], + [ + 'PH', + ], + [ + 'NZ', + ], + [ + 'SG', + ], + [ + 'TH', + ], + 81 => [ + 'JP', + ], + [ + 'KR', + ], + 84 => [ + 'VN', + ], + 86 => [ + 'CN', + ], + 90 => [ + 'TR', + ], + [ + 'IN', + ], + [ + 'PK', + ], + [ + 'AF', + ], + [ + 'LK', + ], + [ + 'MM', + ], + 98 => [ + 'IR', + ], + 211 => [ + 'SS', + ], + [ + 'MA', + 'EH', + ], + [ + 'DZ', + ], + 216 => [ + 'TN', + ], + 218 => [ + 'LY', + ], + 220 => [ + 'GM', + ], + [ + 'SN', + ], + [ + 'MR', + ], + [ + 'ML', + ], + [ + 'GN', + ], + [ + 'CI', + ], + [ + 'BF', + ], + [ + 'NE', + ], + [ + 'TG', + ], + [ + 'BJ', + ], + [ + 'MU', + ], + [ + 'LR', + ], + [ + 'SL', + ], + [ + 'GH', + ], + [ + 'NG', + ], + [ + 'TD', + ], + [ + 'CF', + ], + [ + 'CM', + ], + [ + 'CV', + ], + [ + 'ST', + ], + [ + 'GQ', + ], + [ + 'GA', + ], + [ + 'CG', + ], + [ + 'CD', + ], + [ + 'AO', + ], + [ + 'GW', + ], + [ + 'IO', + ], + [ + 'AC', + ], + [ + 'SC', + ], + [ + 'SD', + ], + [ + 'RW', + ], + [ + 'ET', + ], + [ + 'SO', + ], + [ + 'DJ', + ], + [ + 'KE', + ], + [ + 'TZ', + ], + [ + 'UG', + ], + [ + 'BI', + ], + [ + 'MZ', + ], + 260 => [ + 'ZM', + ], + [ + 'MG', + ], + [ + 'RE', + 'YT', + ], + [ + 'ZW', + ], + [ + 'NA', + ], + [ + 'MW', + ], + [ + 'LS', + ], + [ + 'BW', + ], + [ + 'SZ', + ], + [ + 'KM', + ], + 290 => [ + 'SH', + 'TA', + ], + [ + 'ER', + ], + 297 => [ + 'AW', + ], + [ + 'FO', + ], + [ + 'GL', + ], + 350 => [ + 'GI', + ], + [ + 'PT', + ], + [ + 'LU', + ], + [ + 'IE', + ], + [ + 'IS', + ], + [ + 'AL', + ], + [ + 'MT', + ], + [ + 'CY', + ], + [ + 'FI', + 'AX', + ], + [ + 'BG', + ], + 370 => [ + 'LT', + ], + [ + 'LV', + ], + [ + 'EE', + ], + [ + 'MD', + ], + [ + 'AM', + ], + [ + 'BY', + ], + [ + 'AD', + ], + [ + 'MC', + ], + [ + 'SM', + ], + 380 => [ + 'UA', + ], + [ + 'RS', + ], + [ + 'ME', + ], + [ + 'XK', + ], + 385 => [ + 'HR', + ], + [ + 'SI', + ], + [ + 'BA', + ], + 389 => [ + 'MK', + ], + 420 => [ + 'CZ', + ], + [ + 'SK', + ], + 423 => [ + 'LI', + ], + 500 => [ + 'FK', + ], + [ + 'BZ', + ], + [ + 'GT', + ], + [ + 'SV', + ], + [ + 'HN', + ], + [ + 'NI', + ], + [ + 'CR', + ], + [ + 'PA', + ], + [ + 'PM', + ], + [ + 'HT', + ], + 590 => [ + 'GP', + 'BL', + 'MF', + ], + [ + 'BO', + ], + [ + 'GY', + ], + [ + 'EC', + ], + [ + 'GF', + ], + [ + 'PY', + ], + [ + 'MQ', + ], + [ + 'SR', + ], + [ + 'UY', + ], + [ + 'CW', + 'BQ', + ], + 670 => [ + 'TL', + ], + 672 => [ + 'NF', + ], + [ + 'BN', + ], + [ + 'NR', + ], + [ + 'PG', + ], + [ + 'TO', + ], + [ + 'SB', + ], + [ + 'VU', + ], + [ + 'FJ', + ], + [ + 'PW', + ], + [ + 'WF', + ], + [ + 'CK', + ], + [ + 'NU', + ], + 685 => [ + 'WS', + ], + [ + 'KI', + ], + [ + 'NC', + ], + [ + 'TV', + ], + [ + 'PF', + ], + [ + 'TK', + ], + [ + 'FM', + ], + [ + 'MH', + ], + 800 => [ + '001', + ], + 808 => [ + '001', + ], + 850 => [ + 'KP', + ], + 852 => [ + 'HK', + ], + [ + 'MO', + ], + 855 => [ + 'KH', + ], + [ + 'LA', + ], + 870 => [ + '001', + ], + 878 => [ + '001', + ], + 880 => [ + 'BD', + ], + [ + '001', + ], + [ + '001', + ], + [ + '001', + ], + 886 => [ + 'TW', + ], + 888 => [ + '001', + ], + 960 => [ + 'MV', + ], + [ + 'LB', + ], + [ + 'JO', + ], + [ + 'SY', + ], + [ + 'IQ', + ], + [ + 'KW', + ], + [ + 'SA', + ], + [ + 'YE', + ], + [ + 'OM', + ], + 970 => [ + 'PS', + ], + [ + 'AE', + ], + [ + 'IL', + ], + [ + 'BH', + ], + [ + 'QA', + ], + [ + 'BT', + ], + [ + 'MN', + ], + [ + 'NP', + ], + 979 => [ + '001', + ], + 992 => [ + 'TJ', + ], + [ + 'TM', + ], + [ + 'AZ', + ], + [ + 'GE', + ], + [ + 'KG', + ], + 998 => [ + 'UZ', + ], + ]; } diff --git a/src/CountryCodeToRegionCodeMapForTesting.php b/src/CountryCodeToRegionCodeMapForTesting.php index d8b78e7bd..71016bab4 100644 --- a/src/CountryCodeToRegionCodeMapForTesting.php +++ b/src/CountryCodeToRegionCodeMapForTesting.php @@ -16,100 +16,100 @@ class CountryCodeToRegionCodeMapForTesting // indicated with "isMainCountryForCode" in the metadata should be first. public const COUNTRY_CODE_TO_REGION_CODE_MAP_FOR_TESTING = [ - 1 => [ - 'US', - 'BB', - 'BS', - 'CA', - ], - 7 => [ - 'RU', - ], - 33 => [ - 'FR', - ], - 39 => [ - 'IT', - ], - 44 => [ - 'GB', - 'GG', - ], - 46 => [ - 'SE', - ], - 48 => [ - 'PL', - ], - [ - 'DE', - ], - 52 => [ - 'MX', - ], - 54 => [ - 'AR', - ], - [ - 'BR', - ], - 57 => [ - 'CO', - ], - 61 => [ - 'AU', - 'CC', - 'CX', - ], - 64 => [ - 'NZ', - ], - [ - 'SG', - ], - 81 => [ - 'JP', - ], - [ - 'KR', - ], - 86 => [ - 'CN', - ], - 244 => [ - 'AO', - ], - 262 => [ - 'RE', - 'YT', - ], - 290 => [ - 'TA', - ], - 374 => [ - 'AM', - ], - [ - 'BY', - ], - [ - 'AD', - ], - 800 => [ - '001', - ], - 882 => [ - '001', - ], - 971 => [ - 'AE', - ], - 979 => [ - '001', - ], - 998 => [ - 'UZ', - ], -]; + 1 => [ + 'US', + 'BB', + 'BS', + 'CA', + ], + 7 => [ + 'RU', + ], + 33 => [ + 'FR', + ], + 39 => [ + 'IT', + ], + 44 => [ + 'GB', + 'GG', + ], + 46 => [ + 'SE', + ], + 48 => [ + 'PL', + ], + [ + 'DE', + ], + 52 => [ + 'MX', + ], + 54 => [ + 'AR', + ], + [ + 'BR', + ], + 57 => [ + 'CO', + ], + 61 => [ + 'AU', + 'CC', + 'CX', + ], + 64 => [ + 'NZ', + ], + [ + 'SG', + ], + 81 => [ + 'JP', + ], + [ + 'KR', + ], + 86 => [ + 'CN', + ], + 244 => [ + 'AO', + ], + 262 => [ + 'RE', + 'YT', + ], + 290 => [ + 'TA', + ], + 374 => [ + 'AM', + ], + [ + 'BY', + ], + [ + 'AD', + ], + 800 => [ + '001', + ], + 882 => [ + '001', + ], + 971 => [ + 'AE', + ], + 979 => [ + '001', + ], + 998 => [ + 'UZ', + ], + ]; } diff --git a/src/PhoneNumberUtil.php b/src/PhoneNumberUtil.php index 9dd531dc4..d043ce935 100644 --- a/src/PhoneNumberUtil.php +++ b/src/PhoneNumberUtil.php @@ -361,7 +361,7 @@ protected function __construct(MetadataSourceInterface $metadataSource, array $c // Put (lower letter -> upper letter) and (upper letter -> upper letter) mappings. foreach (static::ALPHA_MAPPINGS as $c => $value) { static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS[strtolower($c)] = $c; - static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS[(string)$c] = (string)$c; + static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS[(string) $c] = (string) $c; } static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS += static::ASCII_DIGIT_MAPPINGS; static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS['-'] = '-'; @@ -1628,7 +1628,7 @@ protected function parseHelper(string $numberToParse, ?string $defaultRegion, bo * * We have to remove the leading zeroes ourself though */ - if ((int)$normalizedNationalNumber === 0) { + if ((int) $normalizedNationalNumber === 0) { $normalizedNationalNumber = '0'; } else { $normalizedNationalNumber = ltrim($normalizedNationalNumber, '0'); @@ -1896,7 +1896,7 @@ public function maybeExtractCountryCode( // so, we remove the country calling code, and do some checks on the validity of the number // before and after. $defaultCountryCode = $defaultRegionMetadata->getCountryCode(); - $defaultCountryCodeString = (string)$defaultCountryCode; + $defaultCountryCodeString = (string) $defaultCountryCode; $normalizedNumber = $fullNumber; if (str_starts_with($normalizedNumber, $defaultCountryCodeString)) { $potentialNationalNumber = substr($normalizedNumber, mb_strlen($defaultCountryCodeString)); @@ -2062,7 +2062,7 @@ protected function extractCountryCode(string $fullNumber, string &$nationalNumbe } $numberLength = strlen($fullNumber); for ($i = 1; $i <= static::MAX_LENGTH_COUNTRY_CODE && $i <= $numberLength; $i++) { - $potentialCountryCode = (int)substr($fullNumber, 0, $i); + $potentialCountryCode = (int) substr($fullNumber, 0, $i); if (isset($this->countryCallingCodeToRegionCodeMap[$potentialCountryCode])) { $nationalNumber .= substr($fullNumber, $i); return $potentialCountryCode; @@ -3364,8 +3364,8 @@ public function isNumberMatch(PhoneNumber|string $firstNumberIn, PhoneNumber|str */ protected function isNationalNumberSuffixOfTheOther(PhoneNumber $firstNumber, PhoneNumber $secondNumber): bool { - $firstNumberNationalNumber = trim((string)$firstNumber->getNationalNumber()); - $secondNumberNationalNumber = trim((string)$secondNumber->getNationalNumber()); + $firstNumberNationalNumber = trim((string) $firstNumber->getNationalNumber()); + $secondNumberNationalNumber = trim((string) $secondNumber->getNationalNumber()); return str_ends_with($firstNumberNationalNumber, $secondNumberNationalNumber) || str_ends_with($secondNumberNationalNumber, $firstNumberNationalNumber); } diff --git a/src/RegexBasedMatcher.php b/src/RegexBasedMatcher.php index f68c4e08e..68f787566 100644 --- a/src/RegexBasedMatcher.php +++ b/src/RegexBasedMatcher.php @@ -17,9 +17,7 @@ public static function create(): static } // Keep PHPStan happy (Unsafe usage of new static()) - final public function __construct() - { - } + final public function __construct() {} /** * Returns whether the given national number (a string containing only decimal digits) matches diff --git a/src/ShortNumbersRegionCodeSet.php b/src/ShortNumbersRegionCodeSet.php index 62623add0..905ee9917 100644 --- a/src/ShortNumbersRegionCodeSet.php +++ b/src/ShortNumbersRegionCodeSet.php @@ -13,247 +13,247 @@ class ShortNumbersRegionCodeSet // A set of all region codes for which data is available. public const SHORT_NUMBERS_REGION_CODE_SET = [ - 'AC', - 'AD', - 'AE', - 'AF', - 'AG', - 'AI', - 'AL', - 'AM', - 'AO', - 'AR', - 'AS', - 'AT', - 'AU', - 'AW', - 'AX', - 'AZ', - 'BA', - 'BB', - 'BD', - 'BE', - 'BF', - 'BG', - 'BH', - 'BI', - 'BJ', - 'BL', - 'BM', - 'BN', - 'BO', - 'BQ', - 'BR', - 'BS', - 'BT', - 'BW', - 'BY', - 'BZ', - 'CA', - 'CC', - 'CD', - 'CF', - 'CG', - 'CH', - 'CI', - 'CK', - 'CL', - 'CM', - 'CN', - 'CO', - 'CR', - 'CU', - 'CV', - 'CW', - 'CX', - 'CY', - 'CZ', - 'DE', - 'DJ', - 'DK', - 'DM', - 'DO', - 'DZ', - 'EC', - 'EE', - 'EG', - 'EH', - 'ER', - 'ES', - 'ET', - 'FI', - 'FJ', - 'FK', - 'FM', - 'FO', - 'FR', - 'GA', - 'GB', - 'GD', - 'GE', - 'GF', - 'GG', - 'GH', - 'GI', - 'GL', - 'GM', - 'GN', - 'GP', - 'GR', - 'GT', - 'GU', - 'GW', - 'GY', - 'HK', - 'HN', - 'HR', - 'HT', - 'HU', - 'ID', - 'IE', - 'IL', - 'IM', - 'IN', - 'IQ', - 'IR', - 'IS', - 'IT', - 'JE', - 'JM', - 'JO', - 'JP', - 'KE', - 'KG', - 'KH', - 'KI', - 'KM', - 'KN', - 'KP', - 'KR', - 'KW', - 'KY', - 'KZ', - 'LA', - 'LB', - 'LC', - 'LI', - 'LK', - 'LR', - 'LS', - 'LT', - 'LU', - 'LV', - 'LY', - 'MA', - 'MC', - 'MD', - 'ME', - 'MF', - 'MG', - 'MH', - 'MK', - 'ML', - 'MM', - 'MN', - 'MO', - 'MP', - 'MQ', - 'MR', - 'MS', - 'MT', - 'MU', - 'MV', - 'MW', - 'MX', - 'MY', - 'MZ', - 'NA', - 'NC', - 'NE', - 'NF', - 'NG', - 'NI', - 'NL', - 'NO', - 'NP', - 'NR', - 'NU', - 'NZ', - 'OM', - 'PA', - 'PE', - 'PF', - 'PG', - 'PH', - 'PK', - 'PL', - 'PM', - 'PR', - 'PS', - 'PT', - 'PW', - 'PY', - 'QA', - 'RE', - 'RO', - 'RS', - 'RU', - 'RW', - 'SA', - 'SB', - 'SC', - 'SD', - 'SE', - 'SG', - 'SH', - 'SI', - 'SJ', - 'SK', - 'SL', - 'SM', - 'SN', - 'SO', - 'SR', - 'SS', - 'ST', - 'SV', - 'SX', - 'SY', - 'SZ', - 'TC', - 'TD', - 'TG', - 'TH', - 'TJ', - 'TL', - 'TM', - 'TN', - 'TO', - 'TR', - 'TT', - 'TV', - 'TW', - 'TZ', - 'UA', - 'UG', - 'US', - 'UY', - 'UZ', - 'VA', - 'VC', - 'VE', - 'VG', - 'VI', - 'VN', - 'VU', - 'WF', - 'WS', - 'XK', - 'YE', - 'YT', - 'ZA', - 'ZM', - 'ZW', -]; + 'AC', + 'AD', + 'AE', + 'AF', + 'AG', + 'AI', + 'AL', + 'AM', + 'AO', + 'AR', + 'AS', + 'AT', + 'AU', + 'AW', + 'AX', + 'AZ', + 'BA', + 'BB', + 'BD', + 'BE', + 'BF', + 'BG', + 'BH', + 'BI', + 'BJ', + 'BL', + 'BM', + 'BN', + 'BO', + 'BQ', + 'BR', + 'BS', + 'BT', + 'BW', + 'BY', + 'BZ', + 'CA', + 'CC', + 'CD', + 'CF', + 'CG', + 'CH', + 'CI', + 'CK', + 'CL', + 'CM', + 'CN', + 'CO', + 'CR', + 'CU', + 'CV', + 'CW', + 'CX', + 'CY', + 'CZ', + 'DE', + 'DJ', + 'DK', + 'DM', + 'DO', + 'DZ', + 'EC', + 'EE', + 'EG', + 'EH', + 'ER', + 'ES', + 'ET', + 'FI', + 'FJ', + 'FK', + 'FM', + 'FO', + 'FR', + 'GA', + 'GB', + 'GD', + 'GE', + 'GF', + 'GG', + 'GH', + 'GI', + 'GL', + 'GM', + 'GN', + 'GP', + 'GR', + 'GT', + 'GU', + 'GW', + 'GY', + 'HK', + 'HN', + 'HR', + 'HT', + 'HU', + 'ID', + 'IE', + 'IL', + 'IM', + 'IN', + 'IQ', + 'IR', + 'IS', + 'IT', + 'JE', + 'JM', + 'JO', + 'JP', + 'KE', + 'KG', + 'KH', + 'KI', + 'KM', + 'KN', + 'KP', + 'KR', + 'KW', + 'KY', + 'KZ', + 'LA', + 'LB', + 'LC', + 'LI', + 'LK', + 'LR', + 'LS', + 'LT', + 'LU', + 'LV', + 'LY', + 'MA', + 'MC', + 'MD', + 'ME', + 'MF', + 'MG', + 'MH', + 'MK', + 'ML', + 'MM', + 'MN', + 'MO', + 'MP', + 'MQ', + 'MR', + 'MS', + 'MT', + 'MU', + 'MV', + 'MW', + 'MX', + 'MY', + 'MZ', + 'NA', + 'NC', + 'NE', + 'NF', + 'NG', + 'NI', + 'NL', + 'NO', + 'NP', + 'NR', + 'NU', + 'NZ', + 'OM', + 'PA', + 'PE', + 'PF', + 'PG', + 'PH', + 'PK', + 'PL', + 'PM', + 'PR', + 'PS', + 'PT', + 'PW', + 'PY', + 'QA', + 'RE', + 'RO', + 'RS', + 'RU', + 'RW', + 'SA', + 'SB', + 'SC', + 'SD', + 'SE', + 'SG', + 'SH', + 'SI', + 'SJ', + 'SK', + 'SL', + 'SM', + 'SN', + 'SO', + 'SR', + 'SS', + 'ST', + 'SV', + 'SX', + 'SY', + 'SZ', + 'TC', + 'TD', + 'TG', + 'TH', + 'TJ', + 'TL', + 'TM', + 'TN', + 'TO', + 'TR', + 'TT', + 'TV', + 'TW', + 'TZ', + 'UA', + 'UG', + 'US', + 'UY', + 'UZ', + 'VA', + 'VC', + 'VE', + 'VG', + 'VI', + 'VN', + 'VU', + 'WF', + 'WS', + 'XK', + 'YE', + 'YT', + 'ZA', + 'ZM', + 'ZW', + ]; } diff --git a/tests/Issues/CodeCoverageTest.php b/tests/Issues/CodeCoverageTest.php index 416fffa01..10d2e56d5 100644 --- a/tests/Issues/CodeCoverageTest.php +++ b/tests/Issues/CodeCoverageTest.php @@ -25,7 +25,7 @@ public function testTooShortNumber(): void $this->assertEquals('The string supplied is too short to be a phone number.', $e->getMessage()); $this->assertEquals(3, $e->getCode()); - $this->assertEquals('Error type: 3. The string supplied is too short to be a phone number.', (string)$e); + $this->assertEquals('Error type: 3. The string supplied is too short to be a phone number.', (string) $e); } } diff --git a/tests/Issues/RegionCodeCaseInsensitiveTest.php b/tests/Issues/RegionCodeCaseInsensitiveTest.php index 9ee0f9699..9aad37478 100644 --- a/tests/Issues/RegionCodeCaseInsensitiveTest.php +++ b/tests/Issues/RegionCodeCaseInsensitiveTest.php @@ -47,16 +47,16 @@ public function testGetCountryCodeForRegion(): void public function testExampleNumber(): void { $this->assertSame( - (string)$this->phoneUtil->parse('+441212345678'), - (string)$this->phoneUtil->getExampleNumber('gb') + (string) $this->phoneUtil->parse('+441212345678'), + (string) $this->phoneUtil->getExampleNumber('gb') ); $this->assertSame( - (string)$this->phoneUtil->parse('+44121234567'), - (string)$this->phoneUtil->getInvalidExampleNumber('gb') + (string) $this->phoneUtil->parse('+44121234567'), + (string) $this->phoneUtil->getInvalidExampleNumber('gb') ); $this->assertSame( - (string)$this->phoneUtil->parse('+447400123456'), - (string)$this->phoneUtil->getExampleNumberForType('gb', PhoneNumberType::MOBILE) + (string) $this->phoneUtil->parse('+447400123456'), + (string) $this->phoneUtil->getExampleNumberForType('gb', PhoneNumberType::MOBILE) ); } }