Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion METADATA-VERSION.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
* For more information, look at the phing tasks in build.xml
* @internal
*/
return 'v9.0.35';
return 'v9.0.36';
2 changes: 1 addition & 1 deletion src/PhoneNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public function unserialize($data): void
}

/**
* @param array{int,string,string,bool|null,int,string|null,CountryCodeSource|null,string|null} $data
* @param array{int,string,string,bool|null,int,string|null,CountryCodeSource|int|null,string|null} $data
*/
public function __unserialize(array $data): void
{
Expand Down
38 changes: 35 additions & 3 deletions src/PhoneNumberUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -933,9 +933,11 @@ protected function getRegionCodeForNumberFromRegionList(PhoneNumber $number, arr
public function getNationalSignificantNumber(PhoneNumber $number): string
{
// If leading zero(s) have been set, we prefix this now. Note this is not a national prefix.
// Defensively cap the number of leading zeros to avoid OOM from malicious input.
$nationalNumber = '';
if ($number->isItalianLeadingZero() && $number->getNumberOfLeadingZeros() > 0) {
$zeros = str_repeat('0', $number->getNumberOfLeadingZeros());
$numberOfLeadingZeros = min($number->getNumberOfLeadingZeros(), 10);
$zeros = str_repeat('0', $numberOfLeadingZeros);
$nationalNumber .= $zeros;
}
$nationalNumber .= $number->getNationalNumber();
Expand Down Expand Up @@ -1370,6 +1372,30 @@ public static function getCountryMobileToken(int $countryCallingCode): string
return static::MOBILE_TOKEN_MAPPINGS[(string) $countryCallingCode] ?? '';
}

/**
* Checks whether the supplied string contains at least three ASCII letters.
*/
private function hasAtLeastThreeAlphaChars(string $number): bool
{
$alphaCount = 0;
$length = strlen($number);

for ($i = 0; $i < $length; $i++) {
$character = ord($number[$i]);

if (
($character >= 65 && $character <= 90)
|| ($character >= 97 && $character <= 122)
) {
if (++$alphaCount >= 3) {
return true;
}
}
}

return false;
}

/**
* Checks if the number is a valid vanity (alpha) number such as 800 MICROSOFT. A valid vanity
* number will start with at least 3 digits and will have three or more alpha characters. This
Expand All @@ -1382,12 +1408,18 @@ public static function getCountryMobileToken(int $countryCallingCode): string
*/
public function isAlphaNumber(string $number): bool
{
if (strlen($number) > static::MAX_INPUT_STRING_LENGTH) {
return false;
}

if (!static::isViablePhoneNumber($number)) {
// Number is too short, or doesn't match the basic phone number pattern.
// Number is too short, or doesn't match the basic phone-number pattern.
return false;
}

$this->maybeStripExtension($number);
return (bool) preg_match('/' . static::VALID_ALPHA_PHONE_PATTERN . '/' . static::REGEX_FLAGS, $number);

return $this->hasAtLeastThreeAlphaChars($number);
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/carrier/data/en/En_212.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class En_212
21270 => 'Inwi',
21271 => 'Inwi',
21272 => 'Inwi',
21273 => 'Orange',
21275 => 'Maroc Telecom',
21276 => 'Maroc Telecom',
21277 => 'Orange',
Expand Down
7 changes: 1 addition & 6 deletions src/carrier/data/en/En_256.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class En_256
25676 => 'MTN',
25677 => 'MTN',
25678 => 'MTN',
25679 => 'MTN',
256720 => 'Smile',
256721 => 'LycaMobile',
256724 => 'MTN',
Expand All @@ -34,12 +35,6 @@ class En_256
256731 => 'Airtel',
256736 => 'Hamilton Telecom',
256737 => 'MTN',
256790 => 'MTN',
256791 => 'MTN',
256792 => 'MTN',
256793 => 'MTN',
256794 => 'MTN',
256795 => 'Airtel',
256798 => 'Africell',
256799 => 'Africell',
2567210 => 'Savanna',
Expand Down
1 change: 0 additions & 1 deletion src/carrier/data/en/En_298.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class En_298
29878 => 'Faroese Telecom',
29879 => 'Faroese Telecom',
29891 => 'Faroese Telecom',
29893 => 'Faroese Telecom',
29896 => 'Faroese Telecom',
];
}
2 changes: 1 addition & 1 deletion src/carrier/data/en/En_423.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class En_423
{
public const DATA = [
42364 => 'Soracom',
42364 => 'Telecom Liechtenstein',
42365 => 'Cubic',
42366 => 'Telecom Liechtenstein',
42373 => 'Telecom Liechtenstein',
Expand Down
3 changes: 0 additions & 3 deletions src/carrier/data/en/En_47.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ class En_47
{
public const DATA = [
4741 => 'telenor norge',
4742 => 'telenor norge',
4743 => 'telenor norge',
4744 => 'telenor norge',
4745 => 'telia',
4749 => 'telenor norge',
4790 => 'telenor norge',
Expand Down
6 changes: 3 additions & 3 deletions src/carrier/data/en/En_61.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ class En_61
61488 => 'Telstra',
61495 => 'Optus',
614201 => 'Pivotel Satellite',
614400 => 'the trustee for aazad distribution discretionary trust',
614400 => 'Aazad distribution discretionary trust',
614444 => 'Telstra',
614445 => 'Telstra',
614493 => 'soul pattinson',
614493 => 'Soul Pattinson',
614700 => 'Lycamobile',
614701 => 'Lycamobile',
614702 => 'Lycamobile',
Expand Down Expand Up @@ -122,7 +122,7 @@ class En_61
6142001 => 'Rail Corporation NSW',
6142002 => 'Dialogue Communications',
6142003 => 'MessageBird',
6142004 => 'symbio networks',
6142004 => 'Symbio Networks',
6148984 => 'Victorian Rail Track',
6148985 => 'MessageBird',
];
Expand Down
18 changes: 16 additions & 2 deletions src/carrier/data/en/En_972.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class En_972
972550 => 'Beezz',
972552 => '019mobile',
972556 => 'Rami Levy',
972558 => 'Pelephone',
972559 => '019mobile',
9725520 => 'BITIT',
9725521 => 'BITIT',
Expand All @@ -43,7 +42,6 @@ class En_972
9725543 => 'Maskyoo',
9725544 => 'Cellran Cellular Communications',
9725545 => 'Maskyoo',
9725546 => 'Xphone',
9725550 => 'Annatel',
9725551 => 'Annatel',
9725552 => 'Annatel',
Expand All @@ -53,12 +51,28 @@ class En_972
9725571 => 'Cellact',
9725572 => 'Cellact',
9725577 => '019mobile',
9725587 => 'Pelephone',
9725588 => 'Pelephone',
9725589 => 'Pelephone',
97255400 => 'Rami Levy',
97255401 => 'Rami Levy',
97255402 => 'Rami Levy',
97255403 => 'Yossi',
97255440 => 'Merkaziya',
97255442 => 'Xphone',
97255443 => 'Yossi',
97255460 => 'Xphone',
97255461 => 'Merkaziya',
97255465 => 'Pelephone',
97255466 => 'Pelephone',
97255467 => 'Pelephone',
97255468 => 'Pelephone',
97255469 => 'Pelephone',
97255800 => 'Merkaziya',
97255801 => '019mobile',
97255802 => 'BITIT',
97255860 => 'Merkaziya',
97255861 => '019mobile',
97255862 => 'BITIT',
];
}
24 changes: 9 additions & 15 deletions src/carrier/data/en/En_995.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class En_995
995504 => 'Cellfie',
995507 => 'Globalcell',
995510 => 'Silknet',
995511 => 'MagtiCom',
995514 => 'Silknet',
995515 => 'MagtiCom',
995517 => 'MagtiCom',
Expand Down Expand Up @@ -58,28 +59,20 @@ class En_995
995597 => 'Cellfie',
995598 => 'MagtiCom',
995599 => 'MagtiCom',
9955002 => 'Silknet',
9955003 => 'Unicell Mobile',
9955004 => 'Silknet',
9955008 => 'Silknet',
9955050 => 'Silknet',
9955055 => 'MagtiCom',
9955111 => 'MagtiCom',
9955112 => 'MagtiCom',
9955113 => 'MagtiCom',
9955114 => 'MagtiCom',
9955117 => 'MagtiCom',
9955225 => 'Silknet',
9955333 => 'MagtiCom',
9955335 => 'Silknet',
9955440 => 'Cellfie',
9955441 => 'Cellfie',
9955442 => 'Cellfie',
9955443 => 'Cellfie',
9955447 => 'Cellfie',
9955449 => 'Cellfie',
9955520 => 'Premium Net International SRL',
9955522 => 'Asanet',
9955522 => 'MagtiCom',
9955750 => 'Asanet',
9955755 => 'Silknet',
9955855 => 'Globalcell',
Expand All @@ -92,25 +85,26 @@ class En_995
99550011 => 'Silknet',
99550012 => 'Silknet',
99550019 => 'Cellfie',
99550020 => 'MagtiCom',
99550022 => 'Silknet',
99550033 => 'Silknet',
99550040 => 'MagtiCom',
99550044 => 'Silknet',
99550050 => 'MagtiCom',
99550055 => 'Silknet',
99550070 => 'Cellfie',
99550077 => 'Silknet',
99550090 => 'Cellfie',
99550099 => 'Silknet',
99551100 => 'MagtiCom',
99551101 => 'Silknet',
99551107 => 'Silknet',
99551151 => 'Silknet',
99551152 => 'MagtiCom',
99551153 => 'MagtiCom',
99551154 => 'MagtiCom',
99551155 => 'MagtiCom',
99551156 => 'MagtiCom',
99552222 => 'MagtiCom',
99552225 => 'Silknet',
99552228 => 'Cellfie',
99554411 => 'Cellfie',
99554414 => 'MagtiCom',
99554440 => 'MagtiCom',
99554444 => 'MagtiCom',
99554454 => 'Silknet',
99554455 => 'Cellfie',
Expand Down
4 changes: 2 additions & 2 deletions src/data/PhoneNumberAlternateFormats_995.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public function __construct()
(new NumberFormat())
->setPattern('(\d{3})(\d{6})')
->setFormat('$1 $2')
->setLeadingDigitsPattern(['[348]|5545'])
->setLeadingDigitsPattern(['[348]'])
->setNationalPrefixOptionalWhenFormatting(false),
(new NumberFormat())
->setPattern('(\d{3})(\d{3})(\d{3})')
->setFormat('$1 $2 $3')
->setLeadingDigitsPattern(['[348]|5545'])
->setLeadingDigitsPattern(['[348]'])
->setNationalPrefixOptionalWhenFormatting(false),
(new NumberFormat())
->setPattern('(\d{2})(\d{2})(\d{3})(\d{2})')
Expand Down
2 changes: 1 addition & 1 deletion src/data/PhoneNumberMetadata_BD.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function __construct()
$this->sharedCost = PhoneNumberDesc::empty();
$this->personalNumber = PhoneNumberDesc::empty();
$this->voip = (new PhoneNumberDesc())
->setNationalNumberPattern('96(?:0[469]|1[0-47]|3[389]|43|6[69]|7[78])\d{6}')
->setNationalNumberPattern('96(?:0[1-69]|1[0-479]|2[278]|3[13-9]|4[013]|54|6[69]|7[78]|88)\d{6}')
->setExampleNumber('9604123456')
->setPossibleLength([10]);
$this->pager = PhoneNumberDesc::empty();
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 @@ -32,7 +32,7 @@ public function __construct()
->setNationalNumberPattern('[5-8]\d{8}')
->setPossibleLength([9]);
$this->mobile = (new PhoneNumberDesc())
->setNationalNumberPattern('(?:6(?:[0-79]\d|8[0-247-9])|7(?:[016-8]\d|2[0-8]|5[0-5]))\d{6}')
->setNationalNumberPattern('(?:6(?:[0-79]\d|8[0-247-9])|7(?:[016-8]\d|2[0-8]|3[01]|5[0-5]))\d{6}')
->setExampleNumber('650123456');
$this->premiumRate = (new PhoneNumberDesc())
->setNationalNumberPattern('89\d{7}')
Expand Down
8 changes: 4 additions & 4 deletions src/data/PhoneNumberMetadata_FO.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct()
->setNationalNumberPattern('[2-9]\d{5}')
->setPossibleLength([6]);
$this->mobile = (new PhoneNumberDesc())
->setNationalNumberPattern('(?:[27][1-9]|5\d|9[136])\d{4}')
->setNationalNumberPattern('(?:[27][1-9]|5\d|9[16])\d{4}')
->setExampleNumber('211234');
$this->premiumRate = (new PhoneNumberDesc())
->setNationalNumberPattern('90(?:[13-5][15-7]|2[125-7]|9\d)\d\d')
Expand All @@ -42,8 +42,8 @@ public function __construct()
->setExampleNumber('201234');
$this->numberFormat = [
(new NumberFormat())
->setPattern('(\d{6})')
->setFormat('$1')
->setPattern('(\d{2})(\d{2})(\d{2})')
->setFormat('$1 $2 $3')
->setLeadingDigitsPattern(['[2-9]'])
->setDomesticCarrierCodeFormattingRule('$CC $1')
->setNationalPrefixOptionalWhenFormatting(false),
Expand All @@ -54,7 +54,7 @@ public function __construct()
$this->sharedCost = PhoneNumberDesc::empty();
$this->personalNumber = PhoneNumberDesc::empty();
$this->voip = (new PhoneNumberDesc())
->setNationalNumberPattern('(?:6[0-36]|88)\d{4}')
->setNationalNumberPattern('6[0-36]\d{4}')
->setExampleNumber('601234');
$this->pager = PhoneNumberDesc::empty();
$this->uan = PhoneNumberDesc::empty();
Expand Down
6 changes: 3 additions & 3 deletions src/data/PhoneNumberMetadata_GE.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct()
->setPossibleLengthLocalOnly([6, 7])
->setPossibleLength([9]);
$this->mobile = (new PhoneNumberDesc())
->setNationalNumberPattern('5(?:(?:(?:0555|1(?:[17]77|555))[5-9]|757(?:7[7-9]|8[01]))\d|22252[0-4])\d\d|5(?:0(?:0(?:1[09]|70)|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}|(?:5(?:0(?:0(?:0\d|1[12]|22|3[0-6]|44|5[05]|77|88|9[09])|(?:[14]\d|77)\d|22[02])|1(?:1(?:[03][01]|[124]\d|5[2-6]|7[0-6])|4\d\d)|2(?:228|555)|3555|4(?:4\d\d|555)|5(?:[0157-9]\d\d|200|333|4(?:44|55))|6[89]\d\d|7(?:(?:[0147-9]\d|22)\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}')
->setNationalNumberPattern('5(?:(?:(?:0555|1(?:[17]77|555))[5-9]|757(?:7[7-9]|8[01]))\d|22252[0-4])\d\d|5(?:0(?:0(?:1[09]|70)|505)|1(?:0[01]0|1(?:07|33|51))|2(?:0[02]0|2[25]2)|3(?:0[03]0|3[35]3)|4(?:0[04]0|411)|5222|9000)[0-4]\d{3}|(?:5(?:0(?:0(?:0\d|1[12]|2[02]|3[0-6]|4[04]|5[05]|77|88|9[09])|(?:[14]\d|77)\d|22[02])|1(?:1(?:[03][01]|[124]\d|5[02-6]|7[0-6])|4\d\d)|2(?:228|555)|3555|4(?:4(?:[02-9]\d|14)|555)|5(?:[0157-9]\d\d|200|333|4(?:44|55))|6[89]\d\d|7(?:(?:[0147-9]\d|22)\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}')
->setExampleNumber('555123456');
$this->premiumRate = PhoneNumberDesc::empty();
$this->fixedLine = (new PhoneNumberDesc())
Expand All @@ -58,12 +58,12 @@ public function __construct()
(new NumberFormat())
->setPattern('(\d{3})(\d{2})(\d{2})(\d{2})')
->setFormat('$1 $2 $3 $4')
->setLeadingDigitsPattern(['5(?:[0-46-9]|5[0-57-9])|7', '5(?:[0-46-9]|5(?:[0-357-9]|44))|7'])
->setLeadingDigitsPattern(['[57]'])
->setNationalPrefixOptionalWhenFormatting(false),
(new NumberFormat())
->setPattern('(\d{3})(\d{2})(\d{2})(\d{2})')
->setFormat('$1 $2 $3 $4')
->setLeadingDigitsPattern(['[3-58]'])
->setLeadingDigitsPattern(['[348]'])
->setNationalPrefixFormattingRule('0$1')
->setNationalPrefixOptionalWhenFormatting(false),
];
Expand Down
4 changes: 2 additions & 2 deletions src/data/PhoneNumberMetadata_IL.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct()
->setNationalNumberPattern('1\d{6}(?:\d{3,5})?|[57]\d{8}|[1-489]\d{7}')
->setPossibleLength([7, 8, 9, 10, 11, 12]);
$this->mobile = (new PhoneNumberDesc())
->setNationalNumberPattern('55(?:4(?:0[0-3]|[16]0)|57[0-289])\d{4}|5(?:(?:[0-2][02-9]|[36]\d|[49][2-9]|8[3-7])\d|5(?:01|2\d|3[0-3]|4[3-5]|5[0-25689]|6[6-8]|7[0-267]|8[7-9]|9[1-9]))\d{5}')
->setNationalNumberPattern('55(?:4(?:0[0-3]|10|6[015-9])|57[0-289]|8[06][0-2])\d{4}|5(?:(?:[0-2][02-9]|[36]\d|[49][2-9]|8[3-7])\d|5(?:01|2\d|3[0-3]|4[3-5]|5[0-25689]|6[6-8]|7[0-267]|8[7-9]|9[1-9]))\d{5}')
->setExampleNumber('502345678')
->setPossibleLength([9]);
$this->premiumRate = (new PhoneNumberDesc())
Expand Down Expand Up @@ -100,7 +100,7 @@ public function __construct()
->setPossibleLength([10]);
$this->personalNumber = PhoneNumberDesc::empty();
$this->voip = (new PhoneNumberDesc())
->setNationalNumberPattern('7(?:38(?:[05]\d|8[0138])|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}')
->setNationalNumberPattern('7(?:280[01]|38(?:[05]\d|8[01358])|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}')
->setExampleNumber('771234567')
->setPossibleLength([9]);
$this->pager = PhoneNumberDesc::empty();
Expand Down
2 changes: 1 addition & 1 deletion src/data/PhoneNumberMetadata_LI.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct()
->setNationalNumberPattern('[68]\d{8}|(?:[2378]\d|90)\d{5}')
->setPossibleLength([7, 9]);
$this->mobile = (new PhoneNumberDesc())
->setNationalNumberPattern('(?:6(?:(?:4[5-9]|5\d)\d|6(?:[024-68]\d|1[01]|3[7-9]|70))\d|7(?:[37-9]\d|42|56))\d{4}')
->setNationalNumberPattern('(?:6(?:(?:4[5-9]|5\d)\d|6(?:[024-68]\d|1[01]|3[7-9]|7[02]))\d|7(?:[37-9]\d|42|56))\d{4}')
->setExampleNumber('660234567');
$this->premiumRate = (new PhoneNumberDesc())
->setNationalNumberPattern('90(?:02[258]|1(?:23|3[14])|66[136])\d\d')
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 @@ -36,7 +36,7 @@ public function __construct()
->setNationalNumberPattern('[5-8]\d{8}')
->setPossibleLength([9]);
$this->mobile = (new PhoneNumberDesc())
->setNationalNumberPattern('(?:6(?:[0-79]\d|8[0-247-9])|7(?:[016-8]\d|2[0-8]|5[0-5]))\d{6}')
->setNationalNumberPattern('(?:6(?:[0-79]\d|8[0-247-9])|7(?:[016-8]\d|2[0-8]|3[01]|5[0-5]))\d{6}')
->setExampleNumber('650123456');
$this->premiumRate = (new PhoneNumberDesc())
->setNationalNumberPattern('89\d{7}')
Expand Down
Loading
Loading