Skip to content

Commit

Permalink
Merge pull request #361 from giggsey/issue-360
Browse files Browse the repository at this point in the history
Fix bug when calling isPossibleNumber with string, null
  • Loading branch information
giggsey committed Jan 21, 2020
2 parents 1ec1059 + 5c0b80b commit e420348
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/PhoneNumberUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -3475,7 +3475,7 @@ public function isMobileNumberPortableRegion($regionCode)
*/
public function isPossibleNumber($number, $regionDialingFrom = null)
{
if ($regionDialingFrom !== null && is_string($number)) {
if (is_string($number)) {
try {
return $this->isPossibleNumber($this->parse($number, $regionDialingFrom));
} catch (NumberParseException $e) {
Expand Down
19 changes: 19 additions & 0 deletions tests/Issues/Issue360Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace libphonenumber\Tests\Issues;

use libphonenumber\PhoneNumberUtil;
use PHPUnit\Framework\TestCase;

/**
* Test that you can not pass a string and null to isPossibleNumber
* @see https://github.com/giggsey/libphonenumber-for-php/issues/360
* @package libphonenumber\Tests\Issues
*/
class Issue360Test extends TestCase
{
public function testNullRegion()
{
$this->assertTrue(PhoneNumberUtil::getInstance()->isPossibleNumber('+441174960123', null));
}
}

0 comments on commit e420348

Please sign in to comment.