From cc53dbd951d43de571d562da62802096365b1164 Mon Sep 17 00:00:00 2001 From: Brady Law Date: Thu, 20 Jun 2013 11:23:29 -0700 Subject: [PATCH] Fix bug where a "false" result from array_search cleared the supportedRegion at index 0. --- PhoneNumberUtil.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/PhoneNumberUtil.php b/PhoneNumberUtil.php index a1c85b3..115ca79 100644 --- a/PhoneNumberUtil.php +++ b/PhoneNumberUtil.php @@ -233,7 +233,10 @@ private function init($filePrefix) { foreach ($this->countryCallingCodeToRegionCodeMap as $regionCodes) { $this->supportedRegions = array_merge($this->supportedRegions, $regionCodes); } - unset($this->supportedRegions[array_search(self::REGION_CODE_FOR_NON_GEO_ENTITY, $this->supportedRegions)]); + $index = array_search(self::REGION_CODE_FOR_NON_GEO_ENTITY, $this->supportedRegions); + if ($index) { + unset($this->supportedRegions[$index]); + } $this->nanpaRegions = $this->countryCallingCodeToRegionCodeMap[self::NANPA_COUNTRY_CODE]; }