-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] #[Option] ?string $opt = null
as VALUE_REQUIRED
#60406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -86,7 +86,8 @@ public function testCommandInputOptionDefinition() | |||
$timeoutInputOption = $command->getDefinition()->getOption('idle'); | |||
self::assertSame('idle', $timeoutInputOption->getName()); | |||
self::assertNull($timeoutInputOption->getShortcut()); | |||
self::assertTrue($timeoutInputOption->isValueOptional()); | |||
self::assertTrue($timeoutInputOption->isValueRequired()); | |||
self::assertFalse($timeoutInputOption->isValueOptional()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note this behaviour change - but I think it's ok - VALUE_OPTIONAL
didn't make sense here imo.
All these changes make perfect sense to me Kevin. Thanks again for your work on this! Now trying to write the documentation for Inputs symfony/symfony-docs#20932, after this, I struggle to explain consistently what makes an option value required or optional, can I get some help on this?
Is it the nullable type? the nullable type and a null default? or neither, just hardcoded conventions? I thought any consistent way to reason about the signature would make it easier to remember how to use the options, but that may not be possible for this feature. |
Following the same logic, what about:
|
I think #60407 forbids the first case of your list and makes |
The changes from this PR are included in #60407. |
Adds the following rule for invokable command options:
?string $opt = null
VALUE_REQUIRED
<omitted>
--opt=val
null
(default)"val"