/**
* Returns whether the current element of the iterator can be recursed
* into.
*/
public function hasChildren(): bool
{ return current($this->errors
) instanceof self;
} public function getChildren(): self
{ if (!
$this->
hasChildren()) { throw new LogicException(sprintf('The current element is not iterable. Use "%s" to get the current element.', self::
class.'::current()'
));
} /** @var self $children */
$children =
current($this->errors
);
return $children;
} /**
* Returns the number of elements in the iterator.
*
* Note that this is not the total number of errors, if the constructor
* parameter $deep was set to true! In that case, you should wrap the
* iterator into a {@link \RecursiveIteratorIterator} with the standard mode
* {@link \RecursiveIteratorIterator::LEAVES_ONLY} and count the result.
*
* $iterator = new \RecursiveIteratorIterator($form->getErrors(true));
* $count = count(iterator_to_array($iterator));
*
* Alternatively, set the constructor argument $flatten to true as well.
*
* $count = count($form->getErrors(true, true));
*/