Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Console]#[Option] ?string $opt = null asVALUE_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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
kbond wants to merge1 commit intosymfony:7.3fromkbond:console-nullable-string

Conversation

kbond
Copy link
Member

QA
Branch?7.3
Bug fix?no
New feature?yes
Deprecations?no
IssuesFix#59602 (comment)
LicenseMIT

Adds the following rule for invokable command options:

SignatureDefinitionUsageValue
?string $opt = nullVALUE_REQUIRED<omitted>
--opt=val
null (default)
"val"

@@ -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());
Copy link
MemberAuthor

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.

@yceruto
Copy link
Member

All these changes make perfect sense to me Kevin. Thanks again for your work on this!

Now trying to write the documentation for Inputssymfony/symfony-docs#20932, after this, I struggle to explainconsistently what makes an option value required or optional, can I get some help on this?

SignatureDefinitionUsageValue
?string $opt = ''VALUE_OPTIONAL<omitted>
--opt
--opt=val
'' (default)
null
'val'
?string $opt = nullVALUE_REQUIRED<omitted>
--opt=val
null (default)
'val'
string $opt = ''VALUE_REQUIRED<omitted>
--opt=val
'' (default)
'val'
array $opt = []VALUE_REQUIRED &
VALUE_ARRAY
<omitted>
--opt=val1
[] (default)
['val1']

Is it the nullable type? the nullable typeand 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.

@yceruto
Copy link
Member

Following the same logic, what about:

SignatureDefinitionUsageValue
?array $opt = nullVALUE_REQUIRED &
VALUE_ARRAY
<omitted>
--opt=val1
null (default)
['val1']
chalasr reacted with thumbs up emoji

@kbond
Copy link
MemberAuthor

@yceruto, if you're good with this and#60407, once merged, I'll compile a new list for you in the doc PR.

?array $opt = null

Yep, that's a fair one to add also.

chalasr reacted with thumbs up emoji

@chalasr
Copy link
Member

I think#60407 forbids the first case of your list and makesstring|bool the only way to getVALUE_OPTIONAL, which I agree with

kbond reacted with thumbs up emoji

@kbond
Copy link
MemberAuthor

The changes from this PR are included in#60407.

@kbondkbond closed thisMay 12, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@chalasrchalasrchalasr approved these changes

@ycerutoycerutoAwaiting requested review from yceruto

Assignees
No one assigned
Projects
None yet
Milestone
7.3
Development

Successfully merging this pull request may close these issues.

4 participants
@kbond@yceruto@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp