Skip to content

Commit

Permalink
Merge pull request #519 from giggsey/upstream-8.12.51
Browse files Browse the repository at this point in the history
Upstream metadata changes from Google for v8.12.51
  • Loading branch information
giggsey authored Jul 11, 2022
2 parents 91cdd8c + fc5ee0f commit a42d89a
Show file tree
Hide file tree
Showing 37 changed files with 290 additions and 279 deletions.
2 changes: 1 addition & 1 deletion METADATA-VERSION.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.50
v8.12.51
4 changes: 4 additions & 0 deletions src/CountryCodeToRegionCodeMapForTesting.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class CountryCodeToRegionCodeMapForTesting {
array (
0 => 'BR',
),
57 =>
array (
0 => 'CO',
),
61 =>
array (
0 => 'AU',
Expand Down
22 changes: 7 additions & 15 deletions src/PhoneNumberUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ class PhoneNumberUtil
const UNKNOWN_REGION = 'ZZ';

const NANPA_COUNTRY_CODE = 1;
/*
* The prefix that needs to be inserted in front of a Colombian landline number when dialed from
* a mobile number in Colombia.
*/
const COLOMBIA_MOBILE_TO_FIXED_LINE_PREFIX = '3';
// The PLUS_SIGN signifies the international prefix.
const PLUS_SIGN = '+';
const PLUS_CHARS = '++';
Expand Down Expand Up @@ -2441,12 +2436,7 @@ public function formatNumberForMobileDialing(PhoneNumber $number, $regionCalling
if ($regionCallingFrom == $regionCode) {
$isFixedLineOrMobile = ($numberType == PhoneNumberType::FIXED_LINE) || ($numberType == PhoneNumberType::MOBILE) || ($numberType == PhoneNumberType::FIXED_LINE_OR_MOBILE);
// Carrier codes may be needed in some countries. We handle this here.
if ($regionCode == 'CO' && $numberType == PhoneNumberType::FIXED_LINE) {
$formattedNumber = $this->formatNationalNumberWithCarrierCode(
$numberNoExt,
static::COLOMBIA_MOBILE_TO_FIXED_LINE_PREFIX
);
} elseif ($regionCode == 'BR' && $isFixedLineOrMobile) {
if ($regionCode === 'BR' && $isFixedLineOrMobile) {
// Historically, we set this to an empty string when parsing with raw input if none was
// found in the input string. However, this doesn't result in a number we can dial. For this
// reason, we treat the empty string the same as if it isn't set at all.
Expand Down Expand Up @@ -2827,11 +2817,13 @@ public function isNANPACountry($regionCode)
}

/**
* Formats a phone number using the original phone number format that the number is parsed from.
* Formats a phone number using the original phone number format (e.g. INTERNATIONAL or NATIONAL)
* that the number is parsed from, provided that the number has been parsed with
* parseAndKeepRawInput. Otherwise the number will be formatted in NATIONAL format.
*
* The original format is embedded in the country_code_source field of the PhoneNumber object
* passed in. If such information is missing, the number will be formatted into the NATIONAL
* format by default. When we don't have a formatting pattern for the number, the method returns
* the raw input when it is available.
* passed in, which is only set when parsing keeps the raw input. When we don't have a formatting
* pattern for the number, the method falls back to returning the raw input.
*
* Note this method guarantees no digit will be inserted, removed or modified as a result of
* formatting.
Expand Down
2 changes: 2 additions & 0 deletions src/RegionCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

/**
* Class containing string constants of region codes for easier testing.
* @internal
*/
class RegionCode
{
Expand All @@ -39,6 +40,7 @@ class RegionCode
const CH = 'CH';
const CL = 'CL';
const CN = 'CN';
const CO = 'CO';
const CS = 'CS';
const CX = 'CX';
const DE = 'DE';
Expand Down
1 change: 1 addition & 0 deletions src/carrier/data/en/254.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
254120 => 'Telkom',
254121 => 'Infura',
254124 => 'Finserve',
25413 => 'NRG Media Limited',
25470 => 'Safaricom',
25471 => 'Safaricom',
25472 => 'Safaricom',
Expand Down
2 changes: 1 addition & 1 deletion src/carrier/data/en/262.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,5 @@
26269394 => 'SFR',
26269397 => 'SFR',
26269399 => 'Orange',
2629 => 'Orange',
2629769 => 'Orange',
);
1 change: 1 addition & 0 deletions src/carrier/data/en/298.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@
29878 => 'Faroese Telecom',
29879 => 'Faroese Telecom',
29891 => 'Tosa',
29896 => 'Faroese Telecom',
);
2 changes: 1 addition & 1 deletion src/carrier/data/en/386.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
38664 => 'T-2',
386651 => 'SŽ - Infrastruktura',
386655 => 'Telekom Slovenije',
386656 => 'Telekom Slovenije',
386656 => 'SoftNet',
386657 => 'Novatel',
38668 => 'A1',
38669 => 'A1',
Expand Down
1 change: 1 addition & 0 deletions src/carrier/data/en/421.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@
421949 => 'Telefonica O2',
421950 => '4ka of SWAN',
421951 => '4ka of SWAN',
421952 => '4ka of SWAN',
4219598 => 'Slovak Republic Railways (GSM-R)',
);
16 changes: 10 additions & 6 deletions src/carrier/data/en/60.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

return array (
60102 => 'DiGi',
601030 => 'Celcom',
601031 => 'Celcom',
601032 => 'Celcom',
601033 => 'Celcom',
601034 => 'Celcom',
601030 => 'XOX',
601031 => 'XOX',
601032 => 'XOX',
601033 => 'XOX',
601034 => 'XOX',
601035 => 'Webe',
601036 => 'DiGi',
601037 => 'DiGi',
Expand Down Expand Up @@ -273,7 +273,9 @@
601173 => 'YTL',
601174 => 'YTL',
601175 => 'YTL',
60118 => 'U Mobile',
60118886 => 'U Mobile',
60118888 => 'red ONE',
60118889 => 'U Mobile',
6012 => 'Maxis',
60131 => 'Celcom',
60132 => 'Celcom',
Expand All @@ -292,6 +294,7 @@
60147 => 'Maxis',
60148 => 'Celcom',
60149 => 'DiGi',
60153 => 'Tune Talk',
601591 => 'DiGi',
601592 => 'Celcom',
601596 => 'DiGi',
Expand All @@ -313,6 +316,7 @@
601833 => 'YTL',
601834 => 'YTL',
60184 => 'U Mobile',
601854 => 'XOX',
601857 => 'U Mobile',
601858 => 'YTL',
601859 => 'YTL',
Expand Down
1 change: 1 addition & 0 deletions src/carrier/data/en/976.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
97650 => 'Unitel',
97655 => 'Unitel',
97680 => 'Unitel',
97681 => 'ONDO',
97683 => 'G-Mobile',
97685 => 'Mobicom',
97686 => 'Unitel',
Expand Down
5 changes: 4 additions & 1 deletion src/carrier/data/en/995.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

return array (
9955000 => 'Mobilaive',
9955005 => 'MagtiCom',
99550050 => 'MagtiCom',
99550055 => 'Silknet',
9955007 => 'MyPhone',
995505 => 'MagtiCom',
9955110 => 'MagtiCom',
Expand All @@ -22,6 +23,8 @@
9955115 => 'Silknet',
9955117 => 'MagtiCom',
995514 => 'Geocell',
995515 => 'MagtiCom',
995517 => 'MagtiCom',
99552 => 'MagtiCom',
99553 => 'MagtiCom',
99554444 => 'MagtiCom',
Expand Down
2 changes: 1 addition & 1 deletion src/carrier/data/en/996.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
996996 => 'Sky mobile',
996997 => 'ALFA Telecom',
996998 => 'ALFA Telecom',
996999 => 'Sky mobile',
996999 => 'ALFA Telecom',
);
4 changes: 2 additions & 2 deletions src/data/PhoneNumberMetadata_800.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
return array (
'generalDesc' =>
array (
'NationalNumberPattern' => '(?:005|[1-9]\\d\\d)\\d{5}',
'NationalNumberPattern' => '(?:00|[1-9]\\d)\\d{6}',
'PossibleLength' =>
array (
0 => 8,
Expand Down Expand Up @@ -45,7 +45,7 @@
),
'tollFree' =>
array (
'NationalNumberPattern' => '(?:005|[1-9]\\d\\d)\\d{5}',
'NationalNumberPattern' => '(?:00|[1-9]\\d)\\d{6}',
'ExampleNumber' => '12345678',
'PossibleLength' =>
array (
Expand Down
2 changes: 1 addition & 1 deletion src/data/PhoneNumberMetadata_BJ.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
),
'mobile' =>
array (
'NationalNumberPattern' => '(?:40|5[1-8]|6\\d|9[013-9])\\d{6}',
'NationalNumberPattern' => '(?:40|5[1-9]|6\\d|9[013-9])\\d{6}',
'ExampleNumber' => '90011234',
'PossibleLength' =>
array (
Expand Down
6 changes: 4 additions & 2 deletions src/data/PhoneNumberMetadata_BR.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
return array (
'generalDesc' =>
array (
'NationalNumberPattern' => '(?:[1-46-9]\\d\\d|5(?:[0-46-9]\\d|5[0-24679]))\\d{8}|[1-9]\\d{9}|[3589]\\d{8}|[34]\\d{7}',
'NationalNumberPattern' => '(?:[1-46-9]\\d\\d|5(?:[0-46-9]\\d|5[0-46-9]))\\d{8}|[1-9]\\d{9}|[3589]\\d{8}|[34]\\d{7}',
'PossibleLength' =>
array (
0 => 8,
Expand Down Expand Up @@ -145,10 +145,12 @@
),
'noInternationalDialling' =>
array (
'NationalNumberPattern' => '4020\\d{4}|[34]00\\d{5}',
'NationalNumberPattern' => '30(?:0\\d{5,7}|3\\d{7})|40(?:0\\d|20)\\d{4}|800\\d{6,7}',
'PossibleLength' =>
array (
0 => 8,
1 => 9,
2 => 10,
),
'PossibleLengthLocalOnly' =>
array (
Expand Down
52 changes: 13 additions & 39 deletions src/data/PhoneNumberMetadata_CO.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
return array (
'generalDesc' =>
array (
'NationalNumberPattern' => '(?:(?:1\\d|[36])\\d{3}|9101)\\d{6}|[124-8]\\d{7}',
'NationalNumberPattern' => '(?:60\\d\\d|9101)\\d{6}|(?:1\\d|3)\\d{9}',
'PossibleLength' =>
array (
0 => 8,
1 => 10,
2 => 11,
0 => 10,
1 => 11,
),
'PossibleLengthLocalOnly' =>
array (
Expand All @@ -28,12 +27,11 @@
),
'fixedLine' =>
array (
'NationalNumberPattern' => '60[124-8][2-9]\\d{6}|[124-8][2-9]\\d{6}',
'ExampleNumber' => '12345678',
'NationalNumberPattern' => '60[124-8][2-9]\\d{6}',
'ExampleNumber' => '6012345678',
'PossibleLength' =>
array (
0 => 8,
1 => 10,
0 => 10,
),
'PossibleLengthLocalOnly' =>
array (
Expand Down Expand Up @@ -150,23 +148,11 @@
'countryCode' => 57,
'internationalPrefix' => '00(?:4(?:[14]4|56)|[579])',
'nationalPrefix' => '0',
'nationalPrefixForParsing' => '0([3579]|4(?:[14]4|56))?',
'nationalPrefixForParsing' => '0(4(?:[14]4|56)|[579])?',
'sameMobileAndFixedLinePattern' => false,
'numberFormat' =>
array (
0 =>
array (
'pattern' => '(\\d)(\\d{7})',
'format' => '$1 $2',
'leadingDigitsPatterns' =>
array (
0 => '[146][2-9]|[2578]',
),
'nationalPrefixFormattingRule' => '($1)',
'domesticCarrierCodeFormattingRule' => '0$CC $1',
'nationalPrefixOptionalWhenFormatting' => false,
),
1 =>
array (
'pattern' => '(\\d{3})(\\d{7})',
'format' => '$1 $2',
Expand All @@ -175,10 +161,10 @@
0 => '6',
),
'nationalPrefixFormattingRule' => '($1)',
'domesticCarrierCodeFormattingRule' => '',
'domesticCarrierCodeFormattingRule' => '0$CC $1',
'nationalPrefixOptionalWhenFormatting' => false,
),
2 =>
1 =>
array (
'pattern' => '(\\d{3})(\\d{7})',
'format' => '$1 $2',
Expand All @@ -190,7 +176,7 @@
'domesticCarrierCodeFormattingRule' => '0$CC $1',
'nationalPrefixOptionalWhenFormatting' => false,
),
3 =>
2 =>
array (
'pattern' => '(\\d)(\\d{3})(\\d{7})',
'format' => '$1-$2-$3',
Expand All @@ -206,18 +192,6 @@
'intlNumberFormat' =>
array (
0 =>
array (
'pattern' => '(\\d)(\\d{7})',
'format' => '$1 $2',
'leadingDigitsPatterns' =>
array (
0 => '[146][2-9]|[2578]',
),
'nationalPrefixFormattingRule' => '($1)',
'domesticCarrierCodeFormattingRule' => '0$CC $1',
'nationalPrefixOptionalWhenFormatting' => false,
),
1 =>
array (
'pattern' => '(\\d{3})(\\d{7})',
'format' => '$1 $2',
Expand All @@ -226,10 +200,10 @@
0 => '6',
),
'nationalPrefixFormattingRule' => '($1)',
'domesticCarrierCodeFormattingRule' => '',
'domesticCarrierCodeFormattingRule' => '0$CC $1',
'nationalPrefixOptionalWhenFormatting' => false,
),
2 =>
1 =>
array (
'pattern' => '(\\d{3})(\\d{7})',
'format' => '$1 $2',
Expand All @@ -241,7 +215,7 @@
'domesticCarrierCodeFormattingRule' => '0$CC $1',
'nationalPrefixOptionalWhenFormatting' => false,
),
3 =>
2 =>
array (
'pattern' => '(\\d)(\\d{3})(\\d{7})',
'format' => '$1 $2 $3',
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 @@ -36,7 +36,7 @@
),
'mobile' =>
array (
'NationalNumberPattern' => '(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[017]\\d|2[0-2]|6[0-367]))\\d{6}',
'NationalNumberPattern' => '(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[017]\\d|2[0-2]|6[0-8]))\\d{6}',
'ExampleNumber' => '650123456',
'PossibleLength' =>
array (
Expand Down
2 changes: 1 addition & 1 deletion src/data/PhoneNumberMetadata_FO.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
),
'mobile' =>
array (
'NationalNumberPattern' => '(?:[27][1-9]|5\\d|91)\\d{4}',
'NationalNumberPattern' => '(?:[27][1-9]|5\\d|9[16])\\d{4}',
'ExampleNumber' => '211234',
'PossibleLength' =>
array (
Expand Down
2 changes: 1 addition & 1 deletion src/data/PhoneNumberMetadata_GE.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
),
'mobile' =>
array (
'NationalNumberPattern' => '5(?:(?:0555|1177)[5-9]|757(?:7[7-9]|8[01]))\\d{3}|5(?:00(?:0\\d|50)|11(?:00|1\\d|2[0-4]|3[01])|5200|75(?:00|[57]5)|8(?:0(?:[01]\\d|2[0-4])|58[89]|8(?:55|88)))\\d{4}|5(?:0070|11(?:33|51)|[25]222|3333)[0-4]\\d{3}|(?:5(?:[14]4|5[0157-9]|68|7[0147-9]|9[1-35-9])|790)\\d{6}',
'NationalNumberPattern' => '5(?:(?:0555|1(?:[17]77|555))[5-9]|757(?:7[7-9]|8[01]))\\d{3}|5(?:0070|11(?:33|51)|[25]222|3333)[0-4]\\d{3}|5(?:00(?:0\\d|5[05])|11(?:00|1\\d|2[0-4]|3[01])|5200|75(?:00|[57]5)|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 (
Expand Down
2 changes: 1 addition & 1 deletion src/data/PhoneNumberMetadata_GP.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
),
'fixedLine' =>
array (
'NationalNumberPattern' => '590(?:0[1-68]|[14][0-24-9]|2[0-68]|3[1289]|5[3-579]|6[0189]|7[08]|8[0-689]|9\\d)\\d{4}',
'NationalNumberPattern' => '590(?:0[1-68]|[14][0-24-9]|2[0-68]|3[1289]|5[3-579]|6[0-289]|7[08]|8[0-689]|9\\d)\\d{4}',
'ExampleNumber' => '590201234',
'PossibleLength' =>
array (
Expand Down
Loading

0 comments on commit a42d89a

Please sign in to comment.