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

Add phpdoc for constraint#42136

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

Conversation

@VincentLanglet
Copy link
Contributor

@VincentLangletVincentLanglet commentedJul 15, 2021
edited
Loading

QA
Branch?5.4
Bug fix?no
New feature?no
Deprecations?no
TicketsFix #...
LicenseMIT
Doc PRsymfony/symfony-docs#...

When extending some constraint and overriding some property, it's not always simple to know what can be passed to the properties and when it can be null. Those properties should have phpdoc to define their type.

Plus it avoid a psalm errorNonInvariantDocblockPropertyType for the developer which use a more specific phpdoc (because atm, properties are considered as mixed).

And, it will help the typing for PHP8 on the branch 6.0@nicolas-grekas :)

@derrabus
Copy link
Member

Fixing Doc blocks should be done as a bugfix on lower branches (4.4 mainly, in this case).

@VincentLanglet
Copy link
ContributorAuthor

Fixing Doc blocks should be done as a bugfix on lower branches (4.4 mainly, in this case).

I fully agree on this.
But on one of my last PR there was this debate#40604 and it ended with the decision it should be on 5.x.

If the core team now decide it's a bugfix, I'm fine doing it on 4.4 but I'd like some confirmation before doing this PR again.

@derrabus
Copy link
Member

Fair enough. Sorry for the confusion. 😞

@nicolas-grekasnicolas-grekas added this to the5.4 milestoneJul 19, 2021
@nicolas-grekas
Copy link
Member

We try to remove phpdoc actually.
We have a rule where the default type of a property is enough clue to tell its type.
I'm fine adding phpdoc when it really brings value, but I'd better remove them otherwise.

@VincentLanglet
Copy link
ContributorAuthor

VincentLanglet commentedJul 19, 2021
edited
Loading

We have a rule where the default type of a property is enough clue to tell its type.
I'm fine adding phpdoc when it really brings value, but I'd better remove them otherwise.

The rule has some sens, but it's not because a property has a default value that another type is forbidden
For instance
https://github.com/symfony/symfony/pull/42136/files#diff-738b9954d83ec3560d6a0b70f45958640c89abd268d72bba647e87c0ff13e185R50
The default value is an array, but looking at the code, a string is allowed too.

My main issue was that psalm and phpstan consider asmixed every property without typehint or phpdoc. Witch is pretty annoying when overriding a constraint class/property and adding some phpdoc. I would have prefer to add the phpdoc here rather than in the stub of psalm-symfony repository. The phpdoc can be removed in 6.0 when the type will be added.

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedJul 19, 2021
edited
Loading

That's an issue with psalm/phpstan, it might be fixed with a plugin maybe?
But I'm overall 👎 to "pollute" the code base with useless phpdoc, we already spend too much time on maintaining these.

@VincentLanglet
Copy link
ContributorAuthor

That's an issue with psalm/phpstan, it might be fixed with a plugin maybe?
But I'm overall 👎 to "pollute" the code base with useless phpdoc, we already spend too much time on maintaining these.

So I should remove the phpdoc of property with default value and keep the others ?

@nicolas-grekas
Copy link
Member

So I should remove the phpdoc of property with default value and keep the others ?

That'd work for me yes. If a default value can be added instead in some cases, that'd be even better.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

4 participants

@VincentLanglet@derrabus@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp