mirror of
https://github.com/Respect/Validation.git
synced 2024-06-09 01:02:16 +02:00
Fix possible error when recursing exceptions
The method "current()" from NestedValidationException can return any instance of ValidationException, but the implementation of "getChildren()" requires it to return an instance of "NestedValidationException". Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
parent
ec8874808f
commit
9a41f64479
|
@ -16,6 +16,7 @@ namespace Respect\Validation\Exceptions;
|
|||
use ArrayIterator;
|
||||
use Countable;
|
||||
use RecursiveIterator;
|
||||
use UnexpectedValueException;
|
||||
|
||||
/**
|
||||
* @author Henrique Moody <henriquemoody@gmail.com>
|
||||
|
@ -48,7 +49,12 @@ final class RecursiveExceptionIterator implements RecursiveIterator, Countable
|
|||
|
||||
public function getChildren(): self
|
||||
{
|
||||
return new static($this->current());
|
||||
$exception = $this->current();
|
||||
if (!$exception instanceof NestedValidationException) {
|
||||
throw new UnexpectedValueException();
|
||||
}
|
||||
|
||||
return new static($exception);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue