From 841b97c865f39980f8851ce9d0a6688862f4e5ef Mon Sep 17 00:00:00 2001 From: Guus De Graeve Date: Mon, 24 Mar 2014 14:05:06 +0100 Subject: [PATCH] if getMetadataForRegion returns NULL, continue getMetadataForRegion can return NULL for invalid region codes, in that case just continue looping region codes --- PhoneNumberUtil.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/PhoneNumberUtil.php b/PhoneNumberUtil.php index a1c85b3..28cc4e8 100644 --- a/PhoneNumberUtil.php +++ b/PhoneNumberUtil.php @@ -1916,6 +1916,10 @@ private function getRegionCodeForNumberFromRegionList(PhoneNumber $number, array foreach ($regionCodes as $regionCode) { // If leadingDigits is present, use this. Otherwise, do full validation. $metadata = $this->getMetadataForRegion($regionCode); + if (is_null($metadata)) + { + continue; + } if ($metadata->hasLeadingDigits()) { $nbMatches = preg_match('/' . $metadata->getLeadingDigits() . '/', $nationalNumber, $matches, PREG_OFFSET_CAPTURE); if ($nbMatches > 0 && $matches[0][1] === 0) {