-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Enhance PHPDoc on Constraint::getTargets()
#58493
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Validator] Enhance PHPDoc on Constraint::getTargets()
#58493
Conversation
b2b9050
to
987af2f
Compare
* Constraint::CLASS_CONSTRAINT and Constraint::PROPERTY_CONSTRAINT. | ||
* | ||
* @return string|string[] One or more constant values | ||
* @return self::CLASS_CONSTRAINT|self::PROPERTY_CONSTRAINT|array<self::CLASS_CONSTRAINT|self::PROPERTY_CONSTRAINT> One or more constant values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't this work?
* @return self::CLASS_CONSTRAINT|self::PROPERTY_CONSTRAINT|array<self::CLASS_CONSTRAINT|self::PROPERTY_CONSTRAINT> One or more constant values | |
* @return self::*_CONSTRAINT|array<self::*_CONSTRAINT> One or more constant values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works: https://phpstan.org/r/e511c5d3-eacc-4d1d-b9b3-c45683a3429f
I hesitated, because we could unintentionally include new constants ending with _CONSTRAINT
. But if it seems OK to you, I'm fine with it 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears to not work for Psalm (https://psalm.dev/r/25734b245c), which is a requirement for us (as this is what we use in our own CI).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right, let's keep it as-is then. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then:
* @return self::CLASS_CONSTRAINT|self::PROPERTY_CONSTRAINT|array<self::CLASS_CONSTRAINT|self::PROPERTY_CONSTRAINT> One or more constant values | |
* @return self::CLASS_CONSTRAINT|self::PROPERTY_CONSTRAINT|array<self::CLASS_CONSTRAINT|self::PROPERTY_CONSTRAINT> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed!
7f5ce66
to
bc81173
Compare
bc81173
to
5492bf4
Compare
Thank you @alexandre-daubois. |
…return types (xabbuh) This PR was merged into the 7.2 branch. Discussion ---------- [ErrorHandler] resolve class constant types when patching return types | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | | License | MIT account for types like the ones added in #58493 Commits ------- 01eb32c resolve class constant types when patching return types
Provides better static analysis on constraints.