Skip to content

Commit

Permalink
Merge pull request #657 from giggsey/php-7.4-min
Browse files Browse the repository at this point in the history
PHP 8.4 compatibility
  • Loading branch information
giggsey authored Oct 8, 2024
2 parents 44d32ea + 0d7ce62 commit 8a146ce
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions build/BuildMetadataFromXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ public static function setPossibleLengthsGeneralDesc(PhoneNumberDesc $generalDes
* @param array $lengths
* @param array $localOnlyLengths
*/
private static function setPossibleLengths($lengths, $localOnlyLengths, PhoneNumberDesc $parentDesc = null, PhoneNumberDesc $desc)
private static function setPossibleLengths($lengths, $localOnlyLengths, ?PhoneNumberDesc $parentDesc, PhoneNumberDesc $desc)
{
// We clear these fields since the metadata tends to inherit from the parent element for other
// fields (via a mergeFrom).
Expand Down Expand Up @@ -679,7 +679,7 @@ private static function setPossibleLengths($lengths, $localOnlyLengths, PhoneNum
* @return PhoneNumberDesc complete description of that phone number type
*/
public static function processPhoneNumberDescElement(
PhoneNumberDesc $parentDesc = null,
?PhoneNumberDesc $parentDesc,
\DOMElement $countryElement,
$numberType
) {
Expand Down
2 changes: 1 addition & 1 deletion src/PhoneNumberMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ public static function allNumberGroupsAreExactlyPresent(
protected static function getNationalNumberGroups(
PhoneNumberUtil $util,
PhoneNumber $number,
NumberFormat $formattingPattern = null
?NumberFormat $formattingPattern = null
) {
if ($formattingPattern === null) {
// This will be in the format +CC-DG;ext=EXT where DG represents groups of digits.
Expand Down
16 changes: 10 additions & 6 deletions src/PhoneNumberUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,12 @@ protected function __construct(MetadataSourceInterface $metadataSource, $country
* @param string|null $baseFileLocation
* @return PhoneNumberUtil instance
*/
public static function getInstance($baseFileLocation = null, array $countryCallingCodeToRegionCodeMap = null, MetadataLoaderInterface $metadataLoader = null, MetadataSourceInterface $metadataSource = null)
{
public static function getInstance(
$baseFileLocation = null,
?array $countryCallingCodeToRegionCodeMap = null,
?MetadataLoaderInterface $metadataLoader = null,
?MetadataSourceInterface $metadataSource = null
) {
if (static::$instance === null) {
if ($countryCallingCodeToRegionCodeMap === null) {
$countryCallingCodeToRegionCodeMap = CountryCodeToRegionCodeMap::$countryCodeToRegionCodeMap;
Expand Down Expand Up @@ -1576,7 +1580,7 @@ protected function maybeStripExtension(&$number)
* as that of the default region supplied.
* @return PhoneNumber a phone number proto buffer filled with the parsed number
*/
public function parseAndKeepRawInput($numberToParse, $defaultRegion, PhoneNumber $phoneNumber = null)
public function parseAndKeepRawInput($numberToParse, $defaultRegion, ?PhoneNumber $phoneNumber = null)
{
if ($phoneNumber === null) {
$phoneNumber = new PhoneNumber();
Expand All @@ -1594,7 +1598,7 @@ public function parseAndKeepRawInput($numberToParse, $defaultRegion, PhoneNumber
* @param int $maxTries Defaults to PHP_INT_MAX
* @return PhoneNumberMatcher
*/
public function findNumbers($text, $defaultRegion, AbstractLeniency $leniency = null, $maxTries = PHP_INT_MAX)
public function findNumbers($text, $defaultRegion, ?AbstractLeniency $leniency = null, $maxTries = PHP_INT_MAX)
{
if ($leniency === null) {
$leniency = Leniency::VALID();
Expand Down Expand Up @@ -2030,7 +2034,7 @@ protected function checkRegionForParsing($numberToParse, $defaultRegion)
*/
public function maybeExtractCountryCode(
$number,
PhoneMetadata $defaultRegionMetadata = null,
?PhoneMetadata $defaultRegionMetadata,
&$nationalNumber,
$keepRawInput,
PhoneNumber $phoneNumber
Expand Down Expand Up @@ -3166,7 +3170,7 @@ public function isValidNumberForRegion(PhoneNumber $number, $regionCode)
* and the number is not in international format (does not start
* with +)
*/
public function parse($numberToParse, $defaultRegion = null, PhoneNumber $phoneNumber = null, $keepRawInput = false)
public function parse($numberToParse, $defaultRegion = null, ?PhoneNumber $phoneNumber = null, $keepRawInput = false)
{
if ($phoneNumber === null) {
$phoneNumber = new PhoneNumber();
Expand Down

0 comments on commit 8a146ce

Please sign in to comment.