diff --git a/METADATA-VERSION.txt b/METADATA-VERSION.txt index 164d2afe3..52f9d93c6 100644 --- a/METADATA-VERSION.txt +++ b/METADATA-VERSION.txt @@ -2,4 +2,4 @@ # It can be a commit, branch or tag of the https://github.com/google/libphonenumber project # # For more information, look at the phing tasks in build.xml -v8.12.28 +v8.12.29 diff --git a/phpunit b/phpunit index a88ca3d31..ab4b03887 100755 --- a/phpunit +++ b/phpunit @@ -6,11 +6,14 @@ if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) { exit(1); } +putenv('SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT=1'); +putenv("SYMFONY_DEPRECATIONS_HELPER=disabled=1"); + if (!getenv('SYMFONY_PHPUNIT_VERSION')) { - if (\PHP_VERSION_ID > 70400) { + if (\PHP_VERSION_ID > 80000) { + putenv('SYMFONY_PHPUNIT_VERSION=9.5'); + } elseif (\PHP_VERSION_ID > 70400) { putenv('SYMFONY_PHPUNIT_VERSION=7.5'); - } elseif (\PHP_VERSION_ID > 80000) { - putenv('SYMFONY_PHPUNIT_VERSION=9.4'); } } diff --git a/src/AsYouTypeFormatter.php b/src/AsYouTypeFormatter.php index 8fd441378..0280bbc66 100644 --- a/src/AsYouTypeFormatter.php +++ b/src/AsYouTypeFormatter.php @@ -149,7 +149,8 @@ class AsYouTypeFormatter * to be used by the AYTF. It is eligible when the format element under numberFormat contains * groups of the dollar sign followed by a single digit, separated by valid phone number punctuation. * This prevents invalid punctuation (such as the star sign in Israeli star numbers) getting - * into the output of the AYTF. + * into the output of the AYTF. We require that the first group is present in the output pattern to ensure + * no data is lost while formatting; when we format as you type, this should always be the case. * @var string */ private static $eligibleFormatPattern; @@ -186,7 +187,8 @@ private static function init() self::$emptyMetadata->setInternationalPrefix('NA'); self::$eligibleFormatPattern = '[' . PhoneNumberUtil::VALID_PUNCTUATION . ']*' - . "(\\$\\d" . '[' . PhoneNumberUtil::VALID_PUNCTUATION . ']*)+'; + . "\\$1" . "[" . PhoneNumberUtil::VALID_PUNCTUATION . "]*(\\$\\d" + . "[" . PhoneNumberUtil::VALID_PUNCTUATION . "]*)*"; } } diff --git a/src/PhoneNumberMatcher.php b/src/PhoneNumberMatcher.php index d6b7c4c6b..2308e254f 100644 --- a/src/PhoneNumberMatcher.php +++ b/src/PhoneNumberMatcher.php @@ -877,6 +877,7 @@ protected static function loadAlternateFormatsMetadataFromFile($countryCallingCo * @link http://php.net/manual/en/iterator.current.php * @return PhoneNumberMatch|null */ + #[\ReturnTypeWillChange] public function current() { return $this->lastMatch; diff --git a/src/carrier/data/en/221.php b/src/carrier/data/en/221.php index e23dc4578..0e5d80fc6 100644 --- a/src/carrier/data/en/221.php +++ b/src/carrier/data/en/221.php @@ -13,9 +13,7 @@ return array ( 22170 => 'Expresso', 22172 => 'HAYO', - 221754 => 'Promobile', - 221755 => 'Promobile', - 221756 => 'Promobile', + 22175 => 'Promobile', 221757 => 'Origines', 22176 => 'Tigo', 22177 => 'Orange', diff --git a/src/carrier/data/en/32.php b/src/carrier/data/en/32.php index 68b5ada64..06d642706 100644 --- a/src/carrier/data/en/32.php +++ b/src/carrier/data/en/32.php @@ -49,6 +49,7 @@ 324687 => 'Premium Routing GmbH', 324688 => 'Premium Routing GmbH', 324689 => 'Febo Telecom', + 32469 => 'Telenet', 3247 => 'Proximus', 324805 => 'Voyacom SPRL', 324807 => 'MessageBird BV', diff --git a/src/carrier/data/en/995.php b/src/carrier/data/en/995.php index 668beaeb9..f8f4cca60 100644 --- a/src/carrier/data/en/995.php +++ b/src/carrier/data/en/995.php @@ -45,6 +45,7 @@ 9955757 => 'MagtiCom', 995577 => 'Geocell', 995579 => 'Veon', + 995580 => 'Silknet', 995585 => 'MagtiCom', 9955885 => 'Silknet', 9955888 => 'Geocell', diff --git a/src/data/PhoneNumberMetadata_BE.php b/src/data/PhoneNumberMetadata_BE.php index 08952ad5a..54de31e0a 100644 --- a/src/data/PhoneNumberMetadata_BE.php +++ b/src/data/PhoneNumberMetadata_BE.php @@ -62,7 +62,7 @@ ), 'premiumRate' => array ( - 'NationalNumberPattern' => '(?:70(?:2[0-57]|3[0457]|44|69|7[0579])|90(?:0[0-35-8]|1[36]|2[0-3568]|3[0135689]|4[2-68]|5[1-68]|6[0-378]|7[23568]|9[34679]))\\d{4}', + 'NationalNumberPattern' => '(?:70(?:2[0-57]|3[04-7]|44|69|7[0579])|90(?:0[0-8]|1[36]|2[0-3568]|3[013-689]|[47][2-68]|5[1-68]|6[0-378]|9[34679]))\\d{4}', 'ExampleNumber' => '90012345', 'PossibleLength' => array ( @@ -116,7 +116,7 @@ ), 'uan' => array ( - 'NationalNumberPattern' => '78(?:0[57]|1[0458]|2[25]|3[15-8]|48|[56]0|7[078])\\d{4}', + 'NationalNumberPattern' => '78(?:0[57]|1[0458]|2[25]|3[15-8]|48|[56]0|7[078]|9\\d)\\d{4}', 'ExampleNumber' => '78102345', 'PossibleLength' => array ( diff --git a/src/data/PhoneNumberMetadata_GE.php b/src/data/PhoneNumberMetadata_GE.php index ea9974c39..dddb9ccf4 100644 --- a/src/data/PhoneNumberMetadata_GE.php +++ b/src/data/PhoneNumberMetadata_GE.php @@ -40,7 +40,7 @@ ), 'mobile' => array ( - 'NationalNumberPattern' => '5(?:0555[5-9]|757(?:7[7-9]|8[01]))\\d{3}|5(?:0070|[25]222|3333)[0-4]\\d{3}|5(?:00(?:0\\d|50)|111\\d|(?:52|75)00|8(?:58[89]|8(?:55|88)))\\d{4}|(?:5(?:[14]4|5[0157-9]|68|7[0147-9]|9[1-35-9])|790)\\d{6}', + 'NationalNumberPattern' => '5(?:0555[5-9]|757(?:7[7-9]|8[01]))\\d{3}|5(?:0070|[25]222|3333)[0-4]\\d{3}|5(?:00(?:0\\d|50)|111\\d|(?:52|75)00|8(?:0(?:[01]\\d|2[0-4])|58[89]|8(?:55|88)))\\d{4}|(?:5(?:[14]4|5[0157-9]|68|7[0147-9]|9[1-35-9])|790)\\d{6}', 'ExampleNumber' => '555123456', 'PossibleLength' => array ( diff --git a/src/data/PhoneNumberMetadata_IR.php b/src/data/PhoneNumberMetadata_IR.php index ec2670ea1..7be032e2a 100644 --- a/src/data/PhoneNumberMetadata_IR.php +++ b/src/data/PhoneNumberMetadata_IR.php @@ -47,7 +47,7 @@ ), 'mobile' => array ( - 'NationalNumberPattern' => '9(?:(?:0(?:[0-35]\\d|4[4-6])|(?:[13]\\d|2[0-3])\\d)\\d|9(?:(?:[0-2]\\d|3[01]|4[0145])\\d|5[15]0|8(?:1\\d|88)|9(?:0[013]|[19]\\d|21|77|8[7-9])))\\d{5}', + 'NationalNumberPattern' => '9(?:(?:0(?:[0-35]\\d|4[4-6])|(?:[13]\\d|2[0-3])\\d)\\d|9(?:(?:[0-3]\\d|4[0145])\\d|5[15]0|8(?:1\\d|88)|9(?:0[013]|[19]\\d|21|77|8[7-9])))\\d{5}', 'ExampleNumber' => '9123456789', 'PossibleLength' => array ( @@ -99,11 +99,9 @@ ), 'voip' => array ( - 'NationalNumberPattern' => '993[2-9]\\d{6}', - 'ExampleNumber' => '9932123456', 'PossibleLength' => array ( - 0 => 10, + 0 => -1, ), 'PossibleLengthLocalOnly' => array ( diff --git a/src/data/PhoneNumberMetadata_MO.php b/src/data/PhoneNumberMetadata_MO.php index 0b540264a..625ba7644 100644 --- a/src/data/PhoneNumberMetadata_MO.php +++ b/src/data/PhoneNumberMetadata_MO.php @@ -14,7 +14,7 @@ return array ( 'generalDesc' => array ( - 'NationalNumberPattern' => '08005\\d\\d|(?:28|[68]\\d)\\d{6}', + 'NationalNumberPattern' => '0800\\d{3}|(?:28|[68]\\d)\\d{6}', 'PossibleLength' => array ( 0 => 7, @@ -50,7 +50,7 @@ ), 'tollFree' => array ( - 'NationalNumberPattern' => '08005\\d\\d', + 'NationalNumberPattern' => '0800\\d{3}', 'ExampleNumber' => '0800501', 'PossibleLength' => array ( diff --git a/src/data/PhoneNumberMetadata_MX.php b/src/data/PhoneNumberMetadata_MX.php index 13227c8d0..017243c61 100644 --- a/src/data/PhoneNumberMetadata_MX.php +++ b/src/data/PhoneNumberMetadata_MX.php @@ -14,7 +14,7 @@ return array ( 'generalDesc' => array ( - 'NationalNumberPattern' => '199[1-9]\\d{7}|(?:1(?:[01467]\\d|[235][1-9]|8[1-79]|9[1-8])|[2-9]\\d)\\d{8}', + 'NationalNumberPattern' => '1(?:65[0-689]|99[1-9])\\d{7}|(?:1(?:[0147]\\d|[235][1-9]|6[0-46-9]|8[1-79]|9[1-8])|[2-9]\\d)\\d{8}', 'PossibleLength' => array ( 0 => 10, @@ -28,7 +28,7 @@ ), 'fixedLine' => array ( - 'NationalNumberPattern' => '(?:2(?:0[01]|2[1-9]|3[1-35-8]|4[13-9]|7[1-689]|8[1-578]|9[467])|3(?:1[1-79]|[2458][1-9]|3\\d|7[1-8]|9[1-5])|4(?:1[1-57-9]|[24-7][1-9]|3[1-8]|8[1-35-9]|9[2-689])|5(?:[56]\\d|88|9[1-79])|6(?:1[2-68]|[2-4][1-9]|5[1-3689]|6[1-57-9]|7[1-7]|8[67]|9[4-8])|7(?:[1-467][1-9]|5[13-9]|8[1-69]|9[17])|8(?:1\\d|2[13-689]|3[1-6]|4[124-6]|6[1246-9]|7[1-378]|9[12479])|9(?:1[346-9]|2[1-4]|3[2-46-8]|5[1348]|6[1-9]|7[12]|8[1-8]|9\\d))\\d{7}', + 'NationalNumberPattern' => '6571\\d{6}|(?:2(?:0[01]|2[1-9]|3[1-35-8]|4[13-9]|7[1-689]|8[1-578]|9[467])|3(?:1[1-79]|[2458][1-9]|3\\d|7[1-8]|9[1-5])|4(?:1[1-57-9]|[24-7][1-9]|3[1-8]|8[1-35-9]|9[2-689])|5(?:[56]\\d|88|9[1-79])|6(?:1[2-68]|[2-4][1-9]|5[1-3689]|6[1-57-9]|7[1-7]|8[67]|9[4-8])|7(?:[1-467][1-9]|5[13-9]|8[1-69]|9[17])|8(?:1\\d|2[13-689]|3[1-6]|4[124-6]|6[1246-9]|7[1-378]|9[12479])|9(?:1[346-9]|2[1-4]|3[2-46-8]|5[1348]|6[1-9]|7[12]|8[1-8]|9\\d))\\d{7}', 'ExampleNumber' => '2001234567', 'PossibleLength' => array ( @@ -42,7 +42,7 @@ ), 'mobile' => array ( - 'NationalNumberPattern' => '(?:1(?:2(?:2[1-9]|3[1-35-8]|4[13-9]|7[1-689]|8[1-578]|9[467])|3(?:1[1-79]|[2458][1-9]|3\\d|7[1-8]|9[1-5])|4(?:1[1-57-9]|[24-7][1-9]|3[1-8]|8[1-35-9]|9[2-689])|5(?:[56]\\d|88|9[1-79])|6(?:1[2-68]|[2-4][1-9]|5[1-3689]|6[1-57-9]|7[1-7]|8[67]|9[4-8])|7(?:[1-467][1-9]|5[13-9]|8[1-69]|9[17])|8(?:1\\d|2[13-689]|3[1-6]|4[124-6]|6[1246-9]|7[1-378]|9[12479])|9(?:1[346-9]|2[1-4]|3[2-46-8]|5[1348]|[69][1-9]|7[12]|8[1-8]))|2(?:2[1-9]|3[1-35-8]|4[13-9]|7[1-689]|8[1-578]|9[467])|3(?:1[1-79]|[2458][1-9]|3\\d|7[1-8]|9[1-5])|4(?:1[1-57-9]|[24-7][1-9]|3[1-8]|8[1-35-9]|9[2-689])|5(?:[56]\\d|88|9[1-79])|6(?:1[2-68]|[2-4][1-9]|5[1-3689]|6[1-57-9]|7[1-7]|8[67]|9[4-8])|7(?:[1-467][1-9]|5[13-9]|8[1-69]|9[17])|8(?:1\\d|2[13-689]|3[1-6]|4[124-6]|6[1246-9]|7[1-378]|9[12479])|9(?:1[346-9]|2[1-4]|3[2-46-8]|5[1348]|6[1-9]|7[12]|8[1-8]|9\\d))\\d{7}', + 'NationalNumberPattern' => '6571\\d{6}|(?:1(?:2(?:2[1-9]|3[1-35-8]|4[13-9]|7[1-689]|8[1-578]|9[467])|3(?:1[1-79]|[2458][1-9]|3\\d|7[1-8]|9[1-5])|4(?:1[1-57-9]|[24-7][1-9]|3[1-8]|8[1-35-9]|9[2-689])|5(?:[56]\\d|88|9[1-79])|6(?:1[2-68]|[2-4][1-9]|5[1-3689]|6[1-57-9]|7[1-7]|8[67]|9[4-8])|7(?:[1-467][1-9]|5[13-9]|8[1-69]|9[17])|8(?:1\\d|2[13-689]|3[1-6]|4[124-6]|6[1246-9]|7[1-378]|9[12479])|9(?:1[346-9]|2[1-4]|3[2-46-8]|5[1348]|[69][1-9]|7[12]|8[1-8]))|2(?:2[1-9]|3[1-35-8]|4[13-9]|7[1-689]|8[1-578]|9[467])|3(?:1[1-79]|[2458][1-9]|3\\d|7[1-8]|9[1-5])|4(?:1[1-57-9]|[24-7][1-9]|3[1-8]|8[1-35-9]|9[2-689])|5(?:[56]\\d|88|9[1-79])|6(?:1[2-68]|[2-4][1-9]|5[1-3689]|6[1-57-9]|7[1-7]|8[67]|9[4-8])|7(?:[1-467][1-9]|5[13-9]|8[1-69]|9[17])|8(?:1\\d|2[13-689]|3[1-6]|4[124-6]|6[1246-9]|7[1-378]|9[12479])|9(?:1[346-9]|2[1-4]|3[2-46-8]|5[1348]|6[1-9]|7[12]|8[1-8]|9\\d))\\d{7}', 'ExampleNumber' => '12221234567', 'PossibleLength' => array ( diff --git a/src/data/PhoneNumberMetadata_QA.php b/src/data/PhoneNumberMetadata_QA.php index bec32feac..5a7289d34 100644 --- a/src/data/PhoneNumberMetadata_QA.php +++ b/src/data/PhoneNumberMetadata_QA.php @@ -14,11 +14,12 @@ return array ( 'generalDesc' => array ( - 'NationalNumberPattern' => '[2-7]\\d{7}|(?:2\\d\\d|800)\\d{4}', + 'NationalNumberPattern' => '[2-7]\\d{7}|800\\d{4}(?:\\d{2})?|2\\d{6}', 'PossibleLength' => array ( 0 => 7, 1 => 8, + 2 => 9, ), 'PossibleLengthLocalOnly' => array ( @@ -50,11 +51,12 @@ ), 'tollFree' => array ( - 'NationalNumberPattern' => '800\\d{4}', + 'NationalNumberPattern' => '800\\d{4}(?:\\d{2})?', 'ExampleNumber' => '8001234', 'PossibleLength' => array ( 0 => 7, + 1 => 9, ), 'PossibleLengthLocalOnly' => array ( diff --git a/src/data/PhoneNumberMetadata_SN.php b/src/data/PhoneNumberMetadata_SN.php index 102f27969..0e2a9b3f9 100644 --- a/src/data/PhoneNumberMetadata_SN.php +++ b/src/data/PhoneNumberMetadata_SN.php @@ -14,7 +14,7 @@ return array ( 'generalDesc' => array ( - 'NationalNumberPattern' => '(?:[378]\\d{4}|93330)\\d{4}', + 'NationalNumberPattern' => '(?:[378]\\d|93)\\d{7}', 'PossibleLength' => array ( 0 => 9, @@ -36,7 +36,7 @@ ), 'mobile' => array ( - 'NationalNumberPattern' => '7(?:[06-8]\\d|21|5[4-7]|90)\\d{6}', + 'NationalNumberPattern' => '75(?:01|[38]3)\\d{5}|7(?:[06-8]\\d|21|5[4-7]|90)\\d{6}', 'ExampleNumber' => '701234567', 'PossibleLength' => array ( @@ -90,7 +90,7 @@ ), 'voip' => array ( - 'NationalNumberPattern' => '93330\\d{4}|3(?:392|9[01]\\d)\\d{5}', + 'NationalNumberPattern' => '(?:3(?:392|9[01]\\d)\\d|93(?:3[13]0|929))\\d{4}', 'ExampleNumber' => '933301234', 'PossibleLength' => array ( diff --git a/src/geocoding/data/en/52.php b/src/geocoding/data/en/52.php index 9a542e767..35dc05362 100644 --- a/src/geocoding/data/en/52.php +++ b/src/geocoding/data/en/52.php @@ -219,6 +219,7 @@ 52652 => 'Chihuahua', 52653 => 'Luis B. Sanchez/San Luis Rio Colorado, SON', 52656 => 'Chihuahua', + 52657 => 'Chihuahua', 52658 => 'Baja California', 52659 => 'Chihuahua', 52661 => 'Primo Tapia/Rosarito, BCN', diff --git a/src/timezone/data/map_data.php b/src/timezone/data/map_data.php index c8f7a95ad..34efff711 100644 --- a/src/timezone/data/map_data.php +++ b/src/timezone/data/map_data.php @@ -2305,6 +2305,7 @@ 52652 => 'America/Mazatlan', 52653 => 'America/Mazatlan', 52656 => 'America/Hermosillo', + 52657 => 'America/Mazatlan', 52658 => 'America/Tijuana', 52659 => 'America/Mazatlan', 52661 => 'America/Tijuana', diff --git a/tests/core/AsYouTypeFormatterTest.php b/tests/core/AsYouTypeFormatterTest.php index a13b99b6a..9405fb172 100644 --- a/tests/core/AsYouTypeFormatterTest.php +++ b/tests/core/AsYouTypeFormatterTest.php @@ -655,6 +655,20 @@ public function testAYTF_MX() $this->assertEquals('+52 800 123 456', $formatter->inputDigit('6')); $this->assertEquals('+52 800 123 4567', $formatter->inputDigit('7')); + // +529011234567, proactively ensuring that no formatting is applied, where a format is chosen + // that would otherwise have led to some digits being dropped. + $formatter->clear(); + $this->assertEquals("9", $formatter->inputDigit('9')); + $this->assertEquals("90", $formatter->inputDigit('0')); + $this->assertEquals("901", $formatter->inputDigit('1')); + $this->assertEquals("9011", $formatter->inputDigit('1')); + $this->assertEquals("90112", $formatter->inputDigit('2')); + $this->assertEquals("901123", $formatter->inputDigit('3')); + $this->assertEquals("9011234", $formatter->inputDigit('4')); + $this->assertEquals("90112345", $formatter->inputDigit('5')); + $this->assertEquals("901123456", $formatter->inputDigit('6')); + $this->assertEquals("9011234567", $formatter->inputDigit('7')); + // +52 55 1234 5678 $formatter->clear(); $this->assertEquals('+', $formatter->inputDigit('+')); diff --git a/tests/core/data/PhoneNumberMetadataForTesting_MX.php b/tests/core/data/PhoneNumberMetadataForTesting_MX.php index 735cb77a0..9ce505bc9 100644 --- a/tests/core/data/PhoneNumberMetadataForTesting_MX.php +++ b/tests/core/data/PhoneNumberMetadataForTesting_MX.php @@ -166,6 +166,18 @@ 'nationalPrefixOptionalWhenFormatting' => true, ), 1 => + array ( + 'pattern' => '(\\d{3})(\\d{2})(\\d{5})', + 'format' => '$2 $3', + 'leadingDigitsPatterns' => + array ( + 0 => '901', + ), + 'nationalPrefixFormattingRule' => '01 $1', + 'domesticCarrierCodeFormattingRule' => '', + 'nationalPrefixOptionalWhenFormatting' => true, + ), + 2 => array ( 'pattern' => '(\\d{2})(\\d{4})(\\d{4})', 'format' => '$1 $2 $3', @@ -177,7 +189,7 @@ 'domesticCarrierCodeFormattingRule' => '', 'nationalPrefixOptionalWhenFormatting' => true, ), - 2 => + 3 => array ( 'pattern' => '(\\d{3})(\\d{3})(\\d{4})', 'format' => '$1 $2 $3', @@ -189,7 +201,7 @@ 'domesticCarrierCodeFormattingRule' => '', 'nationalPrefixOptionalWhenFormatting' => true, ), - 3 => + 4 => array ( 'pattern' => '(\\d)(\\d{2})(\\d{4})(\\d{4})', 'format' => '045 $2 $3 $4', @@ -201,7 +213,7 @@ 'domesticCarrierCodeFormattingRule' => '', 'nationalPrefixOptionalWhenFormatting' => true, ), - 4 => + 5 => array ( 'pattern' => '(\\d)(\\d{3})(\\d{3})(\\d{4})', 'format' => '045 $2 $3 $4', @@ -229,6 +241,15 @@ 'nationalPrefixOptionalWhenFormatting' => true, ), 1 => + array ( + 'pattern' => '(\\d{3})(\\d{2})(\\d{5})', + 'format' => '$2 $3', + 'leadingDigitsPatterns' => + array ( + 0 => '901', + ), + ), + 2 => array ( 'pattern' => '(\\d{2})(\\d{4})(\\d{4})', 'format' => '$1 $2 $3', @@ -240,7 +261,7 @@ 'domesticCarrierCodeFormattingRule' => '', 'nationalPrefixOptionalWhenFormatting' => true, ), - 2 => + 3 => array ( 'pattern' => '(\\d{3})(\\d{3})(\\d{4})', 'format' => '$1 $2 $3', @@ -252,7 +273,7 @@ 'domesticCarrierCodeFormattingRule' => '', 'nationalPrefixOptionalWhenFormatting' => true, ), - 3 => + 4 => array ( 'pattern' => '(\\d)(\\d{2})(\\d{4})(\\d{4})', 'format' => '$1 $2 $3 $4', @@ -261,7 +282,7 @@ 0 => '1(?:33|55|81)', ), ), - 4 => + 5 => array ( 'pattern' => '(\\d)(\\d{3})(\\d{3})(\\d{4})', 'format' => '$1 $2 $3 $4',