src/Validator/AbstractValidator.php
public function getMessages($language = null)
    {
        if (!$this->messages) {
            return [];
        }

        $messages = [];
        try {
            do {
                $messages[] = $this->getMessage($language);
                next($this->messages);
            } while (current($this->messages));
        } finally {
            reset($this->messages);
        }

        return $messages;
    }
public function getMessages($language = null)
    {
        if (!$this->messages) {
            return [];
        }

        $messages = [];
        try {
            do {
                $messages[] = $this->getMessage($language);
                next($this->messages);
            } while (current($this->messages));
        } finally {
            reset($this->messages);
        }

        return $messages;
    }
{@inheritdoc}