Skip to content

Commit

Permalink
Merge pull request #82 from giggsey/upstream-8.13.53
Browse files Browse the repository at this point in the history
Upstream changes from Google for v8.13.53
  • Loading branch information
giggsey authored Jan 15, 2025
2 parents 9d48e4e + 2c2486e commit ead50d9
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion METADATA-VERSION.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
* For more information, look at the phing tasks in build.xml
* @internal
*/
return 'v8.13.52';
return 'v8.13.53';
15 changes: 15 additions & 0 deletions src/PhoneNumberUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
* </ol>
* There is a known <a href="https://issuetracker.google.com/issues/335892662">issue</a> 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
*/
Expand Down Expand Up @@ -3480,6 +3489,12 @@ public function isPossibleNumberWithReason(PhoneNumber $number): int
* return false for the subscriber-number-only version.
* </ol>
*
* There is a known <a href="https://issuetracker.google.com/issues/335892662">issue</a> 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
Expand Down
2 changes: 1 addition & 1 deletion src/data/PhoneNumberMetadata_EH.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down
2 changes: 1 addition & 1 deletion src/data/PhoneNumberMetadata_IL.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/data/PhoneNumberMetadata_LV.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down
2 changes: 1 addition & 1 deletion src/data/PhoneNumberMetadata_MA.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down
2 changes: 1 addition & 1 deletion src/data/PhoneNumberMetadata_MK.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down
2 changes: 1 addition & 1 deletion src/data/PhoneNumberMetadata_MM.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
],
],
'voip' => [
'pattern' => '1333\\d{4}|[12]468\\d{4}',
'pattern' => '1333\\d{4}',
'example' => '13331234',
'posLength' => [
8,
Expand Down
2 changes: 1 addition & 1 deletion src/data/PhoneNumberMetadata_MU.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/data/PhoneNumberMetadata_PW.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down
4 changes: 2 additions & 2 deletions src/data/PhoneNumberMetadata_SO.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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' => '',
Expand Down
7 changes: 7 additions & 0 deletions tests/core/PhoneNumberUtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit ead50d9

Please sign in to comment.