From 9b96373d10334c7b4a74c54e6a42f91e9c5c5e1f Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 13 Dec 2014 10:04:18 +0100 Subject: [PATCH] Fix failing tests after merge --- .../Constraints/CallbackValidator.php | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/Symfony/Component/Validator/Constraints/CallbackValidator.php b/src/Symfony/Component/Validator/Constraints/CallbackValidator.php index 6f073c7d87..831bf80bd1 100644 --- a/src/Symfony/Component/Validator/Constraints/CallbackValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CallbackValidator.php @@ -58,24 +58,18 @@ class CallbackValidator extends ConstraintValidator } call_user_func($method, $object, $this->context); + } elseif (null !== $object) { + if (!method_exists($object, $method)) { + throw new ConstraintDefinitionException(sprintf('Method "%s" targeted by Callback constraint does not exist', $method)); + } - continue; - } + $reflMethod = new \ReflectionMethod($object, $method); - if (null === $object) { - continue; - } - - if (!method_exists($object, $method)) { - throw new ConstraintDefinitionException(sprintf('Method "%s" targeted by Callback constraint does not exist', $method)); - } - - $reflMethod = new \ReflectionMethod($object, $method); - - if ($reflMethod->isStatic()) { - $reflMethod->invoke(null, $object, $this->context); - } else { - $reflMethod->invoke($object, $this->context); + if ($reflMethod->isStatic()) { + $reflMethod->invoke(null, $object, $this->context); + } else { + $reflMethod->invoke($object, $this->context); + } } } }