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] Make CompletionSuggestions final#44229

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
wouterj wants to merge1 commit intosymfony:5.4fromwouterj:console-completion-fc

Conversation

@wouterj
Copy link
Member

@wouterjwouterj commentedNov 23, 2021
edited
Loading

QA
Branch?5.4
Bug fix?no
New feature?no
Deprecations?no
Ticketsn/a
LicenseMIT
Doc PRn/a

A very late call, but I suddenly realized we have to do something with theCompletionSuggestions class to not cut ourselves in the fingers for 6.1.

The problem:suggestValues() currently only allowsstring values. ZSH and FISH shells can have much more advanced completion support - also allowing descriptions for instance. Instead of making the completion integration shell specific, it is better to allow aDecoratedSuggestion or something like that, likesuggested by @GromNaN in the ZSH PR

We won't add zsh/fish support in Symfony <6.1, so we must allow ourselves to widen the argument type in Symfony 6.1.

Another option is to add the basicDecoratedSuggestion and widen this argument type in Symfony 5.4 already, without immediately using its power.

Copy link
Member

@chalasrchalasr left a comment

Choose a reason for hiding this comment

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

👍

@stof
Copy link
Member

Another option is to add the basicDecoratedSuggestion and widen this argument type in Symfony 5.4 already, without immediately using its power.

I would widen it now, making it easier to write code support 5.4 and 6.1 by always providing the suggestion with description in the command

@stof
Copy link
Member

Note that your current plan also requires widening thegetValueSuggestions return type, which is a BC break even on final classes.

@stof
Copy link
Member

@wouterj if you want to go for the widening type version, you need to taggetValueSuggestions as@internal so that we can change its return type to widen it (should be OK, as I don't think commands need to use it)

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedNov 23, 2021
edited
Loading

Widening a return type is not a BC break so we could do it later.

@wouterj
Copy link
MemberAuthor

Widening a return type is not a BC break so we could do it later.

Are you sure? This means that you can never safely rely on the return type if you're the calling side of the code.

@stof
Copy link
Member

Widening a return type is not a BC break so we could do it later.

it definitely is a BC break for callers (which is also why child classes are not allow to widen a return type of their parent).

@wouterj
Copy link
MemberAuthor

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedNov 23, 2021
edited
Loading

It's a behavioral BC break if something unexpected is returned, but if there's an opt-in on the input side of the API, then it's fine.

@stof
Copy link
Member

so you would want to havegetValueSuggestions($bcCastAsString = true) to make it backward compatible ?

We cannot rely onsuggestValue() as being the opt-in for the return type ofgetValueSuggestions. Callers of the 2 methods can be in different places (the whole point of using that object is passing it around)

@wouterj
Copy link
MemberAuthor

Oh: "Changing a return type is only possible with a child type.". As the proposed new suggestion class would beStringable, I guess it's allowed.

@nicolas-grekas
Copy link
Member

The BC doc needs to tell about widening/narrowing :)

@stof
Copy link
Member

@wouterjStringable is not a child type ofstring

@nicolas-grekas
Copy link
Member

So let's widen now indeed to be on the safe side.

@wouterj
Copy link
MemberAuthor

I've proposed the alternative solution in a new PR:#44230

@stof
Copy link
Member

@nicolas-grekas widening a return type is a BC break all the time. Narrowing it is a BC break for child classes (requiring them to narrow their own return type in advance, which is the whole reason for tentative return types in PHP 8.1 core and our work in DebugClassLoader).

@wouterj
Copy link
MemberAuthor

Let's close in favor of the new one, didn't see the conclusion before creating the other PR.

nicolas-grekas added a commit that referenced this pull requestNov 23, 2021
…n suggestion (wouterj)This PR was merged into the 5.4 branch.Discussion----------[Console] Add Suggestion class for more advanced completion suggestion| Q             | A| ------------- | ---| Branch?       | 5.4| Bug fix?      | no| New feature?  | yes| Deprecations? | no| Tickets       || License       | MIT| Doc PR        | -Alternative to#44229 , see that PR for the full context.Commits-------20ba02c Add Suggestion class for more advanced completion suggestion
symfony-splitter pushed a commit to symfony/console that referenced this pull requestNov 23, 2021
…n suggestion (wouterj)This PR was merged into the 5.4 branch.Discussion----------[Console] Add Suggestion class for more advanced completion suggestion| Q             | A| ------------- | ---| Branch?       | 5.4| Bug fix?      | no| New feature?  | yes| Deprecations? | no| Tickets       || License       | MIT| Doc PR        | -Alternative tosymfony/symfony#44229 , see that PR for the full context.Commits-------20ba02c1ee Add Suggestion class for more advanced completion suggestion
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@derrabusderrabusderrabus approved these changes

@chalasrchalasrchalasr approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

6 participants

@wouterj@stof@nicolas-grekas@derrabus@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp