Skip to content

Commit a6e1029

Browse files
authored
Merge pull request #66 from giggsey/upstream-8.13.40
Upstream metadata changes from Google for v8.13.40
2 parents 5915119 + 9e7f353 commit a6e1029

12 files changed

Lines changed: 36 additions & 19 deletions

METADATA-VERSION.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
* For more information, look at the phing tasks in build.xml
66
* @internal
77
*/
8-
return 'v8.13.39';
8+
return 'v8.13.40';

src/PhoneNumberUtil.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,13 @@ class PhoneNumberUtil
169169
86, // China
170170
];
171171

172+
/**
173+
* Set of country codes that doesn't have national prefix, but it has area codes.
174+
*/
175+
protected const COUNTRIES_WITHOUT_NATIONAL_PREFIX_WITH_AREA_CODES = [
176+
52, // Mexico
177+
];
178+
172179
/**
173180
* Set of country calling codes that have geographically assigned mobile numbers. This may not be
174181
* complete; we add calling codes case by case, as we find geographical mobile numbers or hear
@@ -787,20 +794,25 @@ public function getLengthOfGeographicalAreaCode(PhoneNumber $number): int
787794
if ($metadata === null) {
788795
return 0;
789796
}
797+
798+
$countryCallingCode = $number->getCountryCode();
799+
800+
790801
// If a country doesn't use a national prefix, and this number doesn't have an Italian leading
791802
// zero, we assume it is a closed dialling plan with no area codes.
792-
if (!$metadata->hasNationalPrefix() && !$number->isItalianLeadingZero()) {
803+
// Note:this is our general assumption, but there are exceptions which are tracked in
804+
// COUNTRIES_WITHOUT_NATIONAL_PREFIX_WITH_AREA_CODES.
805+
if (!$metadata->hasNationalPrefix() && !$number->isItalianLeadingZero() && !in_array($countryCallingCode, static::COUNTRIES_WITHOUT_NATIONAL_PREFIX_WITH_AREA_CODES)) {
793806
return 0;
794807
}
795808

796809
$type = $this->getNumberType($number);
797-
$countryCallingCode = $number->getCountryCode();
798810

799811
if ($type === PhoneNumberType::MOBILE
800812
// Note this is a rough heuristic; it doesn't cover Indonesia well, for example, where area
801813
// codes are present for some mobile phones but not for others. We have no better way of
802814
// representing this in the metadata at this point.
803-
&& in_array($countryCallingCode, self::GEO_MOBILE_COUNTRIES_WITHOUT_MOBILE_AREA_CODES)
815+
&& in_array($countryCallingCode, static::GEO_MOBILE_COUNTRIES_WITHOUT_MOBILE_AREA_CODES)
804816
) {
805817
return 0;
806818
}

src/data/PhoneNumberMetadata_FI.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
],
2424
],
2525
'fixedLine' => [
26-
'pattern' => '(?:1[3-79][1-8]|[23568][1-8]\\d|9(?:00|[1-8]\\d))\\d{2,6}',
26+
'pattern' => '1[35-7][1-8]\\d{3,6}|(?:1[49][1-8]|[23568][1-8]\\d|9(?:00|[1-8]\\d))\\d{2,6}',
2727
'example' => '131234567',
2828
'posLength' => [
2929
5,
@@ -156,7 +156,7 @@
156156
'pattern' => '(\\d)(\\d{4,9})',
157157
'format' => '$1 $2',
158158
'leadingDigitsPatterns' => [
159-
'(?:1[3-79]|[2568])[1-8]|3(?:0[1-9]|[1-9])|9',
159+
'(?:1[49]|[2568])[1-8]|3(?:0[1-9]|[1-9])|9',
160160
],
161161
'nationalPrefixFormattingRule' => '0$1',
162162
'domesticCarrierCodeFormattingRule' => '',
@@ -203,7 +203,7 @@
203203
'pattern' => '(\\d)(\\d{4,9})',
204204
'format' => '$1 $2',
205205
'leadingDigitsPatterns' => [
206-
'(?:1[3-79]|[2568])[1-8]|3(?:0[1-9]|[1-9])|9',
206+
'(?:1[49]|[2568])[1-8]|3(?:0[1-9]|[1-9])|9',
207207
],
208208
'nationalPrefixFormattingRule' => '0$1',
209209
'domesticCarrierCodeFormattingRule' => '',

src/data/PhoneNumberMetadata_GE.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
],
2929
],
3030
'mobile' => [
31-
'pattern' => '5(?:(?:(?:0555|1(?:[17]77|555))[5-9]|757(?:7[7-9]|8[01]))\\d|22252[0-4])\\d\\d|(?:5(?:0(?:0(?:0\\d|11|22|3[0-6]|44|5[05]|77|88|9[09])|111|77\\d)|1(?:1(?:[03][01]|[124]\\d)|4\\d\\d)|[23]555|4(?:4\\d\\d|555)|5(?:[0157-9]\\d\\d|200)|6[89]\\d\\d|7(?:[0147-9]\\d\\d|5(?:00|[57]5))|8(?:0(?:[018]\\d|2[0-4])|5(?:55|8[89])|8(?:55|88))|9(?:090|[1-35-9]\\d\\d))|790\\d\\d)\\d{4}|5(?:0(?:0[17]0|505)|1(?:0[01]0|1(?:07|33|51))|2(?:0[02]0|2[25]2)|3(?:0[03]0|3[35]3)|(?:40[04]|900)0|5222)[0-4]\\d{3}',
31+
'pattern' => '5(?:(?:(?:0555|1(?:[17]77|555))[5-9]|757(?:7[7-9]|8[01]))\\d|22252[0-4])\\d\\d|(?:5(?:0(?:0(?:0\\d|11|22|3[0-6]|44|5[05]|77|88|9[09])|111|22[02]|77\\d)|1(?:1(?:[03][01]|[124]\\d)|4\\d\\d)|[23]555|4(?:4\\d\\d|555)|5(?:[0157-9]\\d\\d|200)|6[89]\\d\\d|7(?:[0147-9]\\d\\d|5(?:00|[57]5))|8(?:0(?:[018]\\d|2[0-4])|5(?:55|8[89])|8(?:55|88))|9(?:090|[1-35-9]\\d\\d))|790\\d\\d)\\d{4}|5(?:0(?:0[17]0|505)|1(?:0[01]0|1(?:07|33|51))|2(?:0[02]0|2[25]2)|3(?:0[03]0|3[35]3)|(?:40[04]|900)0|5222)[0-4]\\d{3}',
3232
'example' => '555123456',
3333
],
3434
'tollFree' => [

src/data/PhoneNumberMetadata_GY.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
'example' => '2201234',
2121
],
2222
'mobile' => [
23-
'pattern' => '(?:510|6\\d\\d|7(?:[013]\\d|2[0-25-8]|4[0-29]|5[1-9]))\\d{4}',
23+
'pattern' => '(?:510|6\\d\\d|7(?:[0135]\\d|2[0-8]|4[0-24-9]))\\d{4}',
2424
'example' => '6091234',
2525
],
2626
'tollFree' => [

src/data/PhoneNumberMetadata_HK.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
],
2929
],
3030
'mobile' => [
31-
'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])|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[129]|84[0-29]|9(?:0[1-9]|1[02-9]|[2358][0-8]|[467]\\d))\\d{5}',
31+
'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}',
3232
'example' => '51234567',
3333
'posLength' => [
3434
8,

src/data/PhoneNumberMetadata_IL.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
],
6969
],
7070
'voip' => [
71-
'pattern' => '7(?:38(?:0\\d|5[0-29]|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}',
71+
'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}',
7272
'example' => '771234567',
7373
'posLength' => [
7474
9,

src/data/PhoneNumberMetadata_MU.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
],
2727
],
2828
'mobile' => [
29-
'pattern' => '5(?:4(?:2[1-389]|7[1-9])|87[15-8])\\d{4}|(?:5(?:2[5-9]|4[3-689]|[57]\\d|8[0-689]|9[0-8])|7(?:0[0-3]|3[013]))\\d{5}',
29+
'pattern' => '5(?:4(?:2[1-389]|7[1-9])|87[15-8])\\d{4}|(?:5(?:2[5-9]|4[3-689]|[57]\\d|8[0-689]|9[0-8])|7(?:0[0-4]|3[013]))\\d{5}',
3030
'example' => '52512345',
3131
'posLength' => [
3232
8,

src/data/PhoneNumberMetadata_MX.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
],
2121
],
2222
'fixedLine' => [
23-
'pattern' => '657[12]\\d{6}|(?:2(?:0[01]|2\\d|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]|[25-7][1-9]|3[1-8]|4\\d|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(?:[1346][1-9]|[27]\\d|5[13-9]|8[1-69]|9[17])|8(?:1\\d|2[13-689]|3[1-6]|4[124-6]|6[1246-9]|7[0-378]|9[12479])|9(?:1[346-9]|2[1-4]|3[2-46-8]|5[1348]|[69]\\d|7[12]|8[1-8]))\\d{7}',
23+
'pattern' => '657[12]\\d{6}|(?:2(?:0[01]|2\\d|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]|[25-7][1-9]|3[1-8]|4\\d|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[0-57-9]|7[1-7]|8[67]|9[4-8])|7(?:[1346][1-9]|[27]\\d|5[13-9]|8[1-69]|9[17])|8(?:1\\d|2[13-689]|3[1-6]|4[124-6]|6[1246-9]|7[0-378]|9[12479])|9(?:1[346-9]|2[1-4]|3[2-46-8]|5[1348]|[69]\\d|7[12]|8[1-8]))\\d{7}',
2424
'example' => '2001234567',
2525
'posLengthLocal' => [
2626
7,
2727
8,
2828
],
2929
],
3030
'mobile' => [
31-
'pattern' => '657[12]\\d{6}|(?:2(?:2\\d|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]|[25-7][1-9]|3[1-8]|4\\d|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(?:[1346][1-9]|[27]\\d|5[13-9]|8[1-69]|9[17])|8(?:1\\d|2[13-689]|3[1-6]|4[124-6]|6[1246-9]|7[0-378]|9[12479])|9(?:1[346-9]|2[1-4]|3[2-46-8]|5[1348]|[69]\\d|7[12]|8[1-8]))\\d{7}',
31+
'pattern' => '657[12]\\d{6}|(?:2(?:2\\d|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]|[25-7][1-9]|3[1-8]|4\\d|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[0-57-9]|7[1-7]|8[67]|9[4-8])|7(?:[1346][1-9]|[27]\\d|5[13-9]|8[1-69]|9[17])|8(?:1\\d|2[13-689]|3[1-6]|4[124-6]|6[1246-9]|7[0-378]|9[12479])|9(?:1[346-9]|2[1-4]|3[2-46-8]|5[1348]|[69]\\d|7[12]|8[1-8]))\\d{7}',
3232
'example' => '2221234567',
3333
'posLengthLocal' => [
3434
7,

src/data/PhoneNumberMetadata_TD.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
'id' => 'TD',
1111
'countryCode' => 235,
1212
'generalDesc' => [
13-
'pattern' => '(?:22|[69]\\d|77)\\d{6}',
13+
'pattern' => '(?:22|[689]\\d|77)\\d{6}',
1414
'posLength' => [
1515
8,
1616
],
@@ -20,7 +20,7 @@
2020
'example' => '22501234',
2121
],
2222
'mobile' => [
23-
'pattern' => '(?:6[0-689]|77|9\\d)\\d{6}',
23+
'pattern' => '(?:[69]\\d|77|8[56])\\d{6}',
2424
'example' => '63012345',
2525
],
2626
'tollFree' => [
@@ -75,7 +75,7 @@
7575
'pattern' => '(\\d{2})(\\d{2})(\\d{2})(\\d{2})',
7676
'format' => '$1 $2 $3 $4',
7777
'leadingDigitsPatterns' => [
78-
'[2679]',
78+
'[26-9]',
7979
],
8080
'nationalPrefixFormattingRule' => '',
8181
'domesticCarrierCodeFormattingRule' => '',

0 commit comments

Comments
 (0)