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] Additional validation of mode inInputArgument andInputOption#52055

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

Draft
jnoordsij wants to merge4 commits intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromjnoordsij:console-input-mode-validation

Conversation

jnoordsij
Copy link
Contributor

@jnoordsijjnoordsij commentedOct 14, 2023
edited
Loading

QA
Branch?6.4
Bug fix?no
New feature?no
Deprecations?yes
Ticketsn/a
LicenseMIT

Currently it is allowed to to combine various combinations of input value requirement specifiers, which are logically exclusive behavior-wise. To prevent mistakes or possibly ambiguous behavior, this PR adds additional validation to ensure there's always exactly one specifier part of the mode after finishing the constructor.

This is done by adding a deprecation message for these cases, which can be replaced with anInvalidArgumentException in a future major version. The tests added are currently checking for the deprecation message and could be updated to check for this exception instead.

Also automatically set OPTIONAL whenever REQUIRED is not specified.
@jnoordsij
Copy link
ContributorAuthor

Tests failing due to issues fixed in#52058; I'll finish this after that is merged.

@jnoordsijjnoordsij marked this pull request as draftOctober 14, 2023 09:18
@jnoordsijjnoordsijforce-pushed theconsole-input-mode-validation branch fromb1e241c to251b242CompareOctober 14, 2023 09:48
Copy link
Member

@GromNaNGromNaN left a comment

Choose a reason for hiding this comment

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

Thank you for this suggestion, that will avoid mistakes. I don't see any legitimate case of using these contradictory options together.

My comments are proposals, to be discussed.

{
$this->expectDeprecation('Since symfony/console 6.4: InputOption mode should be either none, required or optional.');

new InputOption('foo', 'f', InputOption::VALUE_NONE | InputOption::VALUE_REQUIRED);
Copy link
Member

Choose a reason for hiding this comment

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

Have you considered using a data provider to reduce repetition?

throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode));
}

$requirementSpecifier = ($mode & (self::VALUE_NONE | self::VALUE_REQUIRED | self::VALUE_OPTIONAL));
if (!(self::VALUE_NONE === $requirementSpecifier || self::VALUE_REQUIRED === $requirementSpecifier || self::VALUE_OPTIONAL === $requirementSpecifier)) {
trigger_deprecation('symfony/console', '6.4', 'InputOption mode should be either none, required or optional.');
Copy link
Member

Choose a reason for hiding this comment

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

We can add the option name to the deprecation message. That would help to find where the change need to be done when our tools don't provide the backtrace of the trigger.

Co-authored-by: Jérôme Tamarelle <jerome@tamarelle.net>
@OskarStarkOskarStark changed the title[Console] Additional validation of mode in InputArgument and InputOption[Console] Additional validation of mode inInputArgument andInputOptionOct 17, 2023
@nicolas-grekasnicolas-grekas modified the milestones:6.4,7.1Nov 15, 2023
@OskarStark
Copy link
Contributor

What is the status of this PR? If you still want to work on it, please rebase on top of7.1 branch, thanks

@jnoordsij
Copy link
ContributorAuthor

What is the status of this PR? If you still want to work on it, please rebase on top of7.1 branch, thanks

Awaiting the results of#52058, which addresses the test failing here. Once a decision is reached there, I'll be rebasing and adjusting this further.

OskarStark reacted with thumbs up emoji

@xabbuhxabbuh modified the milestones:7.1,7.2May 15, 2024
@fabpotfabpot modified the milestones:7.2,7.3Nov 20, 2024
@fabpotfabpot modified the milestones:7.3,7.4May 26, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@GromNaNGromNaNGromNaN approved these changes

@chalasrchalasrAwaiting requested review from chalasrchalasr is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
7.4
Development

Successfully merging this pull request may close these issues.

7 participants
@jnoordsij@OskarStark@GromNaN@fabpot@nicolas-grekas@xabbuh@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp