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

Handle 'hidden' param from AsCommand attribute#41547

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

Conversation

@yoannrenard
Copy link
Contributor

@yoannrenardyoannrenard commentedJun 4, 2021
edited
Loading

QA
Branch?5.4
Bug fix?yes
New feature?no
Deprecations?no
Tickets
LicenseMIT
Doc PR

The recently introducedAsCommand attribute works like a charm (as much as the whole 5.3 release 👌). Thanks a lot for that!

Though, it seems that thehidden property has been forgotten, whether one set it or not the command only checks the$this->hidden value set from theconfigure() method.

For example:

#[AsCommand(    name:'app:do:something',    description:'Will do something very cool.',    aliases: [],    hidden:true)]class DoSomethingCommandextends Command

When I runbash bin/console list app I get

Available commandsfor the"app" namespace:  app:do:something  Do something very cool.

I implemented a fix inspired by the$name/$description properties.

@yoannrenardyoannrenard changed the titleHandle 'hidden' param from AsCommand attribute[Console] Handle 'hidden' param from AsCommand attributeJun 4, 2021
Copy link
Contributor

@OskarStarkOskarStark left a comment

Choose a reason for hiding this comment

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

Looks good to me except my comment

@carsonbotcarsonbot changed the title[Console] Handle 'hidden' param from AsCommand attributeHandle 'hidden' param from AsCommand attributeJun 5, 2021
@nicolas-grekas
Copy link
Member

This patch doesn't fix the root issue. If you inspect the dumped container for example, you'll see that the command is correctly registered as hidden.
Yet, for some reason I didn't spot yet, thelist command doesn't see this flag as set.
This needs to be investigated.

$isHidden =$attribute[0]->newInstance()->hidden;
}

return$this->hidden ||$isHidden;

Choose a reason for hiding this comment

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

For reviewers (and for the author): this patch cannot be correct, because it makes the attribute a mandatory piece of configuration that cannot be ignored. This is against the root principles of attributes, which should be purely declarative.

derrabus reacted with thumbs up emoji
@nicolas-grekasnicolas-grekas added this to the5.3 milestoneJun 5, 2021
@nicolas-grekas
Copy link
Member

nicolas-grekas commentedJun 5, 2021
edited
Loading

Note that past some issue with registering commands, there is another one: when theCommand class is registered without the DI component (without theAddConsoleCommandPass), then the aliases and hidden flags are ignored, and the name is not parsed (explode('|')). I don't know how common it is to use Command without DI. A fix would involve parsing the name and using it when hidden+aliases are undefined.

@yoannrenard
Copy link
ContributorAuthor

As said@nicolas-grekas without DI, the command name is not parsed when thehidden param is set in the AsCommand attribute.
I've created a quick bug reproducerhere to show you.

@yoannrenard
Copy link
ContributorAuthor

After more tests this morning, I've discovered that AsCommand attribute works fine with CI. I just didn't know that this attribute needed to clear the cache to work. My bad.

I'll close this PR as it is wrong and push my fix for the usage without CI in another one.

@stof
Copy link
Member

stof commentedJun 7, 2021

@yoannrenard the need to clear cache when changing attributes is caused by#39988

@yoannrenard
Copy link
ContributorAuthor

Thanks for the information@stof

nicolas-grekas added a commit that referenced this pull requestJun 12, 2021
This PR was merged into the 5.3 branch.Discussion----------[Console] Fix using #[AsCommand] without DI| Q             | A| ------------- | ---| Branch?       | 5.3| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       |Fix#41547| License       | MIT| Doc PR        | -Commits-------c4357ea [Console] Fix using #[AsCommand] without DI
@yoannrenardyoannrenard deleted the handle_hidden_param_from_AsCommand_attribute branchJune 13, 2021 05:59
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@OskarStarkOskarStarkOskarStark approved these changes

@NyholmNyholmNyholm left review comments

@chalasrchalasrAwaiting requested review from chalasrchalasr is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

5.3

Development

Successfully merging this pull request may close these issues.

6 participants

@yoannrenard@nicolas-grekas@stof@OskarStark@Nyholm@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp