US number parsing fails because different data is used for countryCallingCodeToRegionCodeMap while testing and actual usage. The mapping for global networks (880 => 001) is present in countryCallingCodeToRegionCodeMapForTesting but not in countryCallingCodeToRegionCodeMap.
When the init() is called inside PhoneNumberUtil::getInstance(), it removes US from the supportedRegions array.
At line, http://git.io/CLseew#L235
unset($this->supportedRegions[array_search(self::REGION_CODE_FOR_NON_GEO_ENTITY, $this->supportedRegions)]) resolves to
unset($this->supportedRegions[array_search(001, $this->supportedRegions)])
Because the mapping doesn't exist for 001, array_search returns FALSE executing unset($this->supportedRegions[FALSE].
As unset(array[FALSE]) is equivalent to unset(array[0]), it unset the entry for US from the supportedRegions as index for US is 0 in the array.
Hence, parsing US number results into error.
I have attached a possible solution. Please validate and pull.
US number parsing fails because different data is used for countryCallingCodeToRegionCodeMap while testing and actual usage. The mapping for global networks (880 => 001) is present in countryCallingCodeToRegionCodeMapForTesting but not in countryCallingCodeToRegionCodeMap.
When the init() is called inside PhoneNumberUtil::getInstance(), it removes US from the supportedRegions array.
At line, http://git.io/CLseew#L235 unset($this->supportedRegions[array_search(self::REGION_CODE_FOR_NON_GEO_ENTITY, $this->supportedRegions)]) resolves to unset($this->supportedRegions[array_search(001, $this->supportedRegions)])
Because the mapping doesn't exist for 001, array_search returns FALSE executing unset($this->supportedRegions[FALSE].
As unset(array[FALSE]) is equivalent to unset(array[0]), it unset the entry for US from the supportedRegions as index for US is 0 in the array.
Hence, parsing US number results into error.
I have attached a possible solution. Please validate and pull.