Skip to content

Commit 4fcd491

Browse files
derrabusfabpot
authored andcommitted
[Console] Make sure $maxAttempts is an int or null.
1 parent ee8fc9c commit 4fcd491

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Symfony/Component/Console/Question/Question.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,11 @@ public function getValidator()
188188
*/
189189
public function setMaxAttempts($attempts)
190190
{
191-
if (null !== $attempts && $attempts < 1) {
192-
throw new InvalidArgumentException('Maximum number of attempts must be a positive value.');
191+
if (null !== $attempts) {
192+
$attempts = (int) $attempts;
193+
if ($attempts < 1) {
194+
throw new InvalidArgumentException('Maximum number of attempts must be a positive value.');
195+
}
193196
}
194197

195198
$this->attempts = $attempts;

0 commit comments

Comments
 (0)