-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Workflow] Add generic template for event classes #44622
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
[Workflow] Add generic template for event classes #44622
Conversation
Can you elaborate your motivation for this change? Why do you need these annotations? |
Also, please target the 6.1 branch. |
For PHPStorm generic support. |
The Psalm error looks related. |
That's a very generic answer (no pun intended). Can you be more specific? How do the annotations help you? What would PhpStorm do differently if we added them to the codebase? |
Event
and his inheritors and …
What are you mean, when you say "What would PhpStorm do differently if we added them to the codebase?". I think it's not about what PHPStorm do differently, it's about, when we can Annotate Event with |
That kind-of answers my question, I guess. Would it make sense to add the template type for the subject to the workflow object as well? |
We can add, but in workflow it will be do nothing because it's only be available in library. |
@@ -43,6 +48,9 @@ public function getMarking() | |||
return $this->marking; | |||
} | |||
|
|||
/** | |||
* @return TSubject|object |
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.
This does not look correct. We should always get a TSubject
here. Wasn't that the whole point of the PR?
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.
Nope, in this case psalm have issue, says that it can be object or Tsubject
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.
What issue? https://psalm.dev/r/4582b1218d
if anything, adding |object
creates an issue.
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.
I will remove it now, and we see
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.
@ro0NL And, here we have the issue https://github.com/symfony/symfony/runs/453131776
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.
Weird. Maybe try to reproduce on psalm.dev, but here psalm seems wrong AFAIK.
To make psalm happy, I think you need to add |
You can check upper, I already do this, but @derrabus don't happy with it. |
Well, we need to annotate both the constructor and the property, because the property inference of psalm is done based on the native argument type rather than the phpdoc type (and in that case, we need the more precise type |
Added, fixed. |
I think the last commit is worked |
…for `Event::$subject` and `Event::getSubject()`
Added generic template for
Event
in Workflow ComponentAdded generic template for
Event
,Event::$subject
andEvent::getSubject()
for PHPStorm support.