From 1e21f66ce79fa5225b5a93a0d16c6be1dd6120ba Mon Sep 17 00:00:00 2001 From: Pawel Skotnicki Date: Thu, 5 Feb 2015 10:49:18 +0100 Subject: [PATCH] CallbackMatcher should not be executed for internal function names --- src/Coduo/PHPMatcher/Matcher/CallbackMatcher.php | 2 +- tests/Coduo/PHPMatcher/Matcher/CallbackMatcherTest.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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()