diff --git a/METADATA-VERSION.php b/METADATA-VERSION.php index 6fecbb20..42c552f3 100644 --- a/METADATA-VERSION.php +++ b/METADATA-VERSION.php @@ -6,4 +6,4 @@ * For more information, look at the phing tasks in build.xml * @internal */ -return 'v8.13.52'; +return 'v8.13.53'; diff --git a/src/PhoneNumberUtil.php b/src/PhoneNumberUtil.php index d8880db0..2bae41f1 100644 --- a/src/PhoneNumberUtil.php +++ b/src/PhoneNumberUtil.php @@ -2577,6 +2577,9 @@ public function formatOutOfCountryKeepingAlphaChars(PhoneNumber $number, string $regionCode = $this->getRegionCodeForCountryCode($countryCode); // Metadata cannot be null because the country calling code is valid. $metadataForRegion = $this->getMetadataForRegionOrCallingCode($countryCode, $regionCode); + // Strip any extension + $this->maybeStripExtension($formattedNumber); + // Append the formatted extension $this->maybeAppendFormattedExtension( $number, $metadataForRegion, @@ -3450,6 +3453,12 @@ public function isPossibleNumber(PhoneNumber|string $number, ?string $regionDial * length (obviously includes the length of area codes for fixed line numbers), it will * return false for the subscriber-number-only version. * + * There is a known issue with this + * method: if a number is possible only in a certain region among several regions that share the + * same country calling code, this method will consider only the "main" region. For example, + * +1310xxxx are valid numbers in Canada. However, they are not possible in the US. As a result, + * this method will return IS_POSSIBLE_LOCAL_ONLY for +1310xxxx. + * * @param PhoneNumber $number the number that needs to be checked * @return int a ValidationResult object which indicates whether the number is possible */ @@ -3480,6 +3489,12 @@ public function isPossibleNumberWithReason(PhoneNumber $number): int * return false for the subscriber-number-only version. * * + * There is a known issue with this + * method: if a number is possible only in a certain region among several regions that share the + * same country calling code, this method will consider only the "main" region. For example, + * +1310xxxx are valid numbers in Canada. However, they are not possible in the US. As a result, + * this method will return IS_POSSIBLE_LOCAL_ONLY for +1310xxxx. + * * @param PhoneNumber $number the number that needs to be checked * @param int $type the PhoneNumberType we are interested in * @return int a ValidationResult object which indicates whether the number is possible diff --git a/src/data/PhoneNumberMetadata_EH.php b/src/data/PhoneNumberMetadata_EH.php index b234fc29..d425ce83 100644 --- a/src/data/PhoneNumberMetadata_EH.php +++ b/src/data/PhoneNumberMetadata_EH.php @@ -21,7 +21,7 @@ 'example' => '528812345', ], 'mobile' => [ - 'pattern' => '(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[0167]\\d|2[0-4]|5[01]|8[0-3]))\\d{6}', + 'pattern' => '(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[0167]\\d|2[0-467]|5[0-3]|8[0-5]))\\d{6}', 'example' => '650123456', ], 'tollFree' => [ diff --git a/src/data/PhoneNumberMetadata_IL.php b/src/data/PhoneNumberMetadata_IL.php index 8eefc88b..3c1af00d 100644 --- a/src/data/PhoneNumberMetadata_IL.php +++ b/src/data/PhoneNumberMetadata_IL.php @@ -69,7 +69,7 @@ ], ], 'voip' => [ - '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}', + 'pattern' => '7(?:38(?:0\\d|5[0-3569]|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_LV.php b/src/data/PhoneNumberMetadata_LV.php index 52d58203..290d4258 100644 --- a/src/data/PhoneNumberMetadata_LV.php +++ b/src/data/PhoneNumberMetadata_LV.php @@ -21,7 +21,7 @@ 'example' => '63123456', ], 'mobile' => [ - 'pattern' => '23(?:23[0-57-9]|33[0238])\\d{3}|2(?:[0-24-9]\\d\\d|3(?:0[07]|[14-9]\\d|2[024-9]|3[0-24-9]))\\d{4}', + 'pattern' => '2333[0-8]\\d{3}|2(?:[0-24-9]\\d\\d|3(?:0[07]|[14-9]\\d|2[02-9]|3[0-24-9]))\\d{4}', 'example' => '21234567', ], 'tollFree' => [ diff --git a/src/data/PhoneNumberMetadata_MA.php b/src/data/PhoneNumberMetadata_MA.php index 0cfc0fd0..3ff008a1 100644 --- a/src/data/PhoneNumberMetadata_MA.php +++ b/src/data/PhoneNumberMetadata_MA.php @@ -21,7 +21,7 @@ 'example' => '520123456', ], 'mobile' => [ - 'pattern' => '(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[0167]\\d|2[0-4]|5[01]|8[0-3]))\\d{6}', + 'pattern' => '(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[0167]\\d|2[0-467]|5[0-3]|8[0-5]))\\d{6}', 'example' => '650123456', ], 'tollFree' => [ diff --git a/src/data/PhoneNumberMetadata_MK.php b/src/data/PhoneNumberMetadata_MK.php index ace5a986..c2110670 100644 --- a/src/data/PhoneNumberMetadata_MK.php +++ b/src/data/PhoneNumberMetadata_MK.php @@ -29,7 +29,7 @@ ], ], 'mobile' => [ - 'pattern' => '7(?:3555|(?:474|9[019]7)7)\\d{3}|7(?:[0-25-8]\\d\\d|3(?:[1-48]\\d|6[01]|7[01578])|4(?:2\\d|60|7[01578])|9(?:[2-4]\\d|5[01]|7[015]))\\d{4}', + 'pattern' => '7(?:3555|(?:474|9[019]7)7)\\d{3}|7(?:[0-25-8]\\d\\d|3(?:[1-478]\\d|6[01])|4(?:2\\d|60|7[01578])|9(?:[2-4]\\d|5[01]|7[015]))\\d{4}', 'example' => '72345678', ], 'tollFree' => [ diff --git a/src/data/PhoneNumberMetadata_MM.php b/src/data/PhoneNumberMetadata_MM.php index e6217307..7d79775c 100644 --- a/src/data/PhoneNumberMetadata_MM.php +++ b/src/data/PhoneNumberMetadata_MM.php @@ -69,7 +69,7 @@ ], ], 'voip' => [ - 'pattern' => '1333\\d{4}|[12]468\\d{4}', + 'pattern' => '1333\\d{4}', 'example' => '13331234', 'posLength' => [ 8, diff --git a/src/data/PhoneNumberMetadata_MU.php b/src/data/PhoneNumberMetadata_MU.php index 8dc150aa..d62fd787 100644 --- a/src/data/PhoneNumberMetadata_MU.php +++ b/src/data/PhoneNumberMetadata_MU.php @@ -19,7 +19,7 @@ ], ], 'fixedLine' => [ - 'pattern' => '(?:2(?:[0346-8]\\d|1[0-7])|4(?:[013568]\\d|2[4-8]|71)|54(?:[3-5]\\d|71)|6\\d\\d|8(?:14|3[129]))\\d{4}', + 'pattern' => '(?:2(?:[0346-8]\\d|1[0-7])|4(?:[013568]\\d|2[4-8]|71|90)|54(?:[3-5]\\d|71)|6\\d\\d|8(?:14|3[129]))\\d{4}', 'example' => '54480123', 'posLength' => [ 7, diff --git a/src/data/PhoneNumberMetadata_PW.php b/src/data/PhoneNumberMetadata_PW.php index 1a172f8f..b79f316d 100644 --- a/src/data/PhoneNumberMetadata_PW.php +++ b/src/data/PhoneNumberMetadata_PW.php @@ -21,7 +21,7 @@ 'example' => '2771234', ], 'mobile' => [ - 'pattern' => '(?:(?:46|83)[0-5]|6[2-4689]0)\\d{4}|(?:45|77|88)\\d{5}', + 'pattern' => '(?:(?:46|83)[0-5]|(?:6[2-4689]|78)0)\\d{4}|(?:45|77|88)\\d{5}', 'example' => '6201234', ], 'tollFree' => [ diff --git a/src/data/PhoneNumberMetadata_SO.php b/src/data/PhoneNumberMetadata_SO.php index b8c8c8d2..f3bbdd52 100644 --- a/src/data/PhoneNumberMetadata_SO.php +++ b/src/data/PhoneNumberMetadata_SO.php @@ -28,7 +28,7 @@ ], ], 'mobile' => [ - 'pattern' => '(?:(?:15|(?:3[59]|4[89]|6\\d|7[79]|8[08])\\d|9(?:0\\d|[2-9]))\\d|2(?:4\\d|8))\\d{5}|(?:[67]\\d\\d|904)\\d{5}', + 'pattern' => '(?:(?:15|(?:3[59]|4[89]|6\\d|7[679]|8[08])\\d|9(?:0\\d|[2-9]))\\d|2(?:4\\d|8))\\d{5}|(?:[67]\\d\\d|904)\\d{5}', 'example' => '71123456', 'posLength' => [ 7, @@ -134,7 +134,7 @@ 'pattern' => '(\\d{2})(\\d{5,7})', 'format' => '$1 $2', 'leadingDigitsPatterns' => [ - '1|28|6[0-35-9]|77|9[2-9]', + '1|28|6[0-35-9]|7[67]|9[2-9]', ], 'nationalPrefixFormattingRule' => '', 'domesticCarrierCodeFormattingRule' => '', diff --git a/tests/core/PhoneNumberUtilTest.php b/tests/core/PhoneNumberUtilTest.php index d31e5655..1dab19fc 100644 --- a/tests/core/PhoneNumberUtilTest.php +++ b/tests/core/PhoneNumberUtilTest.php @@ -875,6 +875,13 @@ public function testFormatOutOfCountryKeepingAlphaChars(): void $this->phoneUtil->formatOutOfCountryKeepingAlphaChars($alphaNumericNumber, RegionCode::BS) ); + // Testing a number with extension. + $alphaNumericNumberWithExtn = $this->phoneUtil->parseAndKeepRawInput('800 SIX-flag ext. 1234', RegionCode::US); + $this->assertEquals( + '0011 1 800 SIX-FLAG extn. 1234', + $this->phoneUtil->formatOutOfCountryKeepingAlphaChars($alphaNumericNumberWithExtn, RegionCode::AU) + ); + // Testing that if the raw input doesn't exist, it is formatted using // formatOutOfCountryCallingNumber. $alphaNumericNumber->clearRawInput();