Skip to content

Commit

Permalink
[5.4] Allow Validator extension to use array-style callable (#18399)
Browse files Browse the repository at this point in the history
* 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").

* Update Validator.php
  • Loading branch information
adamthehutt authored and taylorotwell committed Mar 19, 2017
1 parent ef12706 commit ab37f22
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Validation/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ protected function callExtension($rule, $parameters)
{
$callback = $this->extensions[$rule];

if ($callback instanceof Closure) {
if (is_callable($callback)) {
return call_user_func_array($callback, $parameters);
} elseif (is_string($callback)) {
return $this->callClassBasedExtension($callback, $parameters);
Expand Down

0 comments on commit ab37f22

Please sign in to comment.