-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Various Workflow classes are declared final without any apparent reason. #36358
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
Comments
Hello @efthymiou , |
class Value {
/** @var int this may be 0 */
protected $marking;
// …
} Now the provided MethodMarkingStore has the following check in the public function getMarking(object $subject): Marking
{
// …
if (!$marking) {
return new Marking();
} That does not work in my case since 0, which is a valid value in my case, evaluates to false. What is the rationale behind the The |
Final classes help maintainance without removing any possibilities from users, usually. We need to first confirm your case cannot be addressed in any other way than inheritance before taking the hassle of increased maintenance overhead. |
Well I obviously can copy'n'paste the provided code and change the getMarking function accordingly. |
Wouldn't a custom marking store suffice in this case?
|
I do not use the yaml configuration, but yes as I said, I can make a custom MarkingStore by copy'n'pasting the code in MethodMarkingStore into MyMarkingStore |
Hello. I open 2 PRs in order to fix the following statement:
Using numeric for place name seems a bit odd to me. May I ask you why you prefer numeric over string with meanings?
What is your issue with this class? |
…king in MarkingStore (lyrixx) This PR was merged into the 3.4 branch. Discussion ---------- [Workflow] Use a strict comparison when retrieving raw marking in MarkingStore | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #36358 | License | MIT | Doc PR | Commits ------- aebe8ae [Workflow] Use a strict comparison when retrieving raw markin in MarkingStore
…king in MarkingStore (lyrixx) This PR was merged into the 4.4 branch. Discussion ---------- [Workflow] Use a strict comparison when retrieving raw marking in MarkingStore | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix ##36358 | License | MIT | Doc PR | Commits ------- a00a2f1 [Workflow] Use a strict comparison when retrieving raw marking in MarkingStore
I am converting a legacy system, where states are numeric constants. For the time being, converting the state type is not possible. While not the best choice IMO, numeric constants for status are not unusual.
It is also final. It does not seem sensible to me, as it is not in any way an internal class. I have to copy'n'paste the whole class, if I want to modify its behavior. |
how would you hook-in using extending? the answer should be applicable using decoration as well :) (composition over inheritance). |
Well you obviously follow some doctrine with final classes. I drop my case since I am neither a maintainer nor a contributor of this package. |
@lyrixx GuardEvent is also defined as final, which prevent from mocking it and unit-test the guard listeners receiving the event as argument. How are we supposed to unit test our guard listeners ? maybe you could provide a If this proposal is fine for you, i'd be happy to make a PR with that interface. |
Hello, |
Symfony version(s) affected: 5.0.7
Description
Various classes in symfony/workflow are decleared final, preventing extension. For example I cannot extend
Symfony\Component\Workflow\MarkingStore\MethodMarkingStore
to account for 0 values which are valid in my case.How to reproduce
Try extending Symfony\Component\Workflow\MarkingStore\MethodMarkingStore
Possible Solution
Remove final declaration from class.
Additional context
The text was updated successfully, but these errors were encountered: