[Console] Document #[Ask] and #[Interact] attributes#22109
[Console] Document #[Ask] and #[Interact] attributes#22109lacatoire wants to merge 4 commits intosymfony:7.4from
Conversation
|
Could you please add those attributes in reference page ? |
There was a problem hiding this comment.
Pull request overview
Documents the new Console interactive invokable-command attributes (#[Ask] and #[Interact]) introduced in Symfony 7.4, addressing the missing documentation requested in issue #21465.
Changes:
- Add
#[Ask]documentation covering basic prompts, hidden input, confirmations, and usage on DTO properties. - Add
#[Interact]documentation for custom interactive logic and describe execution order. - Link
AskandInteractfrom the Symfony attributes index.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| reference/attributes.rst | Adds references for Ask and Interact to the attributes overview list. |
| console/input.rst | Introduces a new “Interactive Input” section documenting #[Ask] and #[Interact] with examples and execution order. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #[Interact] | ||
| public function prompt(SymfonyStyle $io): void | ||
| { | ||
| if (!isset($this->password)) { |
| public function __invoke( | ||
| #[Option] | ||
| #[Ask('Do you want to activate the user?')] | ||
| bool $active, |
There was a problem hiding this comment.
Options shouldn't be required, they should define a default value, which means interactive attributes can't be used with them.
This code will currently raise an exception.
There was a problem hiding this comment.
It might deserve a clear note: interactive attributes can only be used with required console arguments.
Using them with optional arguments wouldn't work either, since prompting for those values when they are missing would contradict the purpose of optional inputs.
…about required arguments
Document the
#[Ask]and#[Interact]attributes for interactive invokable commands: simple prompts, hidden input, confirmation, DTO properties, custom interact methods, and execution order.Fixes #21465