Skip to content

Commit

Permalink
fix isCallable
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Oct 29, 2020
1 parent 6091048 commit a90f344
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Illuminate/Support/Reflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public static function isCallable($var, $syntaxOnly = false)
return false;
}

if ($syntaxOnly &&
(is_string($var[0]) || is_object($var[0])) &&
is_string($var[1])) {
return true;
}

$class = is_object($var[0]) ? get_class($var[0]) : $var[0];

$method = $var[1];
Expand Down
2 changes: 2 additions & 0 deletions tests/Support/SupportReflectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public function testIsCallable()
$this->assertTrue(Reflector::isCallable([TestClassWithCallStatic::class, 'f']));
$this->assertFalse(Reflector::isCallable([new TestClassWithCallStatic, 'f']));
$this->assertFalse(Reflector::isCallable([new TestClassWithCallStatic]));
$this->assertFalse(Reflector::isCallable(['TotallyMissingClass', 'foo']));
$this->assertTrue(Reflector::isCallable(['TotallyMissingClass', 'foo'], true));
}
}

Expand Down

0 comments on commit a90f344

Please sign in to comment.