Skip to content

Conversation

janedbal
Copy link

This adds documentation for the setTimeout() method that was added to the Question class in Symfony 7.4. The timeout feature allows setting a maximum time limit for user input to prevent hanging indefinitely in interactive questions, particularly useful in database transactions or other time-sensitive operations.

Closes #21366

Setting a Timeout for User Input
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. versionadded:: 7.4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let move this at the end of this section please

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done while merging.

$helper = new QuestionHelper();

$question = new Question('Please enter your answer');
$question->setTimeout(30); // 30 seconds timeout
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$question->setTimeout(30); // 30 seconds timeout
$question->setTimeout(seconds: 30);

would be much better, but lets wait for @xabbuh and @javiereguiluz, because IIRC we don't use named arguments in the docs, as they are not covered by BC

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know and I agree. But, it was decided to never show named arguments in docs, so let's not do this. Thanks.


// ...
$question = new ConfirmationQuestion('Do you want to continue?', false);
$question->setTimeout(10); // 10 seconds timeout
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$question->setTimeout(10); // 10 seconds timeout
$question->setTimeout(seconds: 10);

See comment above

@OskarStark OskarStark changed the title [Console] Document timeout functionality for QuestionHelper [Console] Document timeout functionality for QuestionHelper Sep 15, 2025
@javiereguiluz javiereguiluz force-pushed the console-question-timeout branch from b6a3f86 to c6d70aa Compare September 23, 2025 08:20
@javiereguiluz javiereguiluz merged commit 332828a into symfony:7.4 Sep 23, 2025
2 of 3 checks passed
@javiereguiluz
Copy link
Member

Thanks Jan for this nice contribution and for adding the docs for it too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants