Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.4 compatibility #657

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading