From 36b66c900af876746fd98fa584c0434d8acf145f Mon Sep 17 00:00:00 2001 From: Ilya Gusev Date: Tue, 26 Apr 2016 20:06:48 +0300 Subject: [PATCH 1/2] changed private to protected --- src/libphonenumber/Matcher.php | 8 +- .../MultiFileMetadataSourceImpl.php | 10 +- src/libphonenumber/NumberFormat.php | 10 +- src/libphonenumber/NumberParseException.php | 2 +- src/libphonenumber/PhoneMetadata.php | 62 +++++----- src/libphonenumber/PhoneNumber.php | 18 +-- src/libphonenumber/PhoneNumberDesc.php | 12 +- .../PhoneNumberToCarrierMapper.php | 10 +- .../PhoneNumberToTimeZonesMapper.php | 16 +-- src/libphonenumber/PhoneNumberUtil.php | 116 +++++++++--------- src/libphonenumber/ShortNumberInfo.php | 30 ++--- src/libphonenumber/ShortNumberUtil.php | 2 +- .../geocoding/PhoneNumberOfflineGeocoder.php | 14 +-- .../prefixmapper/MappingFileProvider.php | 4 +- .../prefixmapper/PhonePrefixMap.php | 4 +- .../prefixmapper/PrefixFileReader.php | 10 +- .../prefixmapper/PrefixTimeZonesMap.php | 10 +- 17 files changed, 169 insertions(+), 169 deletions(-) diff --git a/src/libphonenumber/Matcher.php b/src/libphonenumber/Matcher.php index d0f27299d..abb9fa32a 100644 --- a/src/libphonenumber/Matcher.php +++ b/src/libphonenumber/Matcher.php @@ -14,17 +14,17 @@ class Matcher /** * @var string */ - private $pattern; + protected $pattern; /** * @var string */ - private $subject; + protected $subject; /** * @var array */ - private $groups = array(); + protected $groups = array(); /** * @param string $pattern @@ -36,7 +36,7 @@ public function __construct($pattern, $subject) $this->subject = $subject; } - private function doMatch($type = 'find') + protected function doMatch($type = 'find') { $final_pattern = '(?:' . $this->pattern . ')'; switch ($type) { diff --git a/src/libphonenumber/MultiFileMetadataSourceImpl.php b/src/libphonenumber/MultiFileMetadataSourceImpl.php index 86a680716..ebb240073 100644 --- a/src/libphonenumber/MultiFileMetadataSourceImpl.php +++ b/src/libphonenumber/MultiFileMetadataSourceImpl.php @@ -12,13 +12,13 @@ class MultiFileMetadataSourceImpl implements MetadataSourceInterface { - private static $metaDataFilePrefix = PhoneNumberUtil::META_DATA_FILE_PREFIX; + protected static $metaDataFilePrefix = PhoneNumberUtil::META_DATA_FILE_PREFIX; /** * A mapping from a region code to the PhoneMetadata for that region. * @var PhoneMetadata[] */ - private $regionToMetadataMap = array(); + protected $regionToMetadataMap = array(); /** * A mapping from a country calling code for a non-geographical entity to the PhoneMetadata for @@ -26,20 +26,20 @@ class MultiFileMetadataSourceImpl implements MetadataSourceInterface * Toll Free Service) and 808 (International Shared Cost Service). * @var PhoneMetadata[] */ - private $countryCodeToNonGeographicalMetadataMap = array(); + protected $countryCodeToNonGeographicalMetadataMap = array(); /** * The prefix of the metadata files from which region data is loaded. * @var String */ - private $currentFilePrefix; + protected $currentFilePrefix; /** * The metadata loader used to inject alternative metadata sources. * @var MetadataLoaderInterface */ - private $metadataLoader; + protected $metadataLoader; /** * @param MetadataLoaderInterface $metadataLoader diff --git a/src/libphonenumber/NumberFormat.php b/src/libphonenumber/NumberFormat.php index 84d771a89..025e1d971 100644 --- a/src/libphonenumber/NumberFormat.php +++ b/src/libphonenumber/NumberFormat.php @@ -7,11 +7,11 @@ */ class NumberFormat { - private $pattern = null; - private $format = null; - private $leadingDigitsPattern = array(); - private $nationalPrefixFormattingRule = null; - private $domesticCarrierCodeFormattingRule = null; + protected $pattern = null; + protected $format = null; + protected $leadingDigitsPattern = array(); + protected $nationalPrefixFormattingRule = null; + protected $domesticCarrierCodeFormattingRule = null; /** * @return boolean diff --git a/src/libphonenumber/NumberParseException.php b/src/libphonenumber/NumberParseException.php index 607d473bd..753c311c4 100644 --- a/src/libphonenumber/NumberParseException.php +++ b/src/libphonenumber/NumberParseException.php @@ -24,7 +24,7 @@ class NumberParseException extends \Exception // This indicates the string had more digits than any valid phone number could have. const TOO_LONG = 4; - private $errorType; + protected $errorType; public function __construct($errorType, $message, $previous = null) { diff --git a/src/libphonenumber/PhoneMetadata.php b/src/libphonenumber/PhoneMetadata.php index 7501359c7..c92c327e5 100644 --- a/src/libphonenumber/PhoneMetadata.php +++ b/src/libphonenumber/PhoneMetadata.php @@ -8,7 +8,7 @@ class PhoneMetadata /** * @var string */ - private $id = null; + protected $id = null; /** * @return boolean @@ -39,7 +39,7 @@ public function setId($value) /** * @var int */ - private $countryCode = null; + protected $countryCode = null; /** * @return boolean @@ -67,7 +67,7 @@ public function setCountryCode($value) return $this; } - private $leadingDigits = null; + protected $leadingDigits = null; /** * @return bool @@ -88,7 +88,7 @@ public function setLeadingDigits($value) return $this; } - private $internationalPrefix = null; + protected $internationalPrefix = null; public function hasInternationalPrefix() { @@ -106,7 +106,7 @@ public function setInternationalPrefix($value) return $this; } - private $preferredInternationalPrefix = null; + protected $preferredInternationalPrefix = null; public function hasPreferredInternationalPrefix() { @@ -124,7 +124,7 @@ public function setPreferredInternationalPrefix($value) return $this; } - private $nationalPrefixForParsing = null; + protected $nationalPrefixForParsing = null; public function hasNationalPrefixForParsing() { @@ -142,7 +142,7 @@ public function setNationalPrefixForParsing($value) return $this; } - private $nationalPrefixTransformRule = null; + protected $nationalPrefixTransformRule = null; public function hasNationalPrefixTransformRule() { @@ -160,7 +160,7 @@ public function setNationalPrefixTransformRule($value) return $this; } - private $nationalPrefix = null; + protected $nationalPrefix = null; public function hasNationalPrefix() { @@ -178,7 +178,7 @@ public function setNationalPrefix($value) return $this; } - private $preferredExtnPrefix = null; + protected $preferredExtnPrefix = null; public function hasPreferredExtnPrefix() { @@ -196,7 +196,7 @@ public function setPreferredExtnPrefix($value) return $this; } - private $mainCountryForCode = false; + protected $mainCountryForCode = false; public function hasMainCountryForCode() { @@ -219,7 +219,7 @@ public function setMainCountryForCode($value) return $this; } - private $leadingZeroPossible = false; + protected $leadingZeroPossible = false; public function hasLeadingZeroPossible() { @@ -237,7 +237,7 @@ public function setLeadingZeroPossible($value) return $this; } - private $mobileNumberPortableRegion = false; + protected $mobileNumberPortableRegion = false; public function hasMobileNumberPortableRegion() { @@ -255,7 +255,7 @@ public function setMobileNumberPortableRegion($value) return $this; } - private $generalDesc = null; + protected $generalDesc = null; public function hasGeneralDesc() { @@ -279,7 +279,7 @@ public function setGeneralDesc(PhoneNumberDesc $value) /** * @var PhoneNumberDesc */ - private $mobile = null; + protected $mobile = null; public function hasMobile() { @@ -300,7 +300,7 @@ public function setMobile(PhoneNumberDesc $value) return $this; } - private $premiumRate = null; + protected $premiumRate = null; public function hasPremiumRate() { @@ -321,7 +321,7 @@ public function setPremiumRate(PhoneNumberDesc $value) return $this; } - private $fixedLine = null; + protected $fixedLine = null; public function hasFixedLine() { @@ -342,7 +342,7 @@ public function setFixedLine(PhoneNumberDesc $value) return $this; } - private $sameMobileAndFixedLinePattern = false; + protected $sameMobileAndFixedLinePattern = false; public function hasSameMobileAndFixedLinePattern() { @@ -360,7 +360,7 @@ public function setSameMobileAndFixedLinePattern($value) return $this; } - private $numberFormat = array(); + protected $numberFormat = array(); /** * @return NumberFormat[] @@ -390,7 +390,7 @@ public function addNumberFormat(NumberFormat $value) return $this; } - private $tollFree = null; + protected $tollFree = null; public function hasTollFree() { @@ -411,7 +411,7 @@ public function setTollFree(PhoneNumberDesc $value) return $this; } - private $sharedCost = null; + protected $sharedCost = null; public function hasSharedCost() { @@ -432,7 +432,7 @@ public function setSharedCost(PhoneNumberDesc $value) return $this; } - private $personalNumber; + protected $personalNumber; public function hasPersonalNumber() { @@ -453,7 +453,7 @@ public function setPersonalNumber(PhoneNumberDesc $value) return $this; } - private $voip; + protected $voip; public function hasVoip() { @@ -474,7 +474,7 @@ public function setVoip(PhoneNumberDesc $value) return $this; } - private $pager; + protected $pager; public function hasPager() { @@ -495,7 +495,7 @@ public function setPager(PhoneNumberDesc $value) return $this; } - private $uan; + protected $uan; public function hasUan() { @@ -516,7 +516,7 @@ public function setUan(PhoneNumberDesc $value) return $this; } - private $emergency; + protected $emergency; public function hasEmergency() { @@ -537,7 +537,7 @@ public function setEmergency(PhoneNumberDesc $value) return $this; } - private $voicemail; + protected $voicemail; public function hasVoicemail() { @@ -561,7 +561,7 @@ public function setVoicemail(PhoneNumberDesc $value) /** * @var PhoneNumberDesc */ - private $short_code; + protected $short_code; public function hasShortCode() { @@ -582,7 +582,7 @@ public function setShortCode(PhoneNumberDesc $value) /** * @var PhoneNumberDesc */ - private $standard_rate; + protected $standard_rate; public function hasStandardRate() { @@ -603,7 +603,7 @@ public function setStandardRate(PhoneNumberDesc $value) /** * @var PhoneNumberDesc */ - private $carrierSpecific; + protected $carrierSpecific; public function hasCarrierSpecific() { @@ -624,7 +624,7 @@ public function setCarrierSpecific(PhoneNumberDesc $value) /** * @var PhoneNumberDesc */ - private $noInternationalDialling = null; + protected $noInternationalDialling = null; public function hasNoInternationalDialling() { @@ -646,7 +646,7 @@ public function setNoInternationalDialling(PhoneNumberDesc $value) * * @var NumberFormat[] */ - private $intlNumberFormat = array(); + protected $intlNumberFormat = array(); public function intlNumberFormats() { diff --git a/src/libphonenumber/PhoneNumber.php b/src/libphonenumber/PhoneNumber.php index 068ee0dad..e84854ce5 100644 --- a/src/libphonenumber/PhoneNumber.php +++ b/src/libphonenumber/PhoneNumber.php @@ -10,7 +10,7 @@ class PhoneNumber implements \Serializable * * @var int|null */ - private $countryCode = null; + protected $countryCode = null; /** * National (significant) Number is defined in International Telecommunication Union (ITU) * Recommendation E.164. It is a language/country-neutral representation of a phone number at a @@ -22,7 +22,7 @@ class PhoneNumber implements \Serializable * * @var string|null */ - private $nationalNumber = null; + protected $nationalNumber = null; /** * Extension is not standardized in ITU recommendations, except for being defined as a series of * numbers with a maximum length of 40 digits. It is defined as a string here to accommodate for the @@ -31,7 +31,7 @@ class PhoneNumber implements \Serializable * * @var string|null */ - private $extension = null; + protected $extension = null; /** * In some countries, the national (significant) number starts with one or more "0"s without this * being a national prefix or trunk code of some kind. For example, the leading zero in the national @@ -49,7 +49,7 @@ class PhoneNumber implements \Serializable * * @var bool|null */ - private $italianLeadingZero = null; + protected $italianLeadingZero = null; /** * This field is used to store the raw input string containing phone numbers before it was * canonicalized by the library. For example, it could be used to store alphanumerical numbers @@ -57,7 +57,7 @@ class PhoneNumber implements \Serializable * * @var string|null */ - private $rawInput = null; + protected $rawInput = null; /** * The source from which the country_code is derived. This is not set in the general parsing method, * but in the method that parses and keeps raw_input. New fields could be added upon request. @@ -68,7 +68,7 @@ class PhoneNumber implements \Serializable * * @var int|null */ - private $countryCodeSource = null; + protected $countryCodeSource = null; /** * The carrier selection code that is preferred when calling this phone number domestically. This * also includes codes that need to be dialed in some countries when calling from landlines to @@ -79,19 +79,19 @@ class PhoneNumber implements \Serializable * * @var string|null */ - private $preferredDomesticCarrierCode = null; + protected $preferredDomesticCarrierCode = null; /** * Whether this phone number has a number of leading zeros set. * * @var bool */ - private $hasNumberOfLeadingZeros = false; + protected $hasNumberOfLeadingZeros = false; /** * The number of leading zeros of this phone number. * * @var int */ - private $numberOfLeadingZeros = 1; + protected $numberOfLeadingZeros = 1; /** * Clears this phone number. diff --git a/src/libphonenumber/PhoneNumberDesc.php b/src/libphonenumber/PhoneNumberDesc.php index 491cef6c8..bc4aef6c0 100644 --- a/src/libphonenumber/PhoneNumberDesc.php +++ b/src/libphonenumber/PhoneNumberDesc.php @@ -7,12 +7,12 @@ */ class PhoneNumberDesc { - private $hasNationalNumberPattern = false; - private $nationalNumberPattern = ""; - private $hasPossibleNumberPattern = false; - private $possibleNumberPattern = ""; - private $hasExampleNumber = false; - private $exampleNumber = ""; + protected $hasNationalNumberPattern = false; + protected $nationalNumberPattern = ""; + protected $hasPossibleNumberPattern = false; + protected $possibleNumberPattern = ""; + protected $hasExampleNumber = false; + protected $exampleNumber = ""; /** * @return boolean diff --git a/src/libphonenumber/PhoneNumberToCarrierMapper.php b/src/libphonenumber/PhoneNumberToCarrierMapper.php index a2ceb288e..236bd4790 100644 --- a/src/libphonenumber/PhoneNumberToCarrierMapper.php +++ b/src/libphonenumber/PhoneNumberToCarrierMapper.php @@ -17,20 +17,20 @@ class PhoneNumberToCarrierMapper /** * @var PhoneNumberToCarrierMapper[] */ - private static $instance = array(); + protected static $instance = array(); const MAPPING_DATA_DIRECTORY = '/carrier/data/'; /** * @var PhoneNumberUtil */ - private $phoneUtil; + protected $phoneUtil; /** * @var PrefixFileReader */ - private $prefixFileReader; + protected $prefixFileReader; - private function __construct($phonePrefixDataDirectory) + protected function __construct($phonePrefixDataDirectory) { if(!extension_loaded('intl')) { throw new \RuntimeException('The intl extension must be installed'); @@ -125,7 +125,7 @@ public function getSafeDisplayName(PhoneNumber $number, $languageCode) * @param int $numberType A PhoneNumberType int * @return bool */ - private function isMobile($numberType) + protected function isMobile($numberType) { return ($numberType === PhoneNumberType::MOBILE || $numberType === PhoneNumberType::FIXED_LINE_OR_MOBILE || diff --git a/src/libphonenumber/PhoneNumberToTimeZonesMapper.php b/src/libphonenumber/PhoneNumberToTimeZonesMapper.php index 78fb9fe2e..aa674170d 100644 --- a/src/libphonenumber/PhoneNumberToTimeZonesMapper.php +++ b/src/libphonenumber/PhoneNumberToTimeZonesMapper.php @@ -18,15 +18,15 @@ class PhoneNumberToTimeZonesMapper /** * @var PhoneNumberToTimeZonesMapper */ - private static $instance = null; - private $unknownTimeZoneList = array(); + protected static $instance = null; + protected $unknownTimeZoneList = array(); /** * @var PhoneNumberUtil */ - private $phoneUtil; - private $prefixTimeZonesMap; + protected $phoneUtil; + protected $prefixTimeZonesMap; - private function __construct($phonePrefixDataDirectory) + protected function __construct($phonePrefixDataDirectory) { $this->prefixTimeZonesMap = self::loadPrefixTimeZonesMapFromFile( dirname(__FILE__) . $phonePrefixDataDirectory . DIRECTORY_SEPARATOR . self::MAPPING_DATA_FILE_NAME @@ -36,7 +36,7 @@ private function __construct($phonePrefixDataDirectory) $this->unknownTimeZoneList[] = self::UNKNOWN_TIMEZONE; } - private static function loadPrefixTimeZonesMapFromFile($path) + protected static function loadPrefixTimeZonesMapFromFile($path) { if (!is_readable($path)) { throw new \InvalidArgumentException("Mapping file can not be found"); @@ -121,7 +121,7 @@ public function canBeGeocoded($numberType) * @return array the list of corresponding time zones or a single element list with the default * unknown time zone if no other time zone was found */ - private function getCountryLevelTimeZonesforNumber(PhoneNumber $number) + protected function getCountryLevelTimeZonesforNumber(PhoneNumber $number) { $timezones = $this->prefixTimeZonesMap->lookupCountryLevelTimeZonesForNumber($number); return (count($timezones) == 0) ? $this->unknownTimeZoneList : $timezones; @@ -150,7 +150,7 @@ public function getTimeZonesForGeographicalNumber(PhoneNumber $number) * @return array the list of correspondiing time zones or a single element list with the default * unknown timezone if no other time zone was found or if the number was invalid */ - private function getTimeZonesForGeocodableNumber(PhoneNumber $number) + protected function getTimeZonesForGeocodableNumber(PhoneNumber $number) { $timezones = $this->prefixTimeZonesMap->lookupTimeZonesForNumber($number); return (count($timezones) == 0) ? $this->unknownTimeZoneList : $timezones; diff --git a/src/libphonenumber/PhoneNumberUtil.php b/src/libphonenumber/PhoneNumberUtil.php index 1bad4542a..7e2577afe 100644 --- a/src/libphonenumber/PhoneNumberUtil.php +++ b/src/libphonenumber/PhoneNumberUtil.php @@ -102,24 +102,24 @@ class PhoneNumberUtil // for unbalanced parentheses. const FIRST_GROUP_ONLY_PREFIX_PATTERN = '\\(?\\$1\\)?'; public static $PLUS_CHARS_PATTERN; - private static $SEPARATOR_PATTERN; - private static $CAPTURING_DIGIT_PATTERN; - private static $VALID_START_CHAR_PATTERN = null; - private static $SECOND_NUMBER_START_PATTERN = "[\\\\/] *x"; - private static $UNWANTED_END_CHAR_PATTERN = "[[\\P{N}&&\\P{L}]&&[^#]]+$"; - private static $DIALLABLE_CHAR_MAPPINGS = array(); - private static $CAPTURING_EXTN_DIGITS; + protected static $SEPARATOR_PATTERN; + protected static $CAPTURING_DIGIT_PATTERN; + protected static $VALID_START_CHAR_PATTERN = null; + protected static $SECOND_NUMBER_START_PATTERN = "[\\\\/] *x"; + protected static $UNWANTED_END_CHAR_PATTERN = "[[\\P{N}&&\\P{L}]&&[^#]]+$"; + protected static $DIALLABLE_CHAR_MAPPINGS = array(); + protected static $CAPTURING_EXTN_DIGITS; /** * @var PhoneNumberUtil */ - private static $instance = null; + protected static $instance = null; /** * Only upper-case variants of alpha characters are stored. * @var array */ - private static $ALPHA_MAPPINGS = array( + protected static $ALPHA_MAPPINGS = array( 'A' => '2', 'B' => '2', 'C' => '2', @@ -154,7 +154,7 @@ class PhoneNumberUtil * be the length of the area code plus the length of the mobile token. * @var array */ - private static $MOBILE_TOKEN_MAPPINGS; + protected static $MOBILE_TOKEN_MAPPINGS; /** * Set of country calling codes that have geographically assigned mobile numbers. This may not be @@ -163,27 +163,27 @@ class PhoneNumberUtil * * @var array */ - private static $GEO_MOBILE_COUNTRIES; + protected static $GEO_MOBILE_COUNTRIES; /** * For performance reasons, amalgamate both into one map. * @var array */ - private static $ALPHA_PHONE_MAPPINGS; + protected static $ALPHA_PHONE_MAPPINGS; /** * Separate map of all symbols that we wish to retain when formatting alpha numbers. This * includes digits, ASCII letters and number grouping symbols such as "-" and " ". * @var array */ - private static $ALL_PLUS_NUMBER_GROUPING_SYMBOLS; + protected static $ALL_PLUS_NUMBER_GROUPING_SYMBOLS; /** * Simple ASCII digits map used to populate ALPHA_PHONE_MAPPINGS and * ALL_PLUS_NUMBER_GROUPING_SYMBOLS. * @var array */ - private static $asciiDigitMappings = array( + protected static $asciiDigitMappings = array( '0' => '0', '1' => '1', '2' => '2', @@ -202,10 +202,10 @@ class PhoneNumberUtil * version. * @var String */ - private static $EXTN_PATTERNS_FOR_PARSING; - private static $EXTN_PATTERN = null; - private static $VALID_PHONE_NUMBER_PATTERN; - private static $MIN_LENGTH_PHONE_NUMBER_PATTERN; + protected static $EXTN_PATTERNS_FOR_PARSING; + protected static $EXTN_PATTERN = null; + protected static $VALID_PHONE_NUMBER_PATTERN; + protected static $MIN_LENGTH_PHONE_NUMBER_PATTERN; /** * Regular expression of viable phone numbers. This is location independent. Checks we have at * least three leading digits, and only valid punctuation, alpha characters and @@ -225,8 +225,8 @@ class PhoneNumberUtil * Note VALID_PUNCTUATION starts with a -, so must be the first in the range. * @var string */ - private static $VALID_PHONE_NUMBER; - private static $numericCharacters = array( + protected static $VALID_PHONE_NUMBER; + protected static $numericCharacters = array( "\xef\xbc\x90" => 0, "\xef\xbc\x91" => 1, "\xef\xbc\x92" => 2, @@ -276,12 +276,12 @@ class PhoneNumberUtil * The set of county calling codes that map to the non-geo entity region ("001"). * @var array */ - private $countryCodesForNonGeographicalRegion = array(); + protected $countryCodesForNonGeographicalRegion = array(); /** * The set of regions the library supports. * @var array */ - private $supportedRegions = array(); + protected $supportedRegions = array(); /** * A mapping from a country calling code to the region codes which denote the region represented @@ -290,24 +290,24 @@ class PhoneNumberUtil * first. * @var array */ - private $countryCallingCodeToRegionCodeMap = array(); + protected $countryCallingCodeToRegionCodeMap = array(); /** * The set of regions that share country calling code 1. * @var array */ - private $nanpaRegions = array(); + protected $nanpaRegions = array(); /** * @var MetadataSourceInterface */ - private $metadataSource; + protected $metadataSource; /** - * This class implements a singleton, so the only constructor is private. + * This class implements a singleton, so the only constructor is protected. * @param MetadataSourceInterface $metadataSource * @param $countryCallingCodeToRegionCodeMap */ - private function __construct(MetadataSourceInterface $metadataSource, $countryCallingCodeToRegionCodeMap) + protected function __construct(MetadataSourceInterface $metadataSource, $countryCallingCodeToRegionCodeMap) { $this->metadataSource = $metadataSource; $this->countryCallingCodeToRegionCodeMap = $countryCallingCodeToRegionCodeMap; @@ -401,7 +401,7 @@ public static function getInstance($baseFileLocation = self::META_DATA_FILE_PREF return self::$instance; } - private function init() + protected function init() { foreach ($this->countryCallingCodeToRegionCodeMap as $countryCode => $regionCodes) { // We can assume that if the country calling code maps to the non-geo entity region code then @@ -424,12 +424,12 @@ private function init() $this->nanpaRegions = $this->countryCallingCodeToRegionCodeMap[self::NANPA_COUNTRY_CODE]; } - private static function initCapturingExtnDigits() + protected static function initCapturingExtnDigits() { self::$CAPTURING_EXTN_DIGITS = "(" . self::DIGITS . "{1,7})"; } - private static function initExtnPatterns() + protected static function initExtnPatterns() { // One-character symbols that can be used to indicate an extension. $singleExtnSymbolsForMatching = "x\xEF\xBD\x98#\xEF\xBC\x83~\xEF\xBD\x9E"; @@ -452,7 +452,7 @@ private static function initExtnPatterns() * @param string $singleExtnSymbols * @return string */ - private static function createExtnPattern($singleExtnSymbols) + protected static function createExtnPattern($singleExtnSymbols) { // There are three regular expressions here. The first covers RFC 3966 format, where the // extension is added using ";ext=". The second more generic one starts with optional white @@ -471,7 +471,7 @@ private static function createExtnPattern($singleExtnSymbols) "[- ]+(" . self::DIGITS . "{1,5})#"); } - private static function initExtnPattern() + protected static function initExtnPattern() { self::$EXTN_PATTERN = "/(?:" . self::$EXTN_PATTERNS_FOR_PARSING . ")$/" . self::REGEX_FLAGS; } @@ -507,7 +507,7 @@ public static function convertAlphaCharactersInNumber($number) * should be stripped from the number. If this is false, they will be left unchanged in the number. * @return string the normalized string version of the phone number */ - private static function normalizeHelper($number, array $normalizationReplacements, $removeNonMatches) + protected static function normalizeHelper($number, array $normalizationReplacements, $removeNonMatches) { $normalizedNumber = ""; $strLength = mb_strlen($number, 'UTF-8'); @@ -633,7 +633,7 @@ public function getMetadataForRegion($regionCode) * @param string $regionCode * @return bool */ - private function isValidRegionCode($regionCode) + protected function isValidRegionCode($regionCode) { return $regionCode !== null && in_array($regionCode, $this->supportedRegions); } @@ -665,7 +665,7 @@ public function getRegionCodeForNumber(PhoneNumber $number) * @param array $regionCodes * @return null|string */ - private function getRegionCodeForNumberFromRegionList(PhoneNumber $number, array $regionCodes) + protected function getRegionCodeForNumberFromRegionList(PhoneNumber $number, array $regionCodes) { $nationalNumber = $this->getNationalSignificantNumber($number); foreach ($regionCodes as $regionCode) { @@ -713,7 +713,7 @@ public function getNationalSignificantNumber(PhoneNumber $number) * @param PhoneMetadata $metadata * @return int PhoneNumberType constant */ - private function getNumberTypeHelper($nationalNumber, PhoneMetadata $metadata) + protected function getNumberTypeHelper($nationalNumber, PhoneMetadata $metadata) { if (!$this->isNumberMatchingDesc($nationalNumber, $metadata->getGeneralDesc())) { return PhoneNumberType::UNKNOWN; @@ -784,7 +784,7 @@ public function isNumberMatchingDesc($nationalNumber, PhoneNumberDesc $numberDes * @param string $number * @return bool */ - private function isShorterThanPossibleNormalNumber(PhoneMetadata $regionMetadata, $number) + protected function isShorterThanPossibleNormalNumber(PhoneMetadata $regionMetadata, $number) { $possibleNumberPattern = $regionMetadata->getGeneralDesc()->getPossibleNumberPattern(); return ($this->testNumberLengthAgainstPattern($possibleNumberPattern, $number) === ValidationResult::TOO_SHORT); @@ -840,7 +840,7 @@ public function getNumberType(PhoneNumber $number) * @param string $regionCode * @return PhoneMetadata */ - private function getMetadataForRegionOrCallingCode($countryCallingCode, $regionCode) + protected function getMetadataForRegionOrCallingCode($countryCallingCode, $regionCode) { return self::REGION_CODE_FOR_NON_GEO_ENTITY === $regionCode ? $this->getMetadataForNonGeographicalRegion($countryCallingCode) : $this->getMetadataForRegion($regionCode); @@ -983,7 +983,7 @@ public function format(PhoneNumber $number, $numberFormat) * @param int $numberFormat PhoneNumberFormat * @param string $formattedNumber */ - private function prefixNumberWithCountryCallingCode($countryCallingCode, $numberFormat, &$formattedNumber) + protected function prefixNumberWithCountryCallingCode($countryCallingCode, $numberFormat, &$formattedNumber) { switch ($numberFormat) { case PhoneNumberFormat::E164: @@ -1006,7 +1006,7 @@ private function prefixNumberWithCountryCallingCode($countryCallingCode, $number * @param int $countryCallingCode * @return bool */ - private function hasValidCountryCallingCode($countryCallingCode) + protected function hasValidCountryCallingCode($countryCallingCode) { return isset($this->countryCallingCodeToRegionCodeMap[$countryCallingCode]); } @@ -1039,7 +1039,7 @@ public function getRegionCodeForCountryCode($countryCallingCode) * @param null|string $carrierCode * @return string */ - private function formatNsn($number, PhoneMetadata $metadata, $numberFormat, $carrierCode = null) + protected function formatNsn($number, PhoneMetadata $metadata, $numberFormat, $carrierCode = null) { $intlNumberFormats = $metadata->intlNumberFormats(); // When the intlNumberFormats exists, we use that to format national number for the @@ -1089,7 +1089,7 @@ public function chooseFormattingPatternForNumber(array $availableFormats, $natio * @param null|string $carrierCode * @return string */ - private function formatNsnUsingPattern( + protected function formatNsnUsingPattern( $nationalNumber, NumberFormat $formattingPattern, $numberFormat, @@ -1147,7 +1147,7 @@ private function formatNsnUsingPattern( * @param int $numberFormat PhoneNumberFormat * @param string $formattedNumber */ - private function maybeAppendFormattedExtension(PhoneNumber $number, $metadata, $numberFormat, &$formattedNumber) + protected function maybeAppendFormattedExtension(PhoneNumber $number, $metadata, $numberFormat, &$formattedNumber) { if ($number->hasExtension() && mb_strlen($number->getExtension()) > 0) { if ($numberFormat === PhoneNumberFormat::RFC3966) { @@ -1225,7 +1225,7 @@ public static function isViablePhoneNumber($number) * have an extension prefix appended, followed by 1 or more digits. * @return string */ - private static function getValidPhoneNumberPattern() + protected static function getValidPhoneNumberPattern() { return self::$VALID_PHONE_NUMBER_PATTERN; } @@ -1237,7 +1237,7 @@ private static function getValidPhoneNumberPattern() * @param string $number the non-normalized telephone number that we wish to strip the extension from * @return string the phone extension */ - private function maybeStripExtension(&$number) + protected function maybeStripExtension(&$number) { $matches = array(); $find = preg_match(self::$EXTN_PATTERN, $number, $matches, PREG_OFFSET_CAPTURE); @@ -1318,7 +1318,7 @@ public static function setItalianLeadingZerosForPhoneNumber($nationalNumber, Pho * @param PhoneNumber $phoneNumber * @throws NumberParseException */ - private function parseHelper($numberToParse, $defaultRegion, $keepRawInput, $checkRegion, PhoneNumber $phoneNumber) + protected function parseHelper($numberToParse, $defaultRegion, $keepRawInput, $checkRegion, PhoneNumber $phoneNumber) { if ($numberToParse === null) { throw new NumberParseException(NumberParseException::NOT_A_NUMBER, "The phone number supplied was null."); @@ -1475,7 +1475,7 @@ private function parseHelper($numberToParse, $defaultRegion, $keepRawInput, $che * @param string $numberToParse * @param string $nationalNumber */ - private function buildNationalNumberForParsing($numberToParse, &$nationalNumber) + protected function buildNationalNumberForParsing($numberToParse, &$nationalNumber) { $indexOfPhoneContext = strpos($numberToParse, self::RFC3966_PHONE_CONTEXT); if ($indexOfPhoneContext > 0) { @@ -1567,7 +1567,7 @@ public static function extractPossibleNumber($number) * @param string $defaultRegion * @return bool */ - private function checkRegionForParsing($numberToParse, $defaultRegion) + protected function checkRegionForParsing($numberToParse, $defaultRegion) { if (!$this->isValidRegionCode($defaultRegion)) { // If the number is null or empty, we can't infer the region. @@ -1798,7 +1798,7 @@ public static function normalizeDigits($number, $keepNonDigits) * @param string $number * @return bool */ - private function parsePrefixAsIdd($iddPattern, &$number) + protected function parsePrefixAsIdd($iddPattern, &$number) { $m = new Matcher($iddPattern, $number); if ($m->lookingAt()) { @@ -1826,7 +1826,7 @@ private function parsePrefixAsIdd($iddPattern, &$number) * @param string $nationalNumber * @return int */ - private function extractCountryCode(&$fullNumber, &$nationalNumber) + protected function extractCountryCode(&$fullNumber, &$nationalNumber) { if ((mb_strlen($fullNumber) == 0) || ($fullNumber[0] == '0')) { // Country codes do not begin with a '0'. @@ -1921,7 +1921,7 @@ public function maybeStripNationalPrefixAndCarrierCode(&$number, PhoneMetadata $ * @param string $number * @return int ValidationResult */ - private function testNumberLengthAgainstPattern($numberPattern, $number) + protected function testNumberLengthAgainstPattern($numberPattern, $number) { $numberMatcher = new Matcher($numberPattern, $number); if ($numberMatcher->matches()) { @@ -1970,7 +1970,7 @@ public function getCountryCodeForRegion($regionCode) * @return int the country calling code for the region denoted by regionCode * @throws \InvalidArgumentException if the region is invalid */ - private function getCountryCodeForValidRegion($regionCode) + protected function getCountryCodeForValidRegion($regionCode) { $metadata = $this->getMetadataForRegion($regionCode); if ($metadata === null) { @@ -2511,7 +2511,7 @@ public function formatInOriginalFormat(PhoneNumber $number, $regionCallingFrom) * @param PhoneNumber $number * @return bool */ - private function hasUnexpectedItalianLeadingZero(PhoneNumber $number) + protected function hasUnexpectedItalianLeadingZero(PhoneNumber $number) { return $number->isItalianLeadingZero() && !$this->isLeadingZeroPossible($number->getCountryCode()); } @@ -2539,7 +2539,7 @@ public function isLeadingZeroPossible($countryCallingCode) * @param PhoneNumber $number * @return bool */ - private function hasFormattingPatternForNumber(PhoneNumber $number) + protected function hasFormattingPatternForNumber(PhoneNumber $number) { $countryCallingCode = $number->getCountryCode(); $phoneNumberRegion = $this->getRegionCodeForCountryCode($countryCallingCode); @@ -2593,7 +2593,7 @@ public function getNddPrefixForRegion($regionCode, $stripNonDigits) * @param string $regionCode * @return bool */ - private function rawInputContainsNationalPrefix($rawInput, $nationalPrefix, $regionCode) + protected function rawInputContainsNationalPrefix($rawInput, $nationalPrefix, $regionCode) { $normalizedNationalNumber = $this->normalizeDigitsOnly($rawInput); if (strpos($normalizedNationalNumber, $nationalPrefix) === 0) { @@ -2885,7 +2885,7 @@ public function getExampleNumberForType($regionCodeOrType, $type = null) * @param int $type PhoneNumberType * @return PhoneNumberDesc */ - private function getNumberDescByType(PhoneMetadata $metadata, $type) + protected function getNumberDescByType(PhoneMetadata $metadata, $type) { switch ($type) { case PhoneNumberType::PREMIUM_RATE: @@ -3089,7 +3089,7 @@ public function isNumberMatch($firstNumberIn, $secondNumberIn) * @param PhoneNumber $secondNumber * @return bool */ - private function isNationalNumberSuffixOfTheOther(PhoneNumber $firstNumber, PhoneNumber $secondNumber) + protected function isNationalNumberSuffixOfTheOther(PhoneNumber $firstNumber, PhoneNumber $secondNumber) { $firstNumberNationalNumber = trim((string)$firstNumber->getNationalNumber()); $secondNumberNationalNumber = trim((string)$secondNumber->getNationalNumber()); @@ -3097,7 +3097,7 @@ private function isNationalNumberSuffixOfTheOther(PhoneNumber $firstNumber, Phon $this->stringEndsWithString($secondNumberNationalNumber, $firstNumberNationalNumber); } - private function stringEndsWithString($hayStack, $needle) + protected function stringEndsWithString($hayStack, $needle) { $revNeedle = strrev($needle); $revHayStack = strrev($hayStack); diff --git a/src/libphonenumber/ShortNumberInfo.php b/src/libphonenumber/ShortNumberInfo.php index 9a188d3af..d78775495 100644 --- a/src/libphonenumber/ShortNumberInfo.php +++ b/src/libphonenumber/ShortNumberInfo.php @@ -18,22 +18,22 @@ class ShortNumberInfo /** * @var ShortNumberInfo */ - private static $instance = null; + protected static $instance = null; /** * @var MatcherAPIInterface */ - private $matcherAPI; - private $currentFilePrefix; - private $regionToMetadataMap = array(); - private $countryCallingCodeToRegionCodeMap = array(); - private $countryCodeToNonGeographicalMetadataMap = array(); - private static $regionsWhereEmergencyNumbersMustBeExact = array( + protected $matcherAPI; + protected $currentFilePrefix; + protected $regionToMetadataMap = array(); + protected $countryCallingCodeToRegionCodeMap = array(); + protected $countryCodeToNonGeographicalMetadataMap = array(); + protected static $regionsWhereEmergencyNumbersMustBeExact = array( 'BR', 'CL', 'NI', ); - private function __construct(MatcherAPIInterface $matcherAPI) + protected function __construct(MatcherAPIInterface $matcherAPI) { $this->matcherAPI = $matcherAPI; @@ -73,7 +73,7 @@ public static function resetInstance() * @param int $countryCallingCode * @return array */ - private function getRegionCodesForCountryCode($countryCallingCode) + protected function getRegionCodesForCountryCode($countryCallingCode) { if (!array_key_exists($countryCallingCode, $this->countryCallingCodeToRegionCodeMap)) { $regionCodes = null; @@ -91,7 +91,7 @@ private function getRegionCodesForCountryCode($countryCallingCode) * @param string $regionDialingFrom * @return bool */ - private function regionDialingFromMatchesNumber(PhoneNumber $number, $regionDialingFrom) + protected function regionDialingFromMatchesNumber(PhoneNumber $number, $regionDialingFrom) { $regionCodes = $this->getRegionCodesForCountryCode($number->getCountryCode()); @@ -144,7 +144,7 @@ public function getMetadataForRegion($regionCode) return isset($this->regionToMetadataMap[$regionCode]) ? $this->regionToMetadataMap[$regionCode] : null; } - private function loadMetadataFromFile($filePrefix, $regionCode, $countryCallingCode) + protected function loadMetadataFromFile($filePrefix, $regionCode, $countryCallingCode) { $isNonGeoRegion = PhoneNumberUtil::REGION_CODE_FOR_NON_GEO_ENTITY === $regionCode; $fileName = $filePrefix . '_' . ($isNonGeoRegion ? $countryCallingCode : $regionCode) . '.php'; @@ -226,7 +226,7 @@ public function connectsToEmergencyNumber($number, $regionCode) * @param bool $allowPrefixMatch * @return bool */ - private function matchesEmergencyNumberHelper($number, $regionCode, $allowPrefixMatch) + protected function matchesEmergencyNumberHelper($number, $regionCode, $allowPrefixMatch) { $number = PhoneNumberUtil::extractPossibleNumber($number); $matcher = new Matcher(PhoneNumberUtil::$PLUS_CHARS_PATTERN, $number); @@ -284,7 +284,7 @@ public function isCarrierSpecific(PhoneNumber $number) * @param $regionCodes * @return String|null Region Code (or null if none are found) */ - private function getRegionCodeForShortNumberFromRegionList(PhoneNumber $number, $regionCodes) + protected function getRegionCodeForShortNumberFromRegionList(PhoneNumber $number, $regionCodes) { if (count($regionCodes) == 0) { return null; @@ -597,7 +597,7 @@ public function isEmergencyNumber($number, $regionCode) * @param PhoneNumber $number the phone number for which the national significant number is needed * @return string the national significant number of the PhoneNumber object passed in */ - private function getNationalSignificantNumber(PhoneNumber $number) + protected function getNationalSignificantNumber(PhoneNumber $number) { // If leading zero(s) have been set, we prefix this now. Note this is not a national prefix. $nationalNumber = ''; @@ -618,7 +618,7 @@ private function getNationalSignificantNumber(PhoneNumber $number) * @param PhoneNumberDesc $numberDesc * @return bool */ - private function matchesPossibleNumberAndNationalNumber($number, PhoneNumberDesc $numberDesc) + protected function matchesPossibleNumberAndNationalNumber($number, PhoneNumberDesc $numberDesc) { return ($this->matcherAPI->matchesPossibleNumber($number, $numberDesc) && $this->matcherAPI->matchesNationalNumber($number, $numberDesc, false)); diff --git a/src/libphonenumber/ShortNumberUtil.php b/src/libphonenumber/ShortNumberUtil.php index 559a7550d..d5c7d09de 100644 --- a/src/libphonenumber/ShortNumberUtil.php +++ b/src/libphonenumber/ShortNumberUtil.php @@ -20,7 +20,7 @@ class ShortNumberUtil /** * @var PhoneNumberUtil */ - private $phoneUtil; + protected $phoneUtil; public function __construct(PhoneNumberUtil $phoneNumberUtil = null) { diff --git a/src/libphonenumber/geocoding/PhoneNumberOfflineGeocoder.php b/src/libphonenumber/geocoding/PhoneNumberOfflineGeocoder.php index bcb2a0fee..9ba63a7e1 100644 --- a/src/libphonenumber/geocoding/PhoneNumberOfflineGeocoder.php +++ b/src/libphonenumber/geocoding/PhoneNumberOfflineGeocoder.php @@ -15,17 +15,17 @@ class PhoneNumberOfflineGeocoder /** * @var PhoneNumberOfflineGeocoder */ - private static $instance; + protected static $instance; /** * @var PhoneNumberUtil */ - private $phoneUtil; + protected $phoneUtil; /** * @var PrefixFileReader */ - private $prefixFileReader = null; + protected $prefixFileReader = null; - private function __construct($phonePrefixDataDirectory) + protected function __construct($phonePrefixDataDirectory) { if(!extension_loaded('intl')) { throw new \RuntimeException('The intl extension must be installed'); @@ -94,7 +94,7 @@ public function getDescriptionForNumber(PhoneNumber $number, $locale, $userRegio * @param int $numberType * @return boolean */ - private function canBeGeocoded($numberType) + protected function canBeGeocoded($numberType) { return ($numberType === PhoneNumberType::FIXED_LINE || $numberType === PhoneNumberType::MOBILE || $numberType === PhoneNumberType::FIXED_LINE_OR_MOBILE); } @@ -107,7 +107,7 @@ private function canBeGeocoded($numberType) * @param $locale * @return string */ - private function getCountryNameForNumber(PhoneNumber $number, $locale) + protected function getCountryNameForNumber(PhoneNumber $number, $locale) { $regionCodes = $this->phoneUtil->getRegionCodesForCountryCode($number->getCountryCode()); @@ -137,7 +137,7 @@ private function getCountryNameForNumber(PhoneNumber $number, $locale) * @param $locale * @return string */ - private function getRegionDisplayName($regionCode, $locale) + protected function getRegionDisplayName($regionCode, $locale) { if ($regionCode === null || $regionCode == 'ZZ' || $regionCode === PhoneNumberUtil::REGION_CODE_FOR_NON_GEO_ENTITY) { return ""; diff --git a/src/libphonenumber/prefixmapper/MappingFileProvider.php b/src/libphonenumber/prefixmapper/MappingFileProvider.php index f001835e8..2473115e2 100644 --- a/src/libphonenumber/prefixmapper/MappingFileProvider.php +++ b/src/libphonenumber/prefixmapper/MappingFileProvider.php @@ -13,7 +13,7 @@ class MappingFileProvider { - private $map; + protected $map; public function __construct($map) { @@ -38,7 +38,7 @@ public function getFileName($countryCallingCode, $language, $script, $region) return ""; } - private function inMap($language, $countryCallingCode) + protected function inMap($language, $countryCallingCode) { return (array_key_exists($language, $this->map) && in_array($countryCallingCode, $this->map[$language])); } diff --git a/src/libphonenumber/prefixmapper/PhonePrefixMap.php b/src/libphonenumber/prefixmapper/PhonePrefixMap.php index bf6bef5dc..6e12b00b2 100644 --- a/src/libphonenumber/prefixmapper/PhonePrefixMap.php +++ b/src/libphonenumber/prefixmapper/PhonePrefixMap.php @@ -16,11 +16,11 @@ */ class PhonePrefixMap { - private $phonePrefixMapStorage = array(); + protected $phonePrefixMapStorage = array(); /** * @var PhoneNumberUtil */ - private $phoneUtil; + protected $phoneUtil; public function __construct($map) { diff --git a/src/libphonenumber/prefixmapper/PrefixFileReader.php b/src/libphonenumber/prefixmapper/PrefixFileReader.php index 5382cba0c..c464d367f 100644 --- a/src/libphonenumber/prefixmapper/PrefixFileReader.php +++ b/src/libphonenumber/prefixmapper/PrefixFileReader.php @@ -11,19 +11,19 @@ */ class PrefixFileReader { - private $phonePrefixDataDirectory; + protected $phonePrefixDataDirectory; /** * The mappingFileProvider knows for which combination of countryCallingCode and language a phone * prefix mapping file is available in the file system, so that a file can be loaded when needed. * @var MappingFileProvider */ - private $mappingFileProvider; + protected $mappingFileProvider; /** * A mapping from countryCallingCode_lang to the corresponding phone prefix map that has been * loaded. * @var array */ - private $availablePhonePrefixMaps = array(); + protected $availablePhonePrefixMaps = array(); public function __construct($phonePrefixDataDirectory) { @@ -31,7 +31,7 @@ public function __construct($phonePrefixDataDirectory) $this->loadMappingFileProvider(); } - private function loadMappingFileProvider() + protected function loadMappingFileProvider() { $mapPath = $this->phonePrefixDataDirectory . DIRECTORY_SEPARATOR . "Map.php"; if (!file_exists($mapPath)) { @@ -65,7 +65,7 @@ public function getPhonePrefixDescriptions($prefixMapKey, $language, $script, $r return $this->availablePhonePrefixMaps[$fileName]; } - private function loadPhonePrefixMapFromFile($fileName) + protected function loadPhonePrefixMapFromFile($fileName) { $path = $this->phonePrefixDataDirectory . DIRECTORY_SEPARATOR . $fileName; if (!file_exists($path)) { diff --git a/src/libphonenumber/prefixmapper/PrefixTimeZonesMap.php b/src/libphonenumber/prefixmapper/PrefixTimeZonesMap.php index b3d4244e1..a7c8680d8 100644 --- a/src/libphonenumber/prefixmapper/PrefixTimeZonesMap.php +++ b/src/libphonenumber/prefixmapper/PrefixTimeZonesMap.php @@ -10,11 +10,11 @@ class PrefixTimeZonesMap { /* - private final PhonePrefixMap phonePrefixMap = new PhonePrefixMap(); - private static final String RAW_STRING_TIMEZONES_SEPARATOR = "&"; + protected final PhonePrefixMap phonePrefixMap = new PhonePrefixMap(); + protected static final String RAW_STRING_TIMEZONES_SEPARATOR = "&"; */ const RAW_STRING_TIMEZONES_SEPARATOR = "&"; - private $phonePrefixMap; + protected $phonePrefixMap; public function __construct($map) { @@ -48,7 +48,7 @@ public function lookupTimeZonesForNumber(PhoneNumber $number) * @param $key int the key to look up * @return array the list of corresponding time zones */ - private function lookupTimeZonesForNumberKey($key) + protected function lookupTimeZonesForNumberKey($key) { // Lookup in the map data. The returned String may consist of several time zones, so it must be // split. @@ -67,7 +67,7 @@ private function lookupTimeZonesForNumberKey($key) * @param $timezonesString String * @return array */ - private function tokenizeRawOutputString($timezonesString) + protected function tokenizeRawOutputString($timezonesString) { return explode(self::RAW_STRING_TIMEZONES_SEPARATOR, $timezonesString); } From 6ed0e7589145278b3c4c466b2c68dfa95a55243c Mon Sep 17 00:00:00 2001 From: Ilya Gusev Date: Tue, 26 Apr 2016 20:10:51 +0300 Subject: [PATCH 2/2] changed self:: to static:: for inheritance --- .../MultiFileMetadataSourceImpl.php | 2 +- .../PhoneNumberToCarrierMapper.php | 6 +- .../PhoneNumberToTimeZonesMapper.php | 14 +- src/libphonenumber/PhoneNumberUtil.php | 258 +++++++++--------- src/libphonenumber/ShortNumberInfo.php | 12 +- .../geocoding/PhoneNumberOfflineGeocoder.php | 8 +- .../prefixmapper/PrefixTimeZonesMap.php | 2 +- 7 files changed, 151 insertions(+), 151 deletions(-) diff --git a/src/libphonenumber/MultiFileMetadataSourceImpl.php b/src/libphonenumber/MultiFileMetadataSourceImpl.php index ebb240073..33cdb1d61 100644 --- a/src/libphonenumber/MultiFileMetadataSourceImpl.php +++ b/src/libphonenumber/MultiFileMetadataSourceImpl.php @@ -48,7 +48,7 @@ class MultiFileMetadataSourceImpl implements MetadataSourceInterface public function __construct(MetadataLoaderInterface $metadataLoader, $currentFilePrefix = null) { if ($currentFilePrefix === null) { - $currentFilePrefix = self::$metaDataFilePrefix; + $currentFilePrefix = static::$metaDataFilePrefix; } $this->currentFilePrefix = $currentFilePrefix; diff --git a/src/libphonenumber/PhoneNumberToCarrierMapper.php b/src/libphonenumber/PhoneNumberToCarrierMapper.php index 236bd4790..c775f6654 100644 --- a/src/libphonenumber/PhoneNumberToCarrierMapper.php +++ b/src/libphonenumber/PhoneNumberToCarrierMapper.php @@ -51,11 +51,11 @@ protected function __construct($phonePrefixDataDirectory) */ public static function getInstance($mappingDir = self::MAPPING_DATA_DIRECTORY) { - if (!array_key_exists($mappingDir, self::$instance)) { - self::$instance[$mappingDir] = new self($mappingDir); + if (!array_key_exists($mappingDir, static::$instance)) { + static::$instance[$mappingDir] = new static($mappingDir); } - return self::$instance[$mappingDir]; + return static::$instance[$mappingDir]; } /** diff --git a/src/libphonenumber/PhoneNumberToTimeZonesMapper.php b/src/libphonenumber/PhoneNumberToTimeZonesMapper.php index aa674170d..c169bdb82 100644 --- a/src/libphonenumber/PhoneNumberToTimeZonesMapper.php +++ b/src/libphonenumber/PhoneNumberToTimeZonesMapper.php @@ -28,12 +28,12 @@ class PhoneNumberToTimeZonesMapper protected function __construct($phonePrefixDataDirectory) { - $this->prefixTimeZonesMap = self::loadPrefixTimeZonesMapFromFile( - dirname(__FILE__) . $phonePrefixDataDirectory . DIRECTORY_SEPARATOR . self::MAPPING_DATA_FILE_NAME + $this->prefixTimeZonesMap = static::loadPrefixTimeZonesMapFromFile( + dirname(__FILE__) . $phonePrefixDataDirectory . DIRECTORY_SEPARATOR . static::MAPPING_DATA_FILE_NAME ); $this->phoneUtil = PhoneNumberUtil::getInstance(); - $this->unknownTimeZoneList[] = self::UNKNOWN_TIMEZONE; + $this->unknownTimeZoneList[] = static::UNKNOWN_TIMEZONE; } protected static function loadPrefixTimeZonesMapFromFile($path) @@ -60,11 +60,11 @@ protected static function loadPrefixTimeZonesMapFromFile($path) */ public static function getInstance($mappingDir = self::MAPPING_DATA_DIRECTORY) { - if (self::$instance === null) { - self::$instance = new self($mappingDir); + if (static::$instance === null) { + static::$instance = new static($mappingDir); } - return self::$instance; + return static::$instance; } /** @@ -73,7 +73,7 @@ public static function getInstance($mappingDir = self::MAPPING_DATA_DIRECTORY) */ public static function getUnknownTimeZone() { - return self::UNKNOWN_TIMEZONE; + return static::UNKNOWN_TIMEZONE; } /** diff --git a/src/libphonenumber/PhoneNumberUtil.php b/src/libphonenumber/PhoneNumberUtil.php index 7e2577afe..8b22bb739 100644 --- a/src/libphonenumber/PhoneNumberUtil.php +++ b/src/libphonenumber/PhoneNumberUtil.php @@ -312,59 +312,59 @@ protected function __construct(MetadataSourceInterface $metadataSource, $country $this->metadataSource = $metadataSource; $this->countryCallingCodeToRegionCodeMap = $countryCallingCodeToRegionCodeMap; $this->init(); - self::initCapturingExtnDigits(); - self::initExtnPatterns(); - self::initExtnPattern(); - self::$PLUS_CHARS_PATTERN = "[" . self::PLUS_CHARS . "]+"; - self::$SEPARATOR_PATTERN = "[" . self::VALID_PUNCTUATION . "]+"; - self::$CAPTURING_DIGIT_PATTERN = "(" . self::DIGITS . ")"; - self::$VALID_START_CHAR_PATTERN = "[" . self::PLUS_CHARS . self::DIGITS . "]"; + static::initCapturingExtnDigits(); + static::initExtnPatterns(); + static::initExtnPattern(); + static::$PLUS_CHARS_PATTERN = "[" . static::PLUS_CHARS . "]+"; + static::$SEPARATOR_PATTERN = "[" . static::VALID_PUNCTUATION . "]+"; + static::$CAPTURING_DIGIT_PATTERN = "(" . static::DIGITS . ")"; + static::$VALID_START_CHAR_PATTERN = "[" . static::PLUS_CHARS . static::DIGITS . "]"; - self::$ALPHA_PHONE_MAPPINGS = self::$ALPHA_MAPPINGS + self::$asciiDigitMappings; + static::$ALPHA_PHONE_MAPPINGS = static::$ALPHA_MAPPINGS + static::$asciiDigitMappings; - self::$DIALLABLE_CHAR_MAPPINGS = self::$asciiDigitMappings; - self::$DIALLABLE_CHAR_MAPPINGS[self::PLUS_SIGN] = self::PLUS_SIGN; - self::$DIALLABLE_CHAR_MAPPINGS['*'] = '*'; + static::$DIALLABLE_CHAR_MAPPINGS = static::$asciiDigitMappings; + static::$DIALLABLE_CHAR_MAPPINGS[static::PLUS_SIGN] = static::PLUS_SIGN; + static::$DIALLABLE_CHAR_MAPPINGS['*'] = '*'; - self::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS = array(); + static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS = array(); // Put (lower letter -> upper letter) and (upper letter -> upper letter) mappings. - foreach (self::$ALPHA_MAPPINGS as $c => $value) { - self::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS[strtolower($c)] = $c; - self::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS[$c] = $c; - } - self::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS += self::$asciiDigitMappings; - self::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["-"] = '-'; - self::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xEF\xBC\x8D"] = '-'; - self::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xE2\x80\x90"] = '-'; - self::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xE2\x80\x91"] = '-'; - self::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xE2\x80\x92"] = '-'; - self::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xE2\x80\x93"] = '-'; - self::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xE2\x80\x94"] = '-'; - self::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xE2\x80\x95"] = '-'; - self::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xE2\x88\x92"] = '-'; - self::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["/"] = "/"; - self::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xEF\xBC\x8F"] = "/"; - self::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS[" "] = " "; - self::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xE3\x80\x80"] = " "; - self::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xE2\x81\xA0"] = " "; - self::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["."] = "."; - self::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xEF\xBC\x8E"] = "."; - - - self::$MIN_LENGTH_PHONE_NUMBER_PATTERN = "[" . self::DIGITS . "]{" . self::MIN_LENGTH_FOR_NSN . "}"; - self::$VALID_PHONE_NUMBER = "[" . self::PLUS_CHARS . "]*(?:[" . self::VALID_PUNCTUATION . self::STAR_SIGN . "]*[" . self::DIGITS . "]){3,}[" . self::VALID_PUNCTUATION . self::STAR_SIGN . self::VALID_ALPHA . self::DIGITS . "]*"; - self::$VALID_PHONE_NUMBER_PATTERN = "%^" . self::$MIN_LENGTH_PHONE_NUMBER_PATTERN . "$|^" . self::$VALID_PHONE_NUMBER . "(?:" . self::$EXTN_PATTERNS_FOR_PARSING . ")?$%" . self::REGEX_FLAGS; - - self::$UNWANTED_END_CHAR_PATTERN = "[^" . self::DIGITS . self::VALID_ALPHA . "#]+$"; - - self::$MOBILE_TOKEN_MAPPINGS = array(); - self::$MOBILE_TOKEN_MAPPINGS['52'] = "1"; - self::$MOBILE_TOKEN_MAPPINGS['54'] = "9"; - - self::$GEO_MOBILE_COUNTRIES = array(); - self::$GEO_MOBILE_COUNTRIES[] = 52; // Mexico - self::$GEO_MOBILE_COUNTRIES[] = 54; // Argentina - self::$GEO_MOBILE_COUNTRIES[] = 55; // Brazil + foreach (static::$ALPHA_MAPPINGS as $c => $value) { + static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS[strtolower($c)] = $c; + static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS[$c] = $c; + } + static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS += static::$asciiDigitMappings; + static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["-"] = '-'; + static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xEF\xBC\x8D"] = '-'; + static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xE2\x80\x90"] = '-'; + static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xE2\x80\x91"] = '-'; + static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xE2\x80\x92"] = '-'; + static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xE2\x80\x93"] = '-'; + static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xE2\x80\x94"] = '-'; + static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xE2\x80\x95"] = '-'; + static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xE2\x88\x92"] = '-'; + static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["/"] = "/"; + static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xEF\xBC\x8F"] = "/"; + static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS[" "] = " "; + static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xE3\x80\x80"] = " "; + static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xE2\x81\xA0"] = " "; + static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["."] = "."; + static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS["\xEF\xBC\x8E"] = "."; + + + static::$MIN_LENGTH_PHONE_NUMBER_PATTERN = "[" . static::DIGITS . "]{" . static::MIN_LENGTH_FOR_NSN . "}"; + static::$VALID_PHONE_NUMBER = "[" . static::PLUS_CHARS . "]*(?:[" . static::VALID_PUNCTUATION . static::STAR_SIGN . "]*[" . static::DIGITS . "]){3,}[" . static::VALID_PUNCTUATION . static::STAR_SIGN . static::VALID_ALPHA . static::DIGITS . "]*"; + static::$VALID_PHONE_NUMBER_PATTERN = "%^" . static::$MIN_LENGTH_PHONE_NUMBER_PATTERN . "$|^" . static::$VALID_PHONE_NUMBER . "(?:" . static::$EXTN_PATTERNS_FOR_PARSING . ")?$%" . static::REGEX_FLAGS; + + static::$UNWANTED_END_CHAR_PATTERN = "[^" . static::DIGITS . static::VALID_ALPHA . "#]+$"; + + static::$MOBILE_TOKEN_MAPPINGS = array(); + static::$MOBILE_TOKEN_MAPPINGS['52'] = "1"; + static::$MOBILE_TOKEN_MAPPINGS['54'] = "9"; + + static::$GEO_MOBILE_COUNTRIES = array(); + static::$GEO_MOBILE_COUNTRIES[] = 52; // Mexico + static::$GEO_MOBILE_COUNTRIES[] = 54; // Argentina + static::$GEO_MOBILE_COUNTRIES[] = 55; // Brazil } /** @@ -383,7 +383,7 @@ protected function __construct(MetadataSourceInterface $metadataSource, $country */ public static function getInstance($baseFileLocation = self::META_DATA_FILE_PREFIX, array $countryCallingCodeToRegionCodeMap = null, MetadataLoaderInterface $metadataLoader = null, MetadataSourceInterface $metadataSource = null) { - if (self::$instance === null) { + if (static::$instance === null) { if ($countryCallingCodeToRegionCodeMap === null) { $countryCallingCodeToRegionCodeMap = CountryCodeToRegionCodeMap::$countryCodeToRegionCodeMap; } @@ -396,9 +396,9 @@ public static function getInstance($baseFileLocation = self::META_DATA_FILE_PREF $metadataSource = new MultiFileMetadataSourceImpl($metadataLoader, __DIR__ . '/data/' . $baseFileLocation); } - self::$instance = new PhoneNumberUtil($metadataSource, $countryCallingCodeToRegionCodeMap); + static::$instance = new PhoneNumberUtil($metadataSource, $countryCallingCodeToRegionCodeMap); } - return self::$instance; + return static::$instance; } protected function init() @@ -406,7 +406,7 @@ protected function init() foreach ($this->countryCallingCodeToRegionCodeMap as $countryCode => $regionCodes) { // We can assume that if the country calling code maps to the non-geo entity region code then // that's the only region code it maps to. - if (count($regionCodes) == 1 && self::REGION_CODE_FOR_NON_GEO_ENTITY === $regionCodes[0]) { + if (count($regionCodes) == 1 && static::REGION_CODE_FOR_NON_GEO_ENTITY === $regionCodes[0]) { // This is the subset of all country codes that map to the non-geo entity region code. $this->countryCodesForNonGeographicalRegion[] = $countryCode; } else { @@ -417,16 +417,16 @@ protected function init() // If the non-geo entity still got added to the set of supported regions it must be because // there are entries that list the non-geo entity alongside normal regions (which is wrong). // If we discover this, remove the non-geo entity from the set of supported regions and log. - $idx_region_code_non_geo_entity = array_search(self::REGION_CODE_FOR_NON_GEO_ENTITY, $this->supportedRegions); + $idx_region_code_non_geo_entity = array_search(static::REGION_CODE_FOR_NON_GEO_ENTITY, $this->supportedRegions); if ($idx_region_code_non_geo_entity !== false) { unset($this->supportedRegions[$idx_region_code_non_geo_entity]); } - $this->nanpaRegions = $this->countryCallingCodeToRegionCodeMap[self::NANPA_COUNTRY_CODE]; + $this->nanpaRegions = $this->countryCallingCodeToRegionCodeMap[static::NANPA_COUNTRY_CODE]; } protected static function initCapturingExtnDigits() { - self::$CAPTURING_EXTN_DIGITS = "(" . self::DIGITS . "{1,7})"; + static::$CAPTURING_EXTN_DIGITS = "(" . static::DIGITS . "{1,7})"; } protected static function initExtnPatterns() @@ -438,7 +438,7 @@ protected static function initExtnPatterns() // indicate this. $singleExtnSymbolsForParsing = "," . $singleExtnSymbolsForMatching; - self::$EXTN_PATTERNS_FOR_PARSING = self::createExtnPattern($singleExtnSymbolsForParsing); + static::$EXTN_PATTERNS_FOR_PARSING = static::createExtnPattern($singleExtnSymbolsForParsing); } // The FIRST_GROUP_PATTERN was originally set to $1 but there are some countries for which the @@ -464,16 +464,16 @@ protected static function createExtnPattern($singleExtnSymbols) // Canonical-equivalence doesn't seem to be an option with Android java, so we allow two options // for representing the accented o - the character itself, and one in the unicode decomposed // form with the combining acute accent. - return (self::RFC3966_EXTN_PREFIX . self::$CAPTURING_EXTN_DIGITS . "|" . "[ \xC2\xA0\\t,]*" . + return (static::RFC3966_EXTN_PREFIX . static::$CAPTURING_EXTN_DIGITS . "|" . "[ \xC2\xA0\\t,]*" . "(?:e?xt(?:ensi(?:o\xCC\x81?|\xC3\xB3))?n?|(?:\xEF\xBD\x85)?\xEF\xBD\x98\xEF\xBD\x94(?:\xEF\xBD\x8E)?|" . "[" . $singleExtnSymbols . "]|int|\xEF\xBD\x89\xEF\xBD\x8E\xEF\xBD\x94|anexo)" . - "[:\\.\xEF\xBC\x8E]?[ \xC2\xA0\\t,-]*" . self::$CAPTURING_EXTN_DIGITS . "#?|" . - "[- ]+(" . self::DIGITS . "{1,5})#"); + "[:\\.\xEF\xBC\x8E]?[ \xC2\xA0\\t,-]*" . static::$CAPTURING_EXTN_DIGITS . "#?|" . + "[- ]+(" . static::DIGITS . "{1,5})#"); } protected static function initExtnPattern() { - self::$EXTN_PATTERN = "/(?:" . self::$EXTN_PATTERNS_FOR_PARSING . ")$/" . self::REGEX_FLAGS; + static::$EXTN_PATTERN = "/(?:" . static::$EXTN_PATTERNS_FOR_PARSING . ")$/" . static::REGEX_FLAGS; } /** @@ -481,7 +481,7 @@ protected static function initExtnPattern() */ public static function resetInstance() { - self::$instance = null; + static::$instance = null; } /** @@ -492,7 +492,7 @@ public static function resetInstance() */ public static function convertAlphaCharactersInNumber($number) { - return self::normalizeHelper($number, self::$ALPHA_PHONE_MAPPINGS, false); + return static::normalizeHelper($number, static::$ALPHA_PHONE_MAPPINGS, false); } /** @@ -533,7 +533,7 @@ protected static function normalizeHelper($number, array $normalizationReplaceme */ public static function formattingRuleHasFirstGroupOnly($nationalPrefixFormattingRule) { - $m = preg_match(self::FIRST_GROUP_ONLY_PREFIX_PATTERN, $nationalPrefixFormattingRule); + $m = preg_match(static::FIRST_GROUP_ONLY_PREFIX_PATTERN, $nationalPrefixFormattingRule); return $m > 0; } @@ -815,7 +815,7 @@ public function isNumberGeographical(PhoneNumber $phoneNumber) return $numberType == PhoneNumberType::FIXED_LINE || $numberType == PhoneNumberType::FIXED_LINE_OR_MOBILE - || (in_array($phoneNumber->getCountryCode(), self::$GEO_MOBILE_COUNTRIES) + || (in_array($phoneNumber->getCountryCode(), static::$GEO_MOBILE_COUNTRIES) && $numberType == PhoneNumberType::MOBILE); } @@ -842,7 +842,7 @@ public function getNumberType(PhoneNumber $number) */ protected function getMetadataForRegionOrCallingCode($countryCallingCode, $regionCode) { - return self::REGION_CODE_FOR_NON_GEO_ENTITY === $regionCode ? + return static::REGION_CODE_FOR_NON_GEO_ENTITY === $regionCode ? $this->getMetadataForNonGeographicalRegion($countryCallingCode) : $this->getMetadataForRegion($regionCode); } @@ -900,7 +900,7 @@ public function getLengthOfNationalDestinationCode(PhoneNumber $number) $nationalSignificantNumber = $this->format($copiedProto, PhoneNumberFormat::INTERNATIONAL); - $numberGroups = preg_split('/' . self::NON_DIGITS_PATTERN . '/', $nationalSignificantNumber); + $numberGroups = preg_split('/' . static::NON_DIGITS_PATTERN . '/', $nationalSignificantNumber); // The pattern will start with "+COUNTRY_CODE " so the first group will always be the empty // string (before the + symbol) and the second group will be the country calling code. The third @@ -916,7 +916,7 @@ public function getLengthOfNationalDestinationCode(PhoneNumber $number) // the national significant number. This assumes that the mobile token is always formatted // separately from the rest of the phone number. - $mobileToken = self::getCountryMobileToken($number->getCountryCode()); + $mobileToken = static::getCountryMobileToken($number->getCountryCode()); if ($mobileToken !== "") { return mb_strlen($numberGroups[2]) + mb_strlen($numberGroups[3]); } @@ -987,13 +987,13 @@ protected function prefixNumberWithCountryCallingCode($countryCallingCode, $numb { switch ($numberFormat) { case PhoneNumberFormat::E164: - $formattedNumber = self::PLUS_SIGN . $countryCallingCode . $formattedNumber; + $formattedNumber = static::PLUS_SIGN . $countryCallingCode . $formattedNumber; return; case PhoneNumberFormat::INTERNATIONAL: - $formattedNumber = self::PLUS_SIGN . $countryCallingCode . " " . $formattedNumber; + $formattedNumber = static::PLUS_SIGN . $countryCallingCode . " " . $formattedNumber; return; case PhoneNumberFormat::RFC3966: - $formattedNumber = self::RFC3966_PREFIX . self::PLUS_SIGN . $countryCallingCode . "-" . $formattedNumber; + $formattedNumber = static::RFC3966_PREFIX . static::PLUS_SIGN . $countryCallingCode . "-" . $formattedNumber; return; case PhoneNumberFormat::NATIONAL: default: @@ -1025,7 +1025,7 @@ protected function hasValidCountryCallingCode($countryCallingCode) public function getRegionCodeForCountryCode($countryCallingCode) { $regionCodes = isset($this->countryCallingCodeToRegionCodeMap[$countryCallingCode]) ? $this->countryCallingCodeToRegionCodeMap[$countryCallingCode] : null; - return $regionCodes === null ? self::UNKNOWN_REGION : $regionCodes[0]; + return $regionCodes === null ? static::UNKNOWN_REGION : $regionCodes[0]; } /** @@ -1103,11 +1103,11 @@ protected function formatNsnUsingPattern( ) { // Replace the $CC in the formatting rule with the desired carrier code. $carrierCodeFormattingRule = $formattingPattern->getDomesticCarrierCodeFormattingRule(); - $ccPatternMatcher = new Matcher(self::CC_PATTERN, $carrierCodeFormattingRule); + $ccPatternMatcher = new Matcher(static::CC_PATTERN, $carrierCodeFormattingRule); $carrierCodeFormattingRule = $ccPatternMatcher->replaceFirst($carrierCode); // Now replace the $FG in the formatting rule with the first group and the carrier code // combined in the appropriate way. - $firstGroupMatcher = new Matcher(self::FIRST_GROUP_PATTERN, $numberFormatRule); + $firstGroupMatcher = new Matcher(static::FIRST_GROUP_PATTERN, $numberFormatRule); $numberFormatRule = $firstGroupMatcher->replaceFirst($carrierCodeFormattingRule); $formattedNationalNumber = $m->replaceAll($numberFormatRule); } else { @@ -1117,7 +1117,7 @@ protected function formatNsnUsingPattern( $nationalPrefixFormattingRule !== null && mb_strlen($nationalPrefixFormattingRule) > 0 ) { - $firstGroupMatcher = new Matcher(self::FIRST_GROUP_PATTERN, $numberFormatRule); + $firstGroupMatcher = new Matcher(static::FIRST_GROUP_PATTERN, $numberFormatRule); $formattedNationalNumber = $m->replaceAll( $firstGroupMatcher->replaceFirst($nationalPrefixFormattingRule) ); @@ -1128,7 +1128,7 @@ protected function formatNsnUsingPattern( } if ($numberFormat == PhoneNumberFormat::RFC3966) { // Strip any leading punctuation. - $matcher = new Matcher(self::$SEPARATOR_PATTERN, $formattedNationalNumber); + $matcher = new Matcher(static::$SEPARATOR_PATTERN, $formattedNationalNumber); if ($matcher->lookingAt()) { $formattedNationalNumber = $matcher->replaceFirst(""); } @@ -1151,12 +1151,12 @@ protected function maybeAppendFormattedExtension(PhoneNumber $number, $metadata, { if ($number->hasExtension() && mb_strlen($number->getExtension()) > 0) { if ($numberFormat === PhoneNumberFormat::RFC3966) { - $formattedNumber .= self::RFC3966_EXTN_PREFIX . $number->getExtension(); + $formattedNumber .= static::RFC3966_EXTN_PREFIX . $number->getExtension(); } else { if (!empty($metadata) && $metadata->hasPreferredExtnPrefix()) { $formattedNumber .= $metadata->getPreferredExtnPrefix() . $number->getExtension(); } else { - $formattedNumber .= self::DEFAULT_EXTN_PREFIX . $number->getExtension(); + $formattedNumber .= static::DEFAULT_EXTN_PREFIX . $number->getExtension(); } } } @@ -1172,8 +1172,8 @@ protected function maybeAppendFormattedExtension(PhoneNumber $number, $metadata, */ public static function getCountryMobileToken($countryCallingCode) { - if (array_key_exists($countryCallingCode, self::$MOBILE_TOKEN_MAPPINGS)) { - return self::$MOBILE_TOKEN_MAPPINGS[$countryCallingCode]; + if (array_key_exists($countryCallingCode, static::$MOBILE_TOKEN_MAPPINGS)) { + return static::$MOBILE_TOKEN_MAPPINGS[$countryCallingCode]; } return ""; } @@ -1195,7 +1195,7 @@ public function isAlphaNumber($number) return false; } $this->maybeStripExtension($number); - return (bool)preg_match('/' . self::VALID_ALPHA_PHONE_PATTERN . '/' . self::REGEX_FLAGS, $number); + return (bool)preg_match('/' . static::VALID_ALPHA_PHONE_PATTERN . '/' . static::REGEX_FLAGS, $number); } /** @@ -1210,11 +1210,11 @@ public function isAlphaNumber($number) */ public static function isViablePhoneNumber($number) { - if (mb_strlen($number) < self::MIN_LENGTH_FOR_NSN) { + if (mb_strlen($number) < static::MIN_LENGTH_FOR_NSN) { return false; } - $validPhoneNumberPattern = self::getValidPhoneNumberPattern(); + $validPhoneNumberPattern = static::getValidPhoneNumberPattern(); $m = preg_match($validPhoneNumberPattern, $number); return $m > 0; @@ -1227,7 +1227,7 @@ public static function isViablePhoneNumber($number) */ protected static function getValidPhoneNumberPattern() { - return self::$VALID_PHONE_NUMBER_PATTERN; + return static::$VALID_PHONE_NUMBER_PATTERN; } /** @@ -1240,7 +1240,7 @@ protected static function getValidPhoneNumberPattern() protected function maybeStripExtension(&$number) { $matches = array(); - $find = preg_match(self::$EXTN_PATTERN, $number, $matches, PREG_OFFSET_CAPTURE); + $find = preg_match(static::$EXTN_PATTERN, $number, $matches, PREG_OFFSET_CAPTURE); // If we find a potential extension, and the number preceding this is a viable number, we assume // it is an extension. if ($find > 0 && $this->isViablePhoneNumber(substr($number, 0, $matches[0][1]))) { @@ -1326,7 +1326,7 @@ protected function parseHelper($numberToParse, $defaultRegion, $keepRawInput, $c $numberToParse = trim($numberToParse); - if (mb_strlen($numberToParse) > self::MAX_INPUT_STRING_LENGTH) { + if (mb_strlen($numberToParse) > static::MAX_INPUT_STRING_LENGTH) { throw new NumberParseException( NumberParseException::TOO_LONG, "The string supplied was too long to parse." @@ -1378,7 +1378,7 @@ protected function parseHelper($numberToParse, $defaultRegion, $keepRawInput, $c $phoneNumber ); } catch (NumberParseException $e) { - $matcher = new Matcher(self::$PLUS_CHARS_PATTERN, $nationalNumber); + $matcher = new Matcher(static::$PLUS_CHARS_PATTERN, $nationalNumber); if ($e->getErrorType() == NumberParseException::INVALID_COUNTRY_CODE && $matcher->lookingAt()) { // Strip the plus-char, and try again. $countryCode = $this->maybeExtractCountryCode( @@ -1416,7 +1416,7 @@ protected function parseHelper($numberToParse, $defaultRegion, $keepRawInput, $c $phoneNumber->clearCountryCodeSource(); } } - if (mb_strlen($normalizedNationalNumber) < self::MIN_LENGTH_FOR_NSN) { + if (mb_strlen($normalizedNationalNumber) < static::MIN_LENGTH_FOR_NSN) { throw new NumberParseException( NumberParseException::TOO_SHORT_NSN, "The string supplied is too short to be a phone number." @@ -1437,13 +1437,13 @@ protected function parseHelper($numberToParse, $defaultRegion, $keepRawInput, $c } } $lengthOfNationalNumber = mb_strlen($normalizedNationalNumber); - if ($lengthOfNationalNumber < self::MIN_LENGTH_FOR_NSN) { + if ($lengthOfNationalNumber < static::MIN_LENGTH_FOR_NSN) { throw new NumberParseException( NumberParseException::TOO_SHORT_NSN, "The string supplied is too short to be a phone number." ); } - if ($lengthOfNationalNumber > self::MAX_LENGTH_FOR_NSN) { + if ($lengthOfNationalNumber > static::MAX_LENGTH_FOR_NSN) { throw new NumberParseException( NumberParseException::TOO_LONG, "The string supplied is too long to be a phone number." @@ -1477,12 +1477,12 @@ protected function parseHelper($numberToParse, $defaultRegion, $keepRawInput, $c */ protected function buildNationalNumberForParsing($numberToParse, &$nationalNumber) { - $indexOfPhoneContext = strpos($numberToParse, self::RFC3966_PHONE_CONTEXT); + $indexOfPhoneContext = strpos($numberToParse, static::RFC3966_PHONE_CONTEXT); if ($indexOfPhoneContext > 0) { - $phoneContextStart = $indexOfPhoneContext + mb_strlen(self::RFC3966_PHONE_CONTEXT); + $phoneContextStart = $indexOfPhoneContext + mb_strlen(static::RFC3966_PHONE_CONTEXT); // If the phone context contains a phone number prefix, we need to capture it, whereas domains // will be ignored. - if (substr($numberToParse, $phoneContextStart, 1) == self::PLUS_SIGN) { + if (substr($numberToParse, $phoneContextStart, 1) == static::PLUS_SIGN) { // Additional parameters might follow the phone context. If so, we will remove them here // because the parameters after phone context are not important for parsing the // phone number. @@ -1499,8 +1499,8 @@ protected function buildNationalNumberForParsing($numberToParse, &$nationalNumbe // handle the case when "tel:" is missing, as we have seen in some of the phone number inputs. // In that case, we append everything from the beginning. - $indexOfRfc3966Prefix = strpos($numberToParse, self::RFC3966_PREFIX); - $indexOfNationalNumber = ($indexOfRfc3966Prefix !== false) ? $indexOfRfc3966Prefix + strlen(self::RFC3966_PREFIX) : 0; + $indexOfRfc3966Prefix = strpos($numberToParse, static::RFC3966_PREFIX); + $indexOfNationalNumber = ($indexOfRfc3966Prefix !== false) ? $indexOfRfc3966Prefix + strlen(static::RFC3966_PREFIX) : 0; $nationalNumber .= substr($numberToParse, $indexOfNationalNumber, ($indexOfPhoneContext - $indexOfNationalNumber)); } else { // Extract a possible number from the string passed in (this strips leading characters that @@ -1510,7 +1510,7 @@ protected function buildNationalNumberForParsing($numberToParse, &$nationalNumbe // Delete the isdn-subaddress and everything after it if it is present. Note extension won't // appear at the same time with isdn-subaddress according to paragraph 5.3 of the RFC3966 spec, - $indexOfIsdn = strpos($nationalNumber, self::RFC3966_ISDN_SUBADDRESS); + $indexOfIsdn = strpos($nationalNumber, static::RFC3966_ISDN_SUBADDRESS); if ($indexOfIsdn > 0) { $nationalNumber = substr($nationalNumber, 0, $indexOfIsdn); } @@ -1538,17 +1538,17 @@ protected function buildNationalNumberForParsing($numberToParse, &$nationalNumbe public static function extractPossibleNumber($number) { $matches = array(); - $match = preg_match('/' . self::$VALID_START_CHAR_PATTERN . '/ui', $number, $matches, PREG_OFFSET_CAPTURE); + $match = preg_match('/' . static::$VALID_START_CHAR_PATTERN . '/ui', $number, $matches, PREG_OFFSET_CAPTURE); if ($match > 0) { $number = substr($number, $matches[0][1]); // Remove trailing non-alpha non-numerical characters. - $trailingCharsMatcher = new Matcher(self::$UNWANTED_END_CHAR_PATTERN, $number); + $trailingCharsMatcher = new Matcher(static::$UNWANTED_END_CHAR_PATTERN, $number); if ($trailingCharsMatcher->find() && $trailingCharsMatcher->start() > 0) { $number = substr($number, 0, $trailingCharsMatcher->start()); } // Check for extra numbers at the end. - $match = preg_match('%' . self::$SECOND_NUMBER_START_PATTERN . '%', $number, $matches, PREG_OFFSET_CAPTURE); + $match = preg_match('%' . static::$SECOND_NUMBER_START_PATTERN . '%', $number, $matches, PREG_OFFSET_CAPTURE); if ($match > 0) { $number = substr($number, 0, $matches[0][1]); } @@ -1571,7 +1571,7 @@ protected function checkRegionForParsing($numberToParse, $defaultRegion) { if (!$this->isValidRegionCode($defaultRegion)) { // If the number is null or empty, we can't infer the region. - $plusCharsPatternMatcher = new Matcher(self::$PLUS_CHARS_PATTERN, $numberToParse); + $plusCharsPatternMatcher = new Matcher(static::$PLUS_CHARS_PATTERN, $numberToParse); if ($numberToParse === null || mb_strlen($numberToParse) == 0 || !$plusCharsPatternMatcher->lookingAt()) { return false; } @@ -1633,7 +1633,7 @@ public function maybeExtractCountryCode( $phoneNumber->setCountryCodeSource($countryCodeSource); } if ($countryCodeSource != CountryCodeSource::FROM_DEFAULT_COUNTRY) { - if (mb_strlen($fullNumber) <= self::MIN_LENGTH_FOR_NSN) { + if (mb_strlen($fullNumber) <= static::MIN_LENGTH_FOR_NSN) { throw new NumberParseException( NumberParseException::TOO_SHORT_AFTER_IDD, "Phone number had an IDD, but after this was not long enough to be a viable phone number." @@ -1712,7 +1712,7 @@ public function maybeStripInternationalPrefixAndNormalize(&$number, $possibleIdd } $matches = array(); // Check to see if the number begins with one or more plus signs. - $match = preg_match('/^' . self::$PLUS_CHARS_PATTERN . '/' . self::REGEX_FLAGS, $number, $matches, PREG_OFFSET_CAPTURE); + $match = preg_match('/^' . static::$PLUS_CHARS_PATTERN . '/' . static::REGEX_FLAGS, $number, $matches, PREG_OFFSET_CAPTURE); if ($match > 0) { $number = mb_substr($number, $matches[0][1] + mb_strlen($matches[0][0])); // Can now normalize the rest of the number since we've consumed the "+" sign at the start. @@ -1746,11 +1746,11 @@ public function maybeStripInternationalPrefixAndNormalize(&$number, $possibleIdd */ public static function normalize(&$number) { - $m = new Matcher(self::VALID_ALPHA_PHONE_PATTERN, $number); + $m = new Matcher(static::VALID_ALPHA_PHONE_PATTERN, $number); if ($m->matches()) { - return self::normalizeHelper($number, self::$ALPHA_PHONE_MAPPINGS, true); + return static::normalizeHelper($number, static::$ALPHA_PHONE_MAPPINGS, true); } else { - return self::normalizeDigitsOnly($number); + return static::normalizeDigitsOnly($number); } } @@ -1763,7 +1763,7 @@ public static function normalize(&$number) */ public static function normalizeDigitsOnly($number) { - return self::normalizeDigits($number, false /* strip non-digits */); + return static::normalizeDigits($number, false /* strip non-digits */); } /** @@ -1784,8 +1784,8 @@ public static function normalizeDigits($number, $keepNonDigits) // If neither of the above are true, we remove this character. // Check if we are in the unicode number range - if (array_key_exists($character, self::$numericCharacters)) { - $normalizedDigits .= self::$numericCharacters[$character]; + if (array_key_exists($character, static::$numericCharacters)) { + $normalizedDigits .= static::$numericCharacters[$character]; } } return $normalizedDigits; @@ -1805,7 +1805,7 @@ protected function parsePrefixAsIdd($iddPattern, &$number) $matchEnd = $m->end(); // Only strip this if the first digit after the match is not a 0, since country calling codes // cannot begin with 0. - $digitMatcher = new Matcher(self::$CAPTURING_DIGIT_PATTERN, substr($number, $matchEnd)); + $digitMatcher = new Matcher(static::$CAPTURING_DIGIT_PATTERN, substr($number, $matchEnd)); if ($digitMatcher->find()) { $normalizedGroup = $this->normalizeDigitsOnly($digitMatcher->group(1)); if ($normalizedGroup == "0") { @@ -1833,7 +1833,7 @@ protected function extractCountryCode(&$fullNumber, &$nationalNumber) return 0; } $numberLength = mb_strlen($fullNumber); - for ($i = 1; $i <= self::MAX_LENGTH_COUNTRY_CODE && $i <= $numberLength; $i++) { + for ($i = 1; $i <= static::MAX_LENGTH_COUNTRY_CODE && $i <= $numberLength; $i++) { $potentialCountryCode = (int)substr($fullNumber, 0, $i); if (isset($this->countryCallingCodeToRegionCodeMap[$potentialCountryCode])) { $nationalNumber .= substr($fullNumber, $i); @@ -2011,7 +2011,7 @@ public function formatNumberForMobileDialing(PhoneNumber $number, $regionCalling if ($regionCode == "CO" && $numberType == PhoneNumberType::FIXED_LINE) { $formattedNumber = $this->formatNationalNumberWithCarrierCode( $numberNoExt, - self::COLOMBIA_MOBILE_TO_FIXED_LINE_PREFIX + static::COLOMBIA_MOBILE_TO_FIXED_LINE_PREFIX ); } elseif ($regionCode == "BR" && $isFixedLineOrMobile) { // Brazilian fixed line and mobile numbers need to be dialed with a carrier code when @@ -2028,7 +2028,7 @@ public function formatNumberForMobileDialing(PhoneNumber $number, $regionCalling $regionCode, true /* strip non-digits */ ) . " " . $this->format($numberNoExt, PhoneNumberFormat::NATIONAL); - } elseif ($countryCallingCode === self::NANPA_COUNTRY_CODE) { + } elseif ($countryCallingCode === static::NANPA_COUNTRY_CODE) { // For NANPA countries, we output international format for numbers that can be dialed // internationally, since that always works, except for numbers which might potentially be // short numbers, which are always dialled in national format. @@ -2047,7 +2047,7 @@ public function formatNumberForMobileDialing(PhoneNumber $number, $regionCalling // For non-geographical countries, Mexican and Chilean fixed line and mobile numbers, we // output international format for numbers that can be dialed internationally as that always // works. - if (($regionCode == self::REGION_CODE_FOR_NON_GEO_ENTITY || + if (($regionCode == static::REGION_CODE_FOR_NON_GEO_ENTITY || // MX fixed line and mobile numbers should always be formatted in international format, // even when dialed within MX. For national format to work, a carrier code needs to be // used, and the correct carrier code depends on if the caller and callee are from the @@ -2174,7 +2174,7 @@ public function canBeInternationallyDialled(PhoneNumber $number) */ public static function normalizeDiallableCharsOnly($number) { - return self::normalizeHelper($number, self::$DIALLABLE_CHAR_MAPPINGS, true /* remove non matches */); + return static::normalizeHelper($number, static::$DIALLABLE_CHAR_MAPPINGS, true /* remove non matches */); } /** @@ -2217,7 +2217,7 @@ public function formatOutOfCountryKeepingAlphaChars(PhoneNumber $number, $region // the number in raw_input with the parsed number. // To do this, first we normalize punctuation. We retain number grouping symbols such as " " // only. - $rawInput = $this->normalizeHelper($rawInput, self::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS, true); + $rawInput = $this->normalizeHelper($rawInput, static::$ALL_PLUS_NUMBER_GROUPING_SYMBOLS, true); // Now we trim everything before the first three digits in the parsed number. We choose three // because all valid alpha numbers have 3 digits at the start - if it does not, then we don't // trim anything at all. Similarly, if the national number was less than three digits, we don't @@ -2230,7 +2230,7 @@ public function formatOutOfCountryKeepingAlphaChars(PhoneNumber $number, $region } } $metadataForRegionCallingFrom = $this->getMetadataForRegion($regionCallingFrom); - if ($countryCode == self::NANPA_COUNTRY_CODE) { + if ($countryCode == static::NANPA_COUNTRY_CODE) { if ($this->isNANPACountry($regionCallingFrom)) { return $countryCode . " " . $rawInput; } @@ -2265,7 +2265,7 @@ public function formatOutOfCountryKeepingAlphaChars(PhoneNumber $number, $region // international prefix. if ($metadataForRegionCallingFrom !== null) { $internationalPrefix = $metadataForRegionCallingFrom->getInternationalPrefix(); - $uniqueInternationalPrefixMatcher = new Matcher(self::UNIQUE_INTERNATIONAL_PREFIX, $internationalPrefix); + $uniqueInternationalPrefixMatcher = new Matcher(static::UNIQUE_INTERNATIONAL_PREFIX, $internationalPrefix); $internationalPrefixForFormatting = $uniqueInternationalPrefixMatcher->matches() ? $internationalPrefix @@ -2322,7 +2322,7 @@ public function formatOutOfCountryCallingNumber(PhoneNumber $number, $regionCall if (!$this->hasValidCountryCallingCode($countryCallingCode)) { return $nationalSignificantNumber; } - if ($countryCallingCode == self::NANPA_COUNTRY_CODE) { + if ($countryCallingCode == static::NANPA_COUNTRY_CODE) { if ($this->isNANPACountry($regionCallingFrom)) { // For NANPA regions, return the national format for these regions but prefix it with the // country calling code. @@ -2345,7 +2345,7 @@ public function formatOutOfCountryCallingNumber(PhoneNumber $number, $regionCall // For regions that have multiple international prefixes, the international format of the // number is returned, unless there is a preferred international prefix. $internationalPrefixForFormatting = ""; - $uniqueInternationalPrefixMatcher = new Matcher(self::UNIQUE_INTERNATIONAL_PREFIX, $internationalPrefix); + $uniqueInternationalPrefixMatcher = new Matcher(static::UNIQUE_INTERNATIONAL_PREFIX, $internationalPrefix); if ($uniqueInternationalPrefixMatcher->matches()) { $internationalPrefixForFormatting = $internationalPrefix; @@ -2646,7 +2646,7 @@ public function isValidNumberForRegion(PhoneNumber $number, $regionCode) $countryCode = $number->getCountryCode(); $metadata = $this->getMetadataForRegionOrCallingCode($countryCode, $regionCode); if (($metadata === null) || - (self::REGION_CODE_FOR_NON_GEO_ENTITY !== $regionCode && + (static::REGION_CODE_FOR_NON_GEO_ENTITY !== $regionCode && $countryCode !== $this->getCountryCodeForValidRegion($regionCode)) ) { // Either the region code was invalid, or the country calling code for this number does not @@ -2738,9 +2738,9 @@ public function formatByPattern(PhoneNumber $number, $numberFormat, array $userD $nationalPrefix = $metadata->getNationalPrefix(); if (mb_strlen($nationalPrefix) > 0) { // Replace $NP with national prefix and $FG with the first group ($1). - $npPatternMatcher = new Matcher(self::NP_PATTERN, $nationalPrefixFormattingRule); + $npPatternMatcher = new Matcher(static::NP_PATTERN, $nationalPrefixFormattingRule); $nationalPrefixFormattingRule = $npPatternMatcher->replaceFirst($nationalPrefix); - $fgPatternMatcher = new Matcher(self::FG_PATTERN, $nationalPrefixFormattingRule); + $fgPatternMatcher = new Matcher(static::FG_PATTERN, $nationalPrefixFormattingRule); $nationalPrefixFormattingRule = $fgPatternMatcher->replaceFirst("\\$1"); $numFormatCopy->setNationalPrefixFormattingRule($nationalPrefixFormattingRule); } else { @@ -2810,7 +2810,7 @@ public function getInvalidExampleNumber($regionCode) // a mobile number. It would be faster to loop in a different order, but we prefer numbers that // look closer to real numbers (and it gives us a variety of different lengths for the resulting // phone numbers - otherwise they would all be MIN_LENGTH_FOR_NSN digits long.) - for ($phoneNumberLength = mb_strlen($exampleNumber) - 1; $phoneNumberLength >= self::MIN_LENGTH_FOR_NSN; $phoneNumberLength--) { + for ($phoneNumberLength = mb_strlen($exampleNumber) - 1; $phoneNumberLength >= static::MIN_LENGTH_FOR_NSN; $phoneNumberLength--) { $numberToTry = mb_substr($exampleNumber, 0, $phoneNumberLength); try { $possiblyValidNumber = $this->parse($numberToTry, $regionCode); @@ -2857,7 +2857,7 @@ public function getExampleNumberForType($regionCodeOrType, $type = null) $desc = $this->getNumberDescByType($this->getMetadataForNonGeographicalRegion($countryCallingCode), $regionCodeOrType); try { if ($desc->getExampleNumber() != '') { - return $this->parse("+" . $countryCallingCode . $desc->getExampleNumber(), self::UNKNOWN_REGION); + return $this->parse("+" . $countryCallingCode . $desc->getExampleNumber(), static::UNKNOWN_REGION); } } catch (NumberParseException $e) { } @@ -2929,7 +2929,7 @@ public function getExampleNumberForNonGeoEntity($countryCallingCode) $desc = $metadata->getGeneralDesc(); try { if ($desc->hasExampleNumber()) { - return $this->parse("+" . $countryCallingCode . $desc->getExampleNumber(), self::UNKNOWN_REGION); + return $this->parse("+" . $countryCallingCode . $desc->getExampleNumber(), static::UNKNOWN_REGION); } } catch (NumberParseException $e) { } @@ -2964,12 +2964,12 @@ public function isNumberMatch($firstNumberIn, $secondNumberIn) { if (is_string($firstNumberIn) && is_string($secondNumberIn)) { try { - $firstNumberAsProto = $this->parse($firstNumberIn, self::UNKNOWN_REGION); + $firstNumberAsProto = $this->parse($firstNumberIn, static::UNKNOWN_REGION); return $this->isNumberMatch($firstNumberAsProto, $secondNumberIn); } catch (NumberParseException $e) { if ($e->getErrorType() === NumberParseException::INVALID_COUNTRY_CODE) { try { - $secondNumberAsProto = $this->parse($secondNumberIn, self::UNKNOWN_REGION); + $secondNumberAsProto = $this->parse($secondNumberIn, static::UNKNOWN_REGION); return $this->isNumberMatch($secondNumberAsProto, $firstNumberIn); } catch (NumberParseException $e2) { if ($e2->getErrorType() === NumberParseException::INVALID_COUNTRY_CODE) { @@ -2992,7 +2992,7 @@ public function isNumberMatch($firstNumberIn, $secondNumberIn) // First see if the second number has an implicit country calling code, by attempting to parse // it. try { - $secondNumberAsProto = $this->parse($secondNumberIn, self::UNKNOWN_REGION); + $secondNumberAsProto = $this->parse($secondNumberIn, static::UNKNOWN_REGION); return $this->isNumberMatch($firstNumberIn, $secondNumberAsProto); } catch (NumberParseException $e) { if ($e->getErrorType() === NumberParseException::INVALID_COUNTRY_CODE) { @@ -3001,7 +3001,7 @@ public function isNumberMatch($firstNumberIn, $secondNumberIn) // EXACT_MATCH is returned, we replace this with NSN_MATCH. $firstNumberRegion = $this->getRegionCodeForCountryCode($firstNumberIn->getCountryCode()); try { - if ($firstNumberRegion != self::UNKNOWN_REGION) { + if ($firstNumberRegion != static::UNKNOWN_REGION) { $secondNumberWithFirstNumberRegion = $this->parse($secondNumberIn, $firstNumberRegion); $match = $this->isNumberMatch($firstNumberIn, $secondNumberWithFirstNumberRegion); if ($match === MatchType::EXACT_MATCH) { diff --git a/src/libphonenumber/ShortNumberInfo.php b/src/libphonenumber/ShortNumberInfo.php index d78775495..cf03208aa 100644 --- a/src/libphonenumber/ShortNumberInfo.php +++ b/src/libphonenumber/ShortNumberInfo.php @@ -40,7 +40,7 @@ protected function __construct(MatcherAPIInterface $matcherAPI) // TODO: Create ShortNumberInfo for a given map $this->countryCallingCodeToRegionCodeMap = CountryCodeToRegionCodeMap::$countryCodeToRegionCodeMap; - $this->currentFilePrefix = dirname(__FILE__) . '/data/' . self::META_DATA_FILE_PREFIX; + $this->currentFilePrefix = dirname(__FILE__) . '/data/' . static::META_DATA_FILE_PREFIX; // Initialise PhoneNumberUtil to make sure regex's are setup correctly PhoneNumberUtil::getInstance(); @@ -53,16 +53,16 @@ protected function __construct(MatcherAPIInterface $matcherAPI) */ public static function getInstance() { - if (null === self::$instance) { - self::$instance = new self(RegexBasedMatcher::create()); + if (null === static::$instance) { + static::$instance = new self(RegexBasedMatcher::create()); } - return self::$instance; + return static::$instance; } public static function resetInstance() { - self::$instance = null; + static::$instance = null; } /** @@ -246,7 +246,7 @@ protected function matchesEmergencyNumberHelper($number, $regionCode, $allowPref $emergencyDesc = $metadata->getEmergency(); $allowPrefixMatchForRegion = ($allowPrefixMatch - && !in_array($regionCode, self::$regionsWhereEmergencyNumbersMustBeExact) + && !in_array($regionCode, static::$regionsWhereEmergencyNumbersMustBeExact) ); return $this->matcherAPI->matchesNationalNumber($normalizedNumber, $emergencyDesc, $allowPrefixMatchForRegion); diff --git a/src/libphonenumber/geocoding/PhoneNumberOfflineGeocoder.php b/src/libphonenumber/geocoding/PhoneNumberOfflineGeocoder.php index 9ba63a7e1..7e77246dc 100644 --- a/src/libphonenumber/geocoding/PhoneNumberOfflineGeocoder.php +++ b/src/libphonenumber/geocoding/PhoneNumberOfflineGeocoder.php @@ -47,16 +47,16 @@ protected function __construct($phonePrefixDataDirectory) */ public static function getInstance($mappingDir = self::MAPPING_DATA_DIRECTORY) { - if (self::$instance === null) { - self::$instance = new self($mappingDir); + if (static::$instance === null) { + static::$instance = new static($mappingDir); } - return self::$instance; + return static::$instance; } public static function resetInstance() { - self::$instance = null; + static::$instance = null; } /** diff --git a/src/libphonenumber/prefixmapper/PrefixTimeZonesMap.php b/src/libphonenumber/prefixmapper/PrefixTimeZonesMap.php index a7c8680d8..e0a366780 100644 --- a/src/libphonenumber/prefixmapper/PrefixTimeZonesMap.php +++ b/src/libphonenumber/prefixmapper/PrefixTimeZonesMap.php @@ -69,7 +69,7 @@ protected function lookupTimeZonesForNumberKey($key) */ protected function tokenizeRawOutputString($timezonesString) { - return explode(self::RAW_STRING_TIMEZONES_SEPARATOR, $timezonesString); + return explode(static::RAW_STRING_TIMEZONES_SEPARATOR, $timezonesString); } /**