Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

Simperfit
Copy link
Contributor

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.

@Simperfit Simperfit force-pushed the feature/introduce-an-interface-for-the-workflow-component branch 2 times, most recently from df6cd73 to 4b25e0d Compare October 30, 2017 10:04
@nicolas-grekas nicolas-grekas added this to the 4.1 milestone Oct 30, 2017
@nicolas-grekas
Copy link
Member

Note that changing a public interface is a BC break, so this cannot be merged as is, isn't it?

@chalasr
Copy link
Member

chalasr commented Oct 30, 2017

@nicolas-grekas the upgrade note is misleading, this replaces the whole interface.

@chalasr chalasr self-requested a review October 30, 2017 20:51
@Simperfit
Copy link
Contributor Author

Simperfit commented Oct 30, 2017 via email

@Simperfit Simperfit force-pushed the feature/introduce-an-interface-for-the-workflow-component branch 4 times, most recently from 347c55e to a673253 Compare November 1, 2017 18:43
Copy link
Member

@lyrixx lyrixx left a 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`

Copy link
Member

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

@@ -5,6 +5,9 @@ CHANGELOG
-----

* 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
Copy link
Member

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 of add(Workflow $workflow, $supportStrategy)

@@ -28,8 +29,17 @@ class Registry
*/
public function add(Workflow $workflow, $supportStrategy)
{
if (!$supportStrategy instanceof SupportStrategyInterface) {
throw new \InvalidArgumentException('The "supportStrategy" is not an instance of SupportStrategyInterface.');
@trigger_error('add is deprecated since Symfony 4.0. Use addWorkflow instead', E_USER_DEPRECATED);
Copy link
Member

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)

public function addWorkflow(WorkflowInterface $workflow, $supportStrategy)
{
if ($supportStrategy instanceof SupportStrategyInterface) {
@trigger_error('Passing a SupportStrategyInterface in Registry::addWorkflow is deprecated since 4.0. Use SupportStrategyWorkflowInterface instead', E_USER_DEPRECATED);
Copy link
Member

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 ($supportStrategy instanceof SupportStrategyInterface) {
@trigger_error('Passing a SupportStrategyInterface in Registry::addWorkflow is deprecated since 4.0. Use SupportStrategyWorkflowInterface instead', E_USER_DEPRECATED);
}
if (!($supportStrategy instanceof SupportStrategyWorkflowInterface || $supportStrategy instanceof SupportStrategyInterface)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this if could be transformed in an elseif (!$supportStrategy instanceof SupportStrategyWorkflowInterface)

@@ -11,6 +11,8 @@

namespace Symfony\Component\Workflow\SupportStrategy;

@trigger_error('SupportStrategyInterface is deprecated since Symfony 4.0. Use SupportStrategyWorkflowInterface instead', E_USER_DEPRECATED);
Copy link
Member

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
*/
public function can($subject, $transitionName);
Copy link
Member

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

@Simperfit Simperfit force-pushed the feature/introduce-an-interface-for-the-workflow-component branch 4 times, most recently from a597789 to f59403d Compare November 2, 2017 19:38
@Simperfit
Copy link
Contributor Author

@lyrixx Thanks for the review :)

UPGRADE-4.0.md Outdated
@@ -913,7 +913,9 @@ Workflow
--------

* 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`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo here (strategry)

@Simperfit Simperfit force-pushed the feature/introduce-an-interface-for-the-workflow-component branch from f59403d to 6902c37 Compare November 3, 2017 09:14
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 `SupportStrategyWorkflowInterface`

Copy link
Member

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

Copy link
Contributor Author

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 ($supportStrategy instanceof SupportStrategyInterface) {
@trigger_error('Passing a "SupportStrategyInterface" in "Registry::addWorkflow" is deprecated since 4.0. Use "SupportStrategyWorkflowInterface" instead.', E_USER_DEPRECATED);
} elseif (!($supportStrategy instanceof SupportStrategyWorkflowInterface || $supportStrategy instanceof SupportStrategyInterface)) {
Copy link
Member

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.

Copy link
Contributor Author

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.

@Simperfit Simperfit force-pushed the feature/introduce-an-interface-for-the-workflow-component branch from 6902c37 to 116d678 Compare November 3, 2017 10:03
public function addWorkflow(WorkflowInterface $workflow, $supportStrategy)
{
if ($supportStrategy instanceof SupportStrategyInterface) {
@trigger_error('Passing a "SupportStrategyInterface" in "Registry::addWorkflow" is deprecated since 4.0. Use "SupportStrategyWorkflowInterface" instead.', E_USER_DEPRECATED);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strings should be replaced SupportsStrategyInterface::class, __METHOD and SupportStrategyWorkflowInterface::class in this order, we always use FQCNs

Copy link
Member

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 <[email protected]>
*/
final class ClassInstanceSupportStrategy implements SupportStrategyInterface
final class ClassInstanceSupportStrategy implements SupportStrategyWorkflowInterface
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ill open that PR.

@Simperfit Simperfit force-pushed the feature/introduce-an-interface-for-the-workflow-component branch from 116d678 to 6503755 Compare November 3, 2017 10:12
}

/**
* @return string
Copy link
Contributor

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 useless

@@ -6,20 +6,26 @@
use Symfony\Component\Workflow\SupportStrategy\ClassInstanceSupportStrategy;
use Symfony\Component\Workflow\Workflow;

/**
* @group legacy
Copy link
Contributor

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 about SubjectA + SubjectB for the new test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

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 :)

Copy link
Member

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
Copy link
Contributor

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 a SupportStrategyInterface? Using the new strategy interface should only go via addWorkflow IMHO.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree

@Simperfit Simperfit force-pushed the feature/introduce-an-interface-for-the-workflow-component branch 2 times, most recently from cab29ee to 860a174 Compare November 12, 2017 06:55
Copy link
Contributor

@ro0NL ro0NL left a 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 make Registry final since 3.4, so we can keep favoring add(); meaning less upgrade hassle for users as the common usecase would keep working, given Workflow implements WorkflowInterface tomorrow.

Also means we close extensibility on Registry, which we can open by introducing a RegistryInterface, when needed.

@@ -25,13 +26,17 @@ class Registry
/**
* @param Workflow $workflow
* @param SupportStrategyInterface $supportStrategy
*
* @deprecated since Symfony 4.1. Use addWorkflow() instead.
Copy link
Contributor

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.

*/
public function add(Workflow $workflow, $supportStrategy)
{
if (!$supportStrategy instanceof SupportStrategyInterface) {
Copy link
Contributor

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?

@@ -6,20 +6,26 @@
use Symfony\Component\Workflow\SupportStrategy\ClassInstanceSupportStrategy;
use Symfony\Component\Workflow\Workflow;

/**
* @group legacy
Copy link
Contributor

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 :)

*/
public function getEnabledTransitions($subject);

public function getName();
Copy link
Contributor

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).

Copy link
Contributor Author

@Simperfit Simperfit Dec 1, 2017

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
Copy link
Contributor Author

Simperfit commented Nov 14, 2017

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
Copy link
Member

chalasr commented Nov 15, 2017

It's not too late to say that Registry if final since 3.4

It is to me, 3.4 should not receive new deprecations anymore. I think this is fine.

@Simperfit
Copy link
Contributor Author

Ill take care of the 2 comments.

@ro0NL
Copy link
Contributor

ro0NL commented Nov 16, 2017

👍 lets go with addWorkflow. It's not like that's super bad or so.. but im not sure which method comes after that ;-) in case we need to patch this signature one day.

@dunglas
Copy link
Member

dunglas commented Nov 30, 2017

Needs a rebase.

@Simperfit Simperfit force-pushed the feature/introduce-an-interface-for-the-workflow-component branch 2 times, most recently from 1f0be16 to 41d3793 Compare December 1, 2017 12:19
@Simperfit
Copy link
Contributor Author

The PR has been rebased

*/
public function getEnabledTransitions($subject);

public function getName(): string;
Copy link
Member

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 to Workflow::getName() which would break BC

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@Simperfit Simperfit force-pushed the feature/introduce-an-interface-for-the-workflow-component branch from 41d3793 to a533a00 Compare December 1, 2017 16:08
@chalasr
Copy link
Member

chalasr commented Dec 4, 2017

Looks good to me.

Copy link
Member

@lyrixx lyrixx left a 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
Copy link
Member

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

Copy link
Contributor Author

@Simperfit Simperfit Dec 4, 2017

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`
Copy link
Member

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?

@Simperfit Simperfit force-pushed the feature/introduce-an-interface-for-the-workflow-component branch from a533a00 to e8351d8 Compare December 4, 2017 15:23
@Simperfit
Copy link
Contributor Author

done @lyrixx

@Simperfit
Copy link
Contributor Author

This PR is ready.

@lyrixx
Copy link
Member

lyrixx commented Dec 7, 2017

It took time, but here we go, this is in now. Thank you very much Hamza.

@lyrixx lyrixx merged commit e8351d8 into symfony:master Dec 7, 2017
lyrixx added a commit that referenced this pull request Dec 7, 2017
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
Copy link
Contributor Author

🎉 Thanks for your time @lyrixx @ro0NL @xabbuh @chalasr @nicolas-grekas

@fabpot fabpot mentioned this pull request May 7, 2018
fabpot added a commit that referenced this pull request Sep 10, 2023
…(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/A

The 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants