From f431b2516154d24de14ae867c1df2e5b9dd98067 Mon Sep 17 00:00:00 2001 From: Joshua Gigg Date: Tue, 13 Aug 2024 13:10:36 +0100 Subject: [PATCH 1/2] Upstream metadata changes from Google for v8.13.43 - Updated phone metadata for region code(s): AO, BD, BJ, CM, CN, DE, DZ, EG, FR, HK, IL, ZA --- METADATA-VERSION.php | 2 +- src/data/PhoneNumberMetadata_AO.php | 2 +- src/data/PhoneNumberMetadata_BD.php | 4 ++-- src/data/PhoneNumberMetadata_BJ.php | 4 ++-- src/data/PhoneNumberMetadata_CM.php | 2 +- src/data/PhoneNumberMetadata_CN.php | 28 ++++++++++++++++++---------- src/data/PhoneNumberMetadata_DE.php | 2 +- src/data/PhoneNumberMetadata_DZ.php | 2 +- src/data/PhoneNumberMetadata_EG.php | 2 +- src/data/PhoneNumberMetadata_FR.php | 2 +- src/data/PhoneNumberMetadata_HK.php | 4 ++-- src/data/PhoneNumberMetadata_IL.php | 2 +- src/data/PhoneNumberMetadata_ZA.php | 2 +- 13 files changed, 33 insertions(+), 25 deletions(-) diff --git a/METADATA-VERSION.php b/METADATA-VERSION.php index c51943af..03b278e2 100644 --- a/METADATA-VERSION.php +++ b/METADATA-VERSION.php @@ -5,4 +5,4 @@ * For more information, look at the phing tasks in build.xml * @internal */ -return 'v8.13.42'; +return 'v8.13.43'; diff --git a/src/data/PhoneNumberMetadata_AO.php b/src/data/PhoneNumberMetadata_AO.php index 2ec75161..ee98029e 100644 --- a/src/data/PhoneNumberMetadata_AO.php +++ b/src/data/PhoneNumberMetadata_AO.php @@ -20,7 +20,7 @@ 'example' => '222123456', ], 'mobile' => [ - 'pattern' => '9[1-579]\\d{7}', + 'pattern' => '9[1-79]\\d{7}', 'example' => '923123456', ], 'tollFree' => [ diff --git a/src/data/PhoneNumberMetadata_BD.php b/src/data/PhoneNumberMetadata_BD.php index f145c648..5b6e5114 100644 --- a/src/data/PhoneNumberMetadata_BD.php +++ b/src/data/PhoneNumberMetadata_BD.php @@ -20,7 +20,7 @@ ], ], 'fixedLine' => [ - 'pattern' => '(?:4(?:31\\d\\d|423)|5222)\\d{3}(?:\\d{2})?|8332[6-9]\\d\\d|(?:3(?:03[56]|224)|4(?:22[25]|653))\\d{3,4}|(?:3(?:42[47]|529|823)|4(?:027|525|65(?:28|8))|562|6257|7(?:1(?:5[3-5]|6[12]|7[156]|89)|22[589]56|32|42675|52(?:[25689](?:56|8)|[347]8)|71(?:6[1267]|75|89)|92374)|82(?:2[59]|32)56|9(?:03[23]56|23(?:256|373)|31|5(?:1|2[4589]56)))\\d{3}|(?:3(?:02[348]|22[35]|324|422)|4(?:22[67]|32[236-9]|6(?:2[46]|5[57])|953)|5526|6(?:024|6655)|81)\\d{4,5}|(?:2(?:7(?:1[0-267]|2[0-289]|3[0-29]|4[01]|5[1-3]|6[013]|7[0178]|91)|8(?:0[125]|1[1-6]|2[0157-9]|3[1-69]|41|6[1-35]|7[1-5]|8[1-8]|9[0-6])|9(?:0[0-2]|1[0-4]|2[568]|3[3-6]|5[5-7]|6[0136-9]|7[0-7]|8[014-9]))|3(?:0(?:2[025-79]|3[2-4])|181|22[12]|32[2356]|824)|4(?:02[09]|22[348]|32[045]|523|6(?:27|54))|666(?:22|53)|7(?:22[57-9]|42[56]|82[35])8|8(?:0[124-9]|2(?:181|2[02-4679]8)|4[12]|[5-7]2)|9(?:[04]2|2(?:2|328)|81))\\d{4}|(?:2(?:2\\d|[45])\\d\\d|3(?:1(?:2[5-7]|[5-7])|425|822)|4(?:033|1\\d|[257]1|332|4(?:2[246]|5[25])|6(?:2[35]|56|62)|8(?:23|54)|92[2-5])|5(?:02[03489]|22[457]|32[35-79]|42[46]|6(?:[18]|53)|724|826)|6(?:023|2(?:2[2-5]|5[3-5]|8)|32[3478]|42[34]|52[47]|6(?:[18]|6(?:2[34]|5[24]))|[78]2[2-5]|92[2-6])|7(?:02|21\\d|[3-589]1|6[12]|72[24])|8(?:217|3[12]|[5-7]1)|9[24]1)\\d{5}|(?:(?:3[2-8]|5[2-57-9]|6[03-589])1|4[4689][18])\\d{5}|[59]1\\d{5}', + 'pattern' => '(?:4(?:31\\d\\d|423)|5222)\\d{3}(?:\\d{2})?|8332[6-9]\\d\\d|(?:3(?:03[56]|224)|4(?:22[25]|653))\\d{3,4}|(?:3(?:42[47]|529|823)|4(?:027|525|65(?:28|8))|562|6257|7(?:1(?:5[3-5]|6[12]|7[156]|89)|22[589]56|32|42675|52(?:[25689](?:56|8)|[347]8)|71(?:6[1267]|75|89)|92374)|82(?:2[59]|32)56|9(?:03[23]56|23(?:256|373)|31|5(?:1|2[4589]56)))\\d{3}|(?:3(?:02[348]|22[35]|324|422)|4(?:22[67]|32[236-9]|6(?:2[46]|5[57])|953)|5526|6(?:024|6655)|81)\\d{4,5}|(?:2(?:7(?:1[0-267]|2[0-289]|3[0-29]|4[01]|5[1-3]|6[013]|7[0178]|91)|8(?:0[125]|1[1-6]|2[0157-9]|3[1-69]|41|6[1-35]|7[1-5]|8[1-8]|9[0-6])|9(?:0[0-2]|1[0-4]|2[568]|3[3-6]|5[5-7]|6[0136-9]|7[0-7]|8[014-9]))|3(?:0(?:2[025-79]|3[2-4])|181|22[12]|32[2356]|824)|4(?:02[09]|22[348]|32[045]|523|6(?:27|54))|666(?:22|53)|7(?:22[57-9]|42[56]|82[35])8|8(?:0[124-9]|2(?:181|2[02-4679]8)|4[12]|[5-7]2)|9(?:[04]2|2(?:2|328)|81))\\d{4}|(?:2(?:[23]\\d|[45])\\d\\d|3(?:1(?:2[5-7]|[5-7])|425|822)|4(?:033|1\\d|[257]1|332|4(?:2[246]|5[25])|6(?:2[35]|56|62)|8(?:23|54)|92[2-5])|5(?:02[03489]|22[457]|32[35-79]|42[46]|6(?:[18]|53)|724|826)|6(?:023|2(?:2[2-5]|5[3-5]|8)|32[3478]|42[34]|52[47]|6(?:[18]|6(?:2[34]|5[24]))|[78]2[2-5]|92[2-6])|7(?:02|21\\d|[3-589]1|6[12]|72[24])|8(?:217|3[12]|[5-7]1)|9[24]1)\\d{5}|(?:(?:3[2-8]|5[2-57-9]|6[03-589])1|4[4689][18])\\d{5}|[59]1\\d{5}', 'example' => '27111234', ], 'mobile' => [ @@ -105,7 +105,7 @@ 'pattern' => '(\\d{4})(\\d{3,6})', 'format' => '$1-$2', 'leadingDigitsPatterns' => [ - '[13-9]|22', + '[13-9]|2[23]', ], 'nationalPrefixFormattingRule' => '0$1', 'domesticCarrierCodeFormattingRule' => '', diff --git a/src/data/PhoneNumberMetadata_BJ.php b/src/data/PhoneNumberMetadata_BJ.php index 38f38784..05532aa4 100644 --- a/src/data/PhoneNumberMetadata_BJ.php +++ b/src/data/PhoneNumberMetadata_BJ.php @@ -16,11 +16,11 @@ ], ], 'fixedLine' => [ - 'pattern' => '2(?:02|1[037]|2[45]|3[68]|4\\d)\\d{5}', + 'pattern' => '2090\\d{4}|2(?:02|1[037]|2[45]|3[68]|4\\d)\\d{5}', 'example' => '20211234', ], 'mobile' => [ - 'pattern' => '(?:4[0-7]|[56]\\d|9[013-9])\\d{6}', + 'pattern' => '(?:4[0-8]|[56]\\d|9[013-9])\\d{6}', 'example' => '90011234', ], 'tollFree' => [ diff --git a/src/data/PhoneNumberMetadata_CM.php b/src/data/PhoneNumberMetadata_CM.php index be42ac77..34c21778 100644 --- a/src/data/PhoneNumberMetadata_CM.php +++ b/src/data/PhoneNumberMetadata_CM.php @@ -24,7 +24,7 @@ ], ], 'mobile' => [ - 'pattern' => '(?:24[23]|6[25-9]\\d)\\d{6}', + 'pattern' => '(?:24[23]|6(?:[25-9]\\d|40))\\d{6}', 'example' => '671234567', 'posLength' => [ 9, diff --git a/src/data/PhoneNumberMetadata_CN.php b/src/data/PhoneNumberMetadata_CN.php index 772db05e..048762d9 100644 --- a/src/data/PhoneNumberMetadata_CN.php +++ b/src/data/PhoneNumberMetadata_CN.php @@ -10,7 +10,7 @@ 'id' => 'CN', 'countryCode' => 86, 'generalDesc' => [ - 'pattern' => '1[127]\\d{8,9}|2\\d{9}(?:\\d{2})?|[12]\\d{6,7}|86\\d{6}|(?:1[03-689]\\d|6)\\d{7,9}|(?:[3-579]\\d|8[0-57-9])\\d{6,9}', + 'pattern' => '(?:(?:1[03-689]|2\\d)\\d\\d|6)\\d{8}|1\\d{10}|[126]\\d{6}(?:\\d(?:\\d{2})?)?|86\\d{5,6}|(?:[3-579]\\d|8[0-57-9])\\d{5,9}', 'posLength' => [ 7, 8, @@ -25,7 +25,7 @@ ], ], 'fixedLine' => [ - 'pattern' => '(?:10(?:[02-79]\\d\\d|[18](?:0[1-9]|[1-9]\\d))|21(?:[18](?:0[1-9]|[1-9]\\d)|[2-79]\\d\\d))\\d{5}|(?:43[35]|754)\\d{7,8}|8(?:078\\d{7}|51\\d{7,8})|(?:10|(?:2|85)1|43[35]|754)(?:100\\d\\d|95\\d{3,4})|(?:2[02-57-9]|3(?:11|7[179])|4(?:[15]1|3[12])|5(?:1\\d|2[37]|3[12]|51|7[13-79]|9[15])|7(?:[39]1|5[57]|6[09])|8(?:71|98))(?:[02-8]\\d{7}|1(?:0(?:0\\d\\d(?:\\d{3})?|[1-9]\\d{5})|[1-9]\\d{6})|9(?:[0-46-9]\\d{6}|5\\d{3}(?:\\d(?:\\d{2})?)?))|(?:3(?:1[02-9]|35|49|5\\d|7[02-68]|9[1-68])|4(?:1[02-9]|2[179]|3[46-9]|5[2-9]|6[47-9]|7\\d|8[23])|5(?:3[03-9]|4[36]|5[02-9]|6[1-46]|7[028]|80|9[2-46-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[17]\\d|2[248]|3[04-9]|4[3-6]|5[0-3689]|6[2368]|9[02-9])|8(?:1[236-8]|2[5-7]|3\\d|5[2-9]|7[02-9]|8[36-8]|9[1-7])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:[02-8]\\d{6}|1(?:0(?:0\\d\\d(?:\\d{2})?|[1-9]\\d{4})|[1-9]\\d{5})|9(?:[0-46-9]\\d{5}|5\\d{3,5}))', + 'pattern' => '(?:10(?:[02-79]\\d\\d|[18](?:0[1-9]|[1-9]\\d))|2(?:[02-57-9]\\d{3}|1(?:[18](?:0[1-9]|[1-9]\\d)|[2-79]\\d\\d))|(?:41[03]|8078|9(?:78|94))\\d\\d)\\d{5}|(?:10|2[0-57-9])(?:1(?:00|23)\\d\\d|95\\d{3,4})|(?:41[03]|9(?:78|94))(?:100\\d\\d|95\\d{3,4})|8078123|(?:43[35]|754|851)\\d{7,8}|(?:43[35]|754|851)(?:1(?:00\\d|23)\\d|95\\d{3,4})|(?:3(?:11|7[179])|4(?:[15]1|3[12])|5(?:1\\d|2[37]|3[12]|51|7[13-79]|9[15])|7(?:[39]1|5[57]|6[09])|8(?:71|98))(?:[02-8]\\d{7}|1(?:0(?:0\\d\\d(?:\\d{3})?|[1-9]\\d{5})|[13-9]\\d{6}|2(?:[0-24-9]\\d{5}|3\\d(?:\\d{4})?))|9(?:[0-46-9]\\d{6}|5\\d{3}(?:\\d(?:\\d{2})?)?))|(?:3(?:1[02-9]|35|49|5\\d|7[02-68]|9[1-68])|4(?:1[24-9]|2[179]|3[46-9]|5[2-9]|6[47-9]|7\\d|8[23])|5(?:3[03-9]|4[36]|5[02-9]|6[1-46]|7[028]|80|9[2-46-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[17]\\d|2[248]|3[04-9]|4[3-6]|5[0-3689]|6[2368]|9[02-9])|8(?:1[236-8]|2[5-7]|3\\d|5[2-9]|7[02-9]|8[36-8]|9[1-7])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))(?:[02-8]\\d{6}|1(?:0(?:0\\d\\d(?:\\d{2})?|[1-9]\\d{4})|[13-9]\\d{5}|2(?:[0-24-9]\\d{4}|3\\d(?:\\d{3})?))|9(?:[0-46-9]\\d{5}|5\\d{3,5}))', 'example' => '1012345678', 'posLength' => [ 7, @@ -129,7 +129,9 @@ 'pattern' => '(\\d{5,6})', 'format' => '$1', 'leadingDigitsPatterns' => [ - '10', + '1(?:0|23)|781|[1-9]12', + '1(?:0|23)|7812|[1-9]123', + '1(?:0|23(?:[0-8]|9[0-46-9]))|78123|[1-9]123', ], 'nationalPrefixFormattingRule' => '', 'domesticCarrierCodeFormattingRule' => '', @@ -138,9 +140,11 @@ 'pattern' => '(\\d{2})(\\d{5,6})', 'format' => '$1 $2', 'leadingDigitsPatterns' => [ - '(?:10|2[0-57-9])[19]', - '(?:10|2[0-57-9])(?:10|9[56])', - '10(?:10|9[56])|2[0-57-9](?:100|9[56])', + '(?:10|2[0-57-9])[19]|3(?:[157]|35|49|9[1-68])|4(?:1[124-9]|2[179]|6[47-9]|7|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:07|1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3|4[13]|5[1-5]|7[0-79]|9[0-35-9])|(?:4[35]|59|85)[1-9]', + '(?:10|2[0-57-9])(?:1[02]|9[56])|8078|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))1', + '10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|80781|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))12', + '10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|807812|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123', + '10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:078|1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123', ], 'nationalPrefixFormattingRule' => '0$1', 'domesticCarrierCodeFormattingRule' => '$CC $1', @@ -151,7 +155,9 @@ 'leadingDigitsPatterns' => [ '[1-9]', '1[1-9]|26|[3-9]|(?:10|2[0-57-9])(?:[0-8]|9[0-47-9])', - '1(?:0(?:[0-8]|9[0-47-9])|[1-9])|2(?:[0-57-9](?:[02-8]|1(?:0[1-9]|[1-9])|9[0-47-9])|6)|[3-9]', + '1(?:0(?:[02-8]|1(?:[013-9]|2[0-24-9])|9[0-47-9])|[1-9])|2(?:[0-57-9](?:[02-8]|1(?:0[1-9]|[13-9]|2[0-24-9])|9[0-47-9])|6)|[3-9]', + '1(?:0(?:[02-8]|1(?:[013-9]|2[0-24-9])|9[0-47-9])|[1-9])|2(?:[0-57-9](?:[02-8]|1(?:0[1-9]|[13-9]|2[0-24-9])|9[0-47-9])|6)|3(?:[0268]|3[0-46-9]|4[0-8]|9[079])|4(?:[049]|1[03]|2[02-68]|[35]0|6[0-356]|8[014-9])|5(?:0|2[0-24-689]|4[0-2457-9]|6[057-9]|8[1-9]|90)|6(?:[0-24578]|3[06-9]|6[14-79]|9[03-9])|7(?:0[02-9]|2[0135-79]|3[23]|4[0-27-9]|6[1457]|8)|8(?:[046]|1[01459]|2[0-489]|50|8[0-2459]|9[09])|9(?:0[0457]|1[08]|[268]|4[024-9]|5[06-9]|78|94)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))(?:[02-9]|1(?:[013-9]|2[0-24-9]))', + '1(?:0(?:[02-8]|1(?:[013-9]|2[0-24-9])|9[0-47-9])|[1-9])|2(?:[0-57-9](?:[02-8]|1(?:0[1-9]|[13-9]|2[0-24-9])|9[0-47-9])|6)|3(?:[0268]|3[0-46-9]|4[0-8]|9[079])|4(?:[049]|1[03]|2[02-68]|[35]0|6[0-356]|8[014-9])|5(?:0|2[0-24-689]|4[0-2457-9]|6[057-9]|8[1-9]|90)|6(?:[0-24578]|3[06-9]|6[14-79]|9[03-9])|7(?:0[02-9]|2[0135-79]|3[23]|4[0-27-9]|6[1457]|8)|8(?:0(?:[0-689]|7[0-79])|1[01459]|2[0-489]|[46]|50|8[0-2459]|9[09])|9(?:0[0457]|1[08]|[268]|4[024-9]|5[06-9]|78|94)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:078|1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))(?:[02-9]|1(?:[013-9]|2[0-24-9]))', ], 'nationalPrefixFormattingRule' => '', 'domesticCarrierCodeFormattingRule' => '', @@ -274,9 +280,11 @@ 'pattern' => '(\\d{2})(\\d{5,6})', 'format' => '$1 $2', 'leadingDigitsPatterns' => [ - '(?:10|2[0-57-9])[19]', - '(?:10|2[0-57-9])(?:10|9[56])', - '10(?:10|9[56])|2[0-57-9](?:100|9[56])', + '(?:10|2[0-57-9])[19]|3(?:[157]|35|49|9[1-68])|4(?:1[124-9]|2[179]|6[47-9]|7|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:07|1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3|4[13]|5[1-5]|7[0-79]|9[0-35-9])|(?:4[35]|59|85)[1-9]', + '(?:10|2[0-57-9])(?:1[02]|9[56])|8078|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))1', + '10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|80781|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))12', + '10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|807812|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123', + '10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:078|1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123', ], 'nationalPrefixFormattingRule' => '0$1', 'domesticCarrierCodeFormattingRule' => '$CC $1', diff --git a/src/data/PhoneNumberMetadata_DE.php b/src/data/PhoneNumberMetadata_DE.php index 8fb8e1ac..de1f0c11 100644 --- a/src/data/PhoneNumberMetadata_DE.php +++ b/src/data/PhoneNumberMetadata_DE.php @@ -53,7 +53,7 @@ ], ], 'mobile' => [ - 'pattern' => '15(?:[0-25-9]\\d\\d|310)\\d{6}|1(?:6[023]|7\\d)\\d{7,8}', + 'pattern' => '15310\\d{6}|1(?:6[023]|7[0-57-9])\\d{7,8}|1(?:5[0-25-9]|76)\\d{8}', 'example' => '15123456789', 'posLength' => [ 10, diff --git a/src/data/PhoneNumberMetadata_DZ.php b/src/data/PhoneNumberMetadata_DZ.php index 5564baef..17e6ed37 100644 --- a/src/data/PhoneNumberMetadata_DZ.php +++ b/src/data/PhoneNumberMetadata_DZ.php @@ -21,7 +21,7 @@ 'example' => '12345678', ], 'mobile' => [ - 'pattern' => '(?:5(?:4[0-29]|5\\d|6[0-2])|6(?:[569]\\d|7[0-6])|7[7-9]\\d)\\d{6}', + 'pattern' => '(?:5(?:4[0-29]|5\\d|6[0-3])|6(?:[569]\\d|7[0-6])|7[7-9]\\d)\\d{6}', 'example' => '551234567', 'posLength' => [ 9, diff --git a/src/data/PhoneNumberMetadata_EG.php b/src/data/PhoneNumberMetadata_EG.php index 6b9c331b..a3ed0ba4 100644 --- a/src/data/PhoneNumberMetadata_EG.php +++ b/src/data/PhoneNumberMetadata_EG.php @@ -22,7 +22,7 @@ ], ], 'fixedLine' => [ - 'pattern' => '13[23]\\d{6}|(?:15|57)\\d{6,7}|(?:2[2-4]|3|4[05-8]|5[05]|6[24-689]|8[2468]|9[235-7])\\d{7}', + 'pattern' => '13[23]\\d{6}|(?:15|57)\\d{6,7}|(?:2\\d|3|4[05-8]|5[05]|6[24-689]|8[2468]|9[235-7])\\d{7}', 'example' => '234567890', 'posLength' => [ 8, diff --git a/src/data/PhoneNumberMetadata_FR.php b/src/data/PhoneNumberMetadata_FR.php index 386aea2a..7d92f135 100644 --- a/src/data/PhoneNumberMetadata_FR.php +++ b/src/data/PhoneNumberMetadata_FR.php @@ -32,7 +32,7 @@ 'example' => '891123456', ], 'sharedCost' => [ - 'pattern' => '8(?:1[01]|2[0156]|4[02]|84)\\d{6}', + 'pattern' => '8(?:1[01]|2[0156]|4[024]|84)\\d{6}', 'example' => '884012345', ], 'personalNumber' => [ diff --git a/src/data/PhoneNumberMetadata_HK.php b/src/data/PhoneNumberMetadata_HK.php index af6dbb7a..f3b4a40c 100644 --- a/src/data/PhoneNumberMetadata_HK.php +++ b/src/data/PhoneNumberMetadata_HK.php @@ -21,14 +21,14 @@ ], ], 'fixedLine' => [ - 'pattern' => '(?:2(?:[13-9]\\d|2[013-9])\\d|3(?:(?:[1569][0-24-9]|4[0-246-9]|7[0-24-69])\\d|8(?:4[0-8]|[59]\\d|6[0-2]))|58(?:0[1-9]|1[2-9]))\\d{4}', + 'pattern' => '(?:2(?:[13-9]\\d|2[013-9])\\d|3(?:(?:[1569][0-24-9]|4[0-246-9]|7[0-24-69])\\d|8(?:4[0-8]|[579]\\d|6[0-2]))|58(?:0[1-9]|1[2-9]))\\d{4}', 'example' => '21234567', 'posLength' => [ 8, ], ], 'mobile' => [ - 'pattern' => '(?:4(?:44[0-25-9]|6(?:1[0-7]|4[0-57-9]|6[0-4]))|5(?:73[0-6]|95[0-8])|6(?:26[013-8]|66[0-3])|70(?:7[1-8]|8[0-4])|848[0-35-9]|9(?:29[013-9]|39[01]|59[0-4]|899))\\d{4}|(?:4(?:4[0-35-8]|6[02357-9]|70)|5(?:[1-59][0-46-9]|6[0-4689]|7[0-246-9])|6(?:0[1-9]|[13-59]\\d|[268][0-57-9]|7[0-79])|70[1-39]|84[0-29]|9(?:0[1-9]|1[02-9]|[2358][0-8]|[467]\\d))\\d{5}', + 'pattern' => '(?:4(?:44[0-25-9]|6(?:1[0-7]|4[0-57-9]|6[0-4]))|5(?:73[0-6]|95[0-8])|6(?:26[013-8]|66[0-3])|70(?:7[1-8]|8[0-4])|848[0-35-9]|9(?:29[013-9]|39[01]|59[0-4]|899))\\d{4}|(?:4(?:4[0-35-9]|6[02357-9]|70)|5(?:[1-59][0-46-9]|6[0-4689]|7[0-246-9])|6(?:0[1-9]|[13-59]\\d|[268][0-57-9]|7[0-79])|70[1-39]|84[0-39]|9(?:0[1-9]|1[02-9]|[2358][0-8]|[467]\\d))\\d{5}', 'example' => '51234567', 'posLength' => [ 8, diff --git a/src/data/PhoneNumberMetadata_IL.php b/src/data/PhoneNumberMetadata_IL.php index 37c40ed6..5ea3cbb1 100644 --- a/src/data/PhoneNumberMetadata_IL.php +++ b/src/data/PhoneNumberMetadata_IL.php @@ -68,7 +68,7 @@ ], ], 'voip' => [ - 'pattern' => '7(?:38(?:0\\d|5[0-259]|88)|8(?:33|55|77|81)\\d)\\d{4}|7(?:18|2[23]|3[237]|47|6[258]|7\\d|82|9[2-9])\\d{6}', + 'pattern' => '7(?:38(?:0\\d|5[0-2569]|88)|8(?:33|55|77|81)\\d)\\d{4}|7(?:18|2[23]|3[237]|47|6[258]|7\\d|82|9[2-9])\\d{6}', 'example' => '771234567', 'posLength' => [ 9, diff --git a/src/data/PhoneNumberMetadata_ZA.php b/src/data/PhoneNumberMetadata_ZA.php index 5130cf05..da78014f 100644 --- a/src/data/PhoneNumberMetadata_ZA.php +++ b/src/data/PhoneNumberMetadata_ZA.php @@ -28,7 +28,7 @@ ], ], 'mobile' => [ - 'pattern' => '(?:1(?:3492[0-25]|4495[0235]|549(?:20|5[01]))|4[34]492[01])\\d{3}|8[1-4]\\d{3,7}|(?:2[27]|47|54)4950\\d{3}|(?:1(?:049[2-4]|9[12]\\d\\d)|(?:6\\d|7[0-46-9])\\d{3}|8(?:5\\d{3}|7(?:08[67]|158|28[5-9]|310)))\\d{4}|(?:1[6-8]|28|3[2-69]|4[025689]|5[36-8])4920\\d{3}|(?:12|[2-5]1)492\\d{4}', + 'pattern' => '(?:1(?:3492[0-25]|4495[0235]|549(?:20|5[01]))|4[34]492[01])\\d{3}|8[1-4]\\d{3,7}|(?:2[27]|47|54)4950\\d{3}|(?:1(?:049[2-4]|9[12]\\d\\d)|(?:6\\d\\d|7(?:[0-46-9]\\d|5[0-4]))\\d\\d|8(?:5\\d{3}|7(?:08[67]|158|28[5-9]|310)))\\d{4}|(?:1[6-8]|28|3[2-69]|4[025689]|5[36-8])4920\\d{3}|(?:12|[2-5]1)492\\d{4}', 'example' => '711234567', 'posLength' => [ 5, From 445b0797b7c90a4924c84a22dbd01112134a3ee0 Mon Sep 17 00:00:00 2001 From: Joshua Gigg Date: Tue, 13 Aug 2024 13:12:12 +0100 Subject: [PATCH 2/2] :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 adb1dd4a..09ac3df8 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 286d1b30..e22f8db1 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 61cdf076..549ca935 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 d32423a2..7be5884f 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 d8b78e7b..71016bab 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 9dd531dc..d043ce93 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 f68c4e08..68f78756 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 62623add..905ee991 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 416fffa0..10d2e56d 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 9ee0f969..9aad3747 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) ); } }