protected function validateAttempts($interviewer) { /** @var \Exception $error */ $error = null; $attempts = $this->question->getMaxAttempts(); while (null === $attempts || $attempts--) { if (null !== $error) { $this->output->error($error->getMessage()); } try { return call_user_func($this->question->getValidator(), $interviewer()); } catch (\Exception $error) { } } throw $error; }