From 5338f043c600b54d8766297dbca67fb60534ad2b Mon Sep 17 00:00:00 2001 From: Joshua Gigg Date: Tue, 8 Oct 2024 09:17:03 +0100 Subject: [PATCH 1/2] Test with PHP 8.4 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8baff649..144597a8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - php-version: [8.1, 8.2, 8.3] + php-version: [8.1, 8.2, 8.3, 8.4] composer: [highest, lowest] steps: From 3a06bf9efc6ed6e016f6b32db79289d90670ae93 Mon Sep 17 00:00:00 2001 From: Joshua Gigg Date: Tue, 8 Oct 2024 09:21:23 +0100 Subject: [PATCH 2/2] Fix PHP 8.4 compatibility --- build/BuildMetadataFromXml.php | 2 +- src/PhoneNumberUtil.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build/BuildMetadataFromXml.php b/build/BuildMetadataFromXml.php index e22f8db1..09475778 100644 --- a/build/BuildMetadataFromXml.php +++ b/build/BuildMetadataFromXml.php @@ -585,7 +585,7 @@ public static function setPossibleLengthsGeneralDesc(PhoneNumberDesc $generalDes * @param int[] $lengths * @param int[] $localOnlyLengths */ - private static function setPossibleLengths(array $lengths, array $localOnlyLengths, PhoneNumberDesc $desc, PhoneNumberDesc $parentDesc = null): void + private static function setPossibleLengths(array $lengths, array $localOnlyLengths, PhoneNumberDesc $desc, ?PhoneNumberDesc $parentDesc = null): void { // We clear these fields since the metadata tends to inherit from the parent element for other // fields (via a mergeFrom). diff --git a/src/PhoneNumberUtil.php b/src/PhoneNumberUtil.php index d043ce93..d8880db0 100644 --- a/src/PhoneNumberUtil.php +++ b/src/PhoneNumberUtil.php @@ -397,9 +397,9 @@ protected function __construct(MetadataSourceInterface $metadataSource, array $c */ public static function getInstance( string $baseFileLocation = self::META_DATA_FILE_PREFIX, - array $countryCallingCodeToRegionCodeMap = null, - MetadataLoaderInterface $metadataLoader = null, - MetadataSourceInterface $metadataSource = null + ?array $countryCallingCodeToRegionCodeMap = null, + ?MetadataLoaderInterface $metadataLoader = null, + ?MetadataSourceInterface $metadataSource = null ): PhoneNumberUtil { if (static::$instance === null) { if ($countryCallingCodeToRegionCodeMap === null) { @@ -2969,7 +2969,7 @@ public function isValidNumberForRegion(PhoneNumber $number, string $regionCode): * and the number is not in international format (does not start * with +) */ - public function parse(string $numberToParse, ?string $defaultRegion = null, PhoneNumber $phoneNumber = null, bool $keepRawInput = false): PhoneNumber + public function parse(string $numberToParse, ?string $defaultRegion = null, ?PhoneNumber $phoneNumber = null, bool $keepRawInput = false): PhoneNumber { if ($phoneNumber === null) { $phoneNumber = new PhoneNumber();