diff --git a/src/Coduo/PHPMatcher/Matcher/CallbackMatcher.php b/src/Coduo/PHPMatcher/Matcher/CallbackMatcher.php index 9943d526..5d8f6403 100644 --- a/src/Coduo/PHPMatcher/Matcher/CallbackMatcher.php +++ b/src/Coduo/PHPMatcher/Matcher/CallbackMatcher.php @@ -17,6 +17,6 @@ public function match($value, $pattern) */ public function canMatch($pattern) { - return is_callable($pattern); + return is_object($pattern) && is_callable($pattern); } } diff --git a/tests/Coduo/PHPMatcher/Matcher/CallbackMatcherTest.php b/tests/Coduo/PHPMatcher/Matcher/CallbackMatcherTest.php index ae869844..f7ce5837 100644 --- a/tests/Coduo/PHPMatcher/Matcher/CallbackMatcherTest.php +++ b/tests/Coduo/PHPMatcher/Matcher/CallbackMatcherTest.php @@ -15,6 +15,7 @@ function test_negative_can_match() { $matcher = new CallbackMatcher(); $this->assertFalse($matcher->canMatch(new \DateTime())); + $this->assertFalse($matcher->canMatch('SIN')); } function test_positive_matches()