From 4fcd4916ede15ca2df594e54f3193505a0558553 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 6 Sep 2020 21:31:28 +0200 Subject: [PATCH] [Console] Make sure $maxAttempts is an int or null. --- src/Symfony/Component/Console/Question/Question.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Console/Question/Question.php b/src/Symfony/Component/Console/Question/Question.php index 06464e135b..7d016ecea9 100644 --- a/src/Symfony/Component/Console/Question/Question.php +++ b/src/Symfony/Component/Console/Question/Question.php @@ -188,8 +188,11 @@ class Question */ public function setMaxAttempts($attempts) { - if (null !== $attempts && $attempts < 1) { - throw new InvalidArgumentException('Maximum number of attempts must be a positive value.'); + if (null !== $attempts) { + $attempts = (int) $attempts; + if ($attempts < 1) { + throw new InvalidArgumentException('Maximum number of attempts must be a positive value.'); + } } $this->attempts = $attempts;