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

[Config] Add conditional types to conditional builders#46581

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

@wouterj
Copy link
Member

@wouterjwouterj commentedJun 4, 2022
edited
Loading

QA
Branch?5.4
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix#46546
LicenseMIT
Doc PR-

On second thought, one of the main benefits of using the new PHP config builders in application code is the ability to use PHP community tooling to autocomplete and validate the configuration. In this light, I think it makes sense to add the correct PHPdocs to make Psalm and PHPstan understand the config builders.

On top of that, as these config classes are live generated, this is not something that can be easily stubbed in the special PHPstan and Psalm Symfony plugins.

Guuzen reacted with thumbs up emoji
Comment on lines 147 to 148
* @psalm-param T $value
* @psalm-return (T is array ? CLASS : static)
Copy link
MemberAuthor

@wouterjwouterjJun 4, 2022
edited
Loading

Choose a reason for hiding this comment

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

Using vendor prefixed annotations as e.g. PhpStorm has no support for conditional types yet afaik. This allows using@return with something everyone understands, while providing the necessary extra details to static analysis tools.

andrew-demb reacted with thumbs up emoji

Choose a reason for hiding this comment

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

let's still move this after@return in all cases :)

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Let's just say I was a bit unfocused yesterday 😄

@wouterjwouterjforce-pushed theissue-46546/static-analysis-configbuilder branch 2 times, most recently fromfbf15a8 toe69e509CompareJune 10, 2022 10:05
This allows static analysis tools to understand what type is returned.
@wouterjwouterjforce-pushed theissue-46546/static-analysis-configbuilder branch frome69e509 tod8500c1CompareJune 10, 2022 11:09
$body =$hasNormalizationClosures ?'
/**
* @template T
* @psalm-param T $value
Copy link
Member

Choose a reason for hiding this comment

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

should be$VALUE to be replaced by the appropriate name.


/**
* @template T
* @psalm-param T $value

Choose a reason for hiding this comment

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

shouldn't these all be just@param?

@wouterj
Copy link
MemberAuthor

I've re-submitted this PR against the 6.2 branch:#47127

As the config builder class has had a refactor, creating a new PR was easier :)

@wouterjwouterj deleted the issue-46546/static-analysis-configbuilder branchJuly 30, 2022 13:29
nicolas-grekas added a commit that referenced this pull requestAug 1, 2022
…wouterj)This PR was merged into the 6.2 branch.Discussion----------[Config] Add conditional types to conditional builders| Q             | A| ------------- | ---| Branch?       | 6.2| Bug fix?      | no| New feature?  | no| Deprecations? | no| Tickets       |Fix#46546| License       | MIT| Doc PR        | n/aReplaces#46581 , submitted to 6.2 instead. This matches with the changes proposed in#47016 and the config builder contained quite a big refactor for comments in 6.x so this avoids nasty conflicts.Original description:> One of the main benefits of using the new PHP config builders in application code is the ability to use PHP community tooling to autocomplete and validate the configuration. In this light, I think it makes sense to add the correct PHPdocs to make Psalm and PHPstan understand the config builders.>> On top of that, as these config classes are live generated, this is not something that can be easily stubbed in the special PHPstan and Psalm Symfony plugins.Commits-------ce1087e [Config] Add conditional types to conditional builders
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@stofstofstof requested changes

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

4 participants

@wouterj@nicolas-grekas@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp