Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Workflow] Introduce a Workflow interface#24751
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
[Workflow] Introduce a Workflow interface#24751
Uh oh!
There was an error while loading.Please reload this page.
Conversation
df6cd73 to4b25e0dComparenicolas-grekas commentedOct 30, 2017
Note that changing a public interface is a BC break, so this cannot be merged as is, isn't it? |
chalasr commentedOct 30, 2017
@nicolas-grekas the upgrade note is misleading, this replaces the whole interface. |
Simperfit commentedOct 30, 2017 via email• edited by lyrixx
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by lyrixx
Uh oh!
There was an error while loading.Please reload this page.
I guess i have to update the upgrade node |
347c55e toa673253Compare
lyrixx left a comment
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.
Some minor comments, but it's good.
Thanks.
UPGRADE-4.0.md Outdated
| * Deprecated the `add` method in favor of the `addWorkflow` method in `Workflow\Registry` | ||
| * Deprecated the interface `SupportStrategyInterface` in favor of the interface `SupportStrategryWorkflowInterface` | ||
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.
Looks like there is a space here
| ----- | ||
| * Removed class name support in`WorkflowRegistry::add()` as second parameter. | ||
| * Deprecate the usage of`add(Workflow $workflow, $supportStrategy) in`Workflow/Registry` use`addWorkflow(WorkflowInterface, $supportStrategy)` instead |
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.
missing backquote at the end ofadd(Workflow $workflow, $supportStrategy)
| { | ||
| if (!$supportStrategyinstanceof SupportStrategyInterface) { | ||
| thrownew \InvalidArgumentException('The "supportStrategy" is not an instance of SupportStrategyInterface.'); | ||
| @trigger_error('add is deprecated since Symfony 4.0. Use addWorkflow instead',E_USER_DEPRECATED); |
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.
'add' method is ... use 'addWorkflow' insteand.
(don't miss the final dot)
| publicfunctionaddWorkflow(WorkflowInterface$workflow,$supportStrategy) | ||
| { | ||
| if ($supportStrategyinstanceof SupportStrategyInterface) { | ||
| @trigger_error('Passing a SupportStrategyInterface in Registry::addWorkflow is deprecated since 4.0. Use SupportStrategyWorkflowInterface instead',E_USER_DEPRECATED); |
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.
use quote to surround class name and add a final dot.
| if ($supportStrategyinstanceof SupportStrategyInterface) { | ||
| @trigger_error('Passing a SupportStrategyInterface in Registry::addWorkflow is deprecated since 4.0. Use SupportStrategyWorkflowInterface instead',E_USER_DEPRECATED); | ||
| } | ||
| if (!($supportStrategyinstanceof SupportStrategyWorkflowInterface ||$supportStrategyinstanceof SupportStrategyInterface)) { |
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.
thisif could be transformed in anelseif (!$supportStrategy instanceof SupportStrategyWorkflowInterface)
| namespaceSymfony\Component\Workflow\SupportStrategy; | ||
| @trigger_error('SupportStrategyInterface is deprecated since Symfony 4.0. Use SupportStrategyWorkflowInterface instead',E_USER_DEPRECATED); |
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.
please add a final dot
| * | ||
| * @return bool true if the transition is enabled | ||
| */ | ||
| publicfunctioncan($subject,$transitionName); |
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.
Hm, if getMarking can throw an exception, then can and apply may throw an exception too
a597789 tof59403dCompareSimperfit commentedNov 2, 2017
@lyrixx Thanks for the review :) |
UPGRADE-4.0.md Outdated
| * Removed class name support in `WorkflowRegistry::add()` as second parameter. | ||
| * Deprecated the `add` method in favor of the `addWorkflow` method in `Workflow\Registry` | ||
| * Deprecated the interface `SupportStrategyInterface` in favor of the interface `SupportStrategryWorkflowInterface` |
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.
typo here (strategry)
f59403d to6902c37CompareUPGRADE-4.0.md Outdated
| * Deprecated the `add` method in favor of the `addWorkflow` method in `Workflow\Registry` | ||
| * Deprecated the interface `SupportStrategyInterface` in favor of the interface `SupportStrategyWorkflowInterface` | ||
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.
And now there are two spaces here. You need to configure your editor to remove automatically all trailing spaces :D
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.
Yeah, you are right, I didn't configure it to do so !
| { | ||
| if ($supportStrategyinstanceof SupportStrategyInterface) { | ||
| @trigger_error('Passing a "SupportStrategyInterface" in "Registry::addWorkflow" is deprecated since 4.0. Use "SupportStrategyWorkflowInterface" instead.',E_USER_DEPRECATED); | ||
| }elseif (!($supportStrategyinstanceof SupportStrategyWorkflowInterface ||$supportStrategyinstanceof SupportStrategyInterface)) { |
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 looks like you did not simplified the condition.
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.
Yeah, sorry, that's modified.
6902c37 to116d678Compare| publicfunctionaddWorkflow(WorkflowInterface$workflow,$supportStrategy) | ||
| { | ||
| if ($supportStrategyinstanceof SupportStrategyInterface) { | ||
| @trigger_error('Passing a "SupportStrategyInterface" in "Registry::addWorkflow" is deprecated since 4.0. Use "SupportStrategyWorkflowInterface" instead.',E_USER_DEPRECATED); |
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.
strings should be replacedSupportsStrategyInterface::class,__METHOD andSupportStrategyWorkflowInterface::class in this order, we always use FQCNs
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.
same for the exception below
| * @author Andreas Kleemann <akleemann@inviqa.com> | ||
| */ | ||
| finalclass ClassInstanceSupportStrategyimplementsSupportStrategyInterface | ||
| finalclass ClassInstanceSupportStrategyimplementsSupportStrategyWorkflowInterface |
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.
Not implementing the old interface is a BC break ($strategy instanceof SupportsStrategyInterface returning false). Personally I wouldn't care, this could be internal
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 think this is internal too.
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.
Internal should be hinted by an annotation, we can't have a policy of telling "that's internal" and break BC.
I suggest to open a PR against 3.4 to really mark them internal so that we're free to change in 4.1.
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.
Ill open that PR.
116d678 to6503755Compare| } | ||
| /** | ||
| * @return string |
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.
aren't we trying to get rid of these kind docblocks?
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.
👍 useless
| useSymfony\Component\Workflow\Workflow; | ||
| /** | ||
| * @group legacy |
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 file basically only needs this change.. what aboutSubjectA +SubjectB for the new test?
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.
done
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.
still.. no real reason to optimize/tweak a legacy test (::class notation, class removals). Doesnt hurt; just extra diff :)
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, adding the::class notation was ok because the line was actually changed. Now it just gives merge conflicts, should be reverted
| * @param Workflow $workflow | ||
| * @param SupportStrategyInterface $supportStrategy | ||
| * @param Workflow $workflow | ||
| * @param WorkflowSupportStrategyInterface $supportStrategy |
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.
the BC layer actually expects aSupportStrategyInterface? Using the new strategy interface should only go viaaddWorkflow IMHO.
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.
Agree
cab29ee to860a174CompareThere 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.
nice work :) i also asked@nicolas-grekas if this is really the desired upgrade path.
Basically i see one other option; to makeRegistry final since 3.4, so we can keep favoringadd(); meaning less upgrade hassle for users as the common usecase would keep working, givenWorkflow implements WorkflowInterface tomorrow.
Also means we close extensibility onRegistry, which we can open by introducing aRegistryInterface, when needed.
| * @param Workflow $workflow | ||
| * @param SupportStrategyInterface $supportStrategy | ||
| * | ||
| * @deprecated since Symfony 4.1. Use addWorkflow() instead. |
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.
@deprecated since version 4.1, to be removed in 5.0. Use addWorkflow() instead.
| */ | ||
| publicfunctionadd(Workflow$workflow,$supportStrategy) | ||
| { | ||
| if (!$supportStrategyinstanceof SupportStrategyInterface) { |
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.
doesnt hurt to keep right? or why shouldnt it?
| useSymfony\Component\Workflow\Workflow; | ||
| /** | ||
| * @group legacy |
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.
still.. no real reason to optimize/tweak a legacy test (::class notation, class removals). Doesnt hurt; just extra diff :)
| */ | ||
| publicfunctiongetEnabledTransitions($subject); | ||
| publicfunctiongetName(); |
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.
missing type info + {@inheritdoc} in sub class (id prefer a@return string here).
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.
maybe we could typehint it instead of phpdoc ?
Simperfit commentedNov 14, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
WDYT of@ro0NL's path ? It's not too late to say that Registry is final since 3.4@nicolas-grekas ? I guess it could be a thing too to be able to re-implement the registry, and users won't need to change alot of thing. I think it's a good idea@ro0NL. (i'll take care of the comments, I just want to wait a little for others' thoughts). |
chalasr commentedNov 15, 2017
It is to me, 3.4 should not receive new deprecations anymore. I think this is fine. |
Simperfit commentedNov 16, 2017
Ill take care of the 2 comments. |
ro0NL commentedNov 16, 2017
👍 lets go with |
dunglas commentedNov 30, 2017
Needs a rebase. |
1f0be16 to41d3793CompareSimperfit commentedDec 1, 2017
The PR has been rebased |
| */ | ||
| publicfunctiongetEnabledTransitions($subject); | ||
| publicfunctiongetName():string; |
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.
return type should be removed, otherwise it requires to add it toWorkflow::getName() which would break BC
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.
removed
41d3793 toa533a00Comparechalasr commentedDec 4, 2017
Looks good to me. |
lyrixx left a comment
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.
Sorry, I left one (two) extra comment.
I'm 👍 after the changes.
| * @param WorkflowInterface $workflow | ||
| * @param object $subject | ||
| * | ||
| * @return bool |
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.
Sorry about asking again some change, but we don't need this PHP doc. Could you remove it?
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.
Don't be sorry, that's why the PR are made for ;)
UPGRADE-4.1.md Outdated
| Workflow | ||
| -------- | ||
| * Deprecated the`add` method in favor of the`addWorkflow` method in`Workflow\Registry` |
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.
As I asked a mandatory change, Can I also ask you to add a final dot on each line of each .md updated?
a533a00 toe8351d8CompareSimperfit commentedDec 4, 2017
done@lyrixx |
Simperfit commentedDec 4, 2017
This PR is ready. |
lyrixx commentedDec 7, 2017
It took time, but here we go, this is in now. Thank you very much Hamza. |
This PR was merged into the 4.1-dev branch.Discussion----------[Workflow] Introduce a Workflow interface| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | yes| Tests pass? | yes| Fixed tickets |#23910| License | MIT| Doc PR | todo@chalasr I think all the points you made in 23910 has been done. Needs to update the docs too.Commits-------e8351d8 [Workflow] Introduce a Workflow interface
Simperfit commentedDec 7, 2017
🎉 Thanks for your time@lyrixx@ro0NL@xabbuh@chalasr@nicolas-grekas |
…(derrabus)This PR was merged into the 6.4 branch.Discussion----------[TwigBridge] Remove obsolete Workflow feature detection| Q | A| ------------- | ---| Branch? | 6.4| Bug fix? | no| New feature? | no| Deprecations? | no| Tickets | N/A| License | MIT| Doc PR | N/AThe classes and methods that are detected here have been introduced with#24751 and#26092 (both Symfony 4.1)Commits-------7e9d5bb [TwigBridge] Remove obsolete Workflow feature detection
@chalasr I think all the points you made in 23910 has been done. Needs to update the docs too.