diff --git a/src/Symfony/Component/Form/FormErrorIterator.php b/src/Symfony/Component/Form/FormErrorIterator.php index 70dba94fd2e41..9ee2f0e8fe7d3 100644 --- a/src/Symfony/Component/Form/FormErrorIterator.php +++ b/src/Symfony/Component/Form/FormErrorIterator.php @@ -29,9 +29,11 @@ * * @author Bernhard Schussek * - * @implements \ArrayAccess - * @implements \RecursiveIterator - * @implements \SeekableIterator + * @template T of FormError|FormErrorIterator + * + * @implements \ArrayAccess + * @implements \RecursiveIterator + * @implements \SeekableIterator */ class FormErrorIterator implements \RecursiveIterator, \SeekableIterator, \ArrayAccess, \Countable { @@ -41,10 +43,14 @@ class FormErrorIterator implements \RecursiveIterator, \SeekableIterator, \Array public const INDENTATION = ' '; private $form; + + /** + * @var list + */ private $errors; /** - * @param list $errors + * @param list $errors * * @throws InvalidArgumentException If the errors are invalid */ @@ -74,7 +80,7 @@ public function __toString() $string .= 'ERROR: '.$error->getMessage()."\n"; } else { /* @var self $error */ - $string .= $error->form->getName().":\n"; + $string .= $error->getForm()->getName().":\n"; $string .= self::indent((string) $error); } } @@ -95,7 +101,7 @@ public function getForm() /** * Returns the current element of the iterator. * - * @return FormError|self An error or an iterator containing nested errors + * @return T An error or an iterator containing nested errors */ #[\ReturnTypeWillChange] public function current() @@ -164,7 +170,7 @@ public function offsetExists($position) * * @param int $position The position * - * @return FormError|FormErrorIterator + * @return T * * @throws OutOfBoundsException If the given position does not exist */ @@ -227,7 +233,10 @@ public function getChildren() // throw new LogicException(sprintf('The current element is not iterable. Use "%s" to get the current element.', self::class.'::current()')); } - return current($this->errors); + /** @var self $children */ + $children = current($this->errors); + + return $children; } /**