From fd55e2154c2589e425056d87279e4c8eb092e68a Mon Sep 17 00:00:00 2001 From: Adam Huttler Date: Fri, 17 Mar 2017 19:08:28 -0400 Subject: [PATCH 1/2] Allow Validator extension to use array-style callable Currently, a validator extension can be either a Closure or a string denoting a class and method. For complex validation scenarios, however, it's useful to be able to pass an object and method in the array-style callable format (i.e. [$object, $method] instead of "$class@$method"). --- src/Illuminate/Validation/Validator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Validation/Validator.php b/src/Illuminate/Validation/Validator.php index a2d1cfce320d..836ab8183c12 100755 --- a/src/Illuminate/Validation/Validator.php +++ b/src/Illuminate/Validation/Validator.php @@ -1026,7 +1026,7 @@ protected function callExtension($rule, $parameters) { $callback = $this->extensions[$rule]; - if ($callback instanceof Closure) { + if ($callback instanceof Closure || is_array($callback)) { return call_user_func_array($callback, $parameters); } elseif (is_string($callback)) { return $this->callClassBasedExtension($callback, $parameters); From bb352f6ee8be8ffca69bd40c4d3b6e9a9aeb914f Mon Sep 17 00:00:00 2001 From: Adam Huttler Date: Fri, 17 Mar 2017 22:54:19 -0400 Subject: [PATCH 2/2] Update Validator.php --- src/Illuminate/Validation/Validator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Validation/Validator.php b/src/Illuminate/Validation/Validator.php index 836ab8183c12..c44c5d5211b2 100755 --- a/src/Illuminate/Validation/Validator.php +++ b/src/Illuminate/Validation/Validator.php @@ -1026,7 +1026,7 @@ protected function callExtension($rule, $parameters) { $callback = $this->extensions[$rule]; - if ($callback instanceof Closure || is_array($callback)) { + if (is_callable($callback)) { return call_user_func_array($callback, $parameters); } elseif (is_string($callback)) { return $this->callClassBasedExtension($callback, $parameters);