From 1eb10b996a32b7d45b35a9eaa3fd7c81c78d8cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Thu, 3 Oct 2019 18:07:59 +0200 Subject: [PATCH] [Workflow] Fixed BC break on WorkflowInterface --- UPGRADE-4.3.md | 22 +++++++++++++++++++ UPGRADE-5.0.md | 1 + .../MarkingStore/MarkingStoreInterface.php | 2 +- src/Symfony/Component/Workflow/Workflow.php | 6 ++++- .../Component/Workflow/WorkflowInterface.php | 3 ++- 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/UPGRADE-4.3.md b/UPGRADE-4.3.md index cb66993901..86155031fa 100644 --- a/UPGRADE-4.3.md +++ b/UPGRADE-4.3.md @@ -242,6 +242,28 @@ Workflow initial_marking: [draft] ``` + * `WorkflowInterface::apply()` will have a third argument in Symfony 5.0. + + Before: + ```php + class MyWorkflow implements WorkflowInterface + { + public function apply($subject, $transitionName) + { + } + } + ``` + + After: + ```php + class MyWorkflow implements WorkflowInterface + { + public function apply($subject, $transitionName, array $context = []) + { + } + } + ``` + * `MarkingStoreInterface::setMarking()` will have a third argument in Symfony 5.0. Before: diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index 4767811d00..455cd0d62a 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -414,6 +414,7 @@ Workflow * `add` method has been removed use `addWorkflow` method in `Workflow\Registry` instead. * `SupportStrategyInterface` has been removed, use `WorkflowSupportStrategyInterface` instead. * `ClassInstanceSupportStrategy` has been removed, use `InstanceOfSupportStrategy` instead. + * `WorkflowInterface::apply()` has a third argument: `array $context = []`. * `MarkingStoreInterface::setMarking()` has a third argument: `array $context = []`. * Removed support of `initial_place`. Use `initial_places` instead. * `MultipleStateMarkingStore` has been removed. Use `MethodMarkingStore` instead. diff --git a/src/Symfony/Component/Workflow/MarkingStore/MarkingStoreInterface.php b/src/Symfony/Component/Workflow/MarkingStore/MarkingStoreInterface.php index a932f99c8b..3ff0a89bef 100644 --- a/src/Symfony/Component/Workflow/MarkingStore/MarkingStoreInterface.php +++ b/src/Symfony/Component/Workflow/MarkingStore/MarkingStoreInterface.php @@ -39,5 +39,5 @@ interface MarkingStoreInterface * @param object $subject A subject * @param array $context Some context */ - public function setMarking($subject, Marking $marking /*, array $context = []*/); + public function setMarking($subject, Marking $marking/*, array $context = []*/); } diff --git a/src/Symfony/Component/Workflow/Workflow.php b/src/Symfony/Component/Workflow/Workflow.php index 76e53eda51..2d56bd9ee5 100644 --- a/src/Symfony/Component/Workflow/Workflow.php +++ b/src/Symfony/Component/Workflow/Workflow.php @@ -150,9 +150,13 @@ class Workflow implements WorkflowInterface /** * {@inheritdoc} + * + * @param array $context Some context */ - public function apply($subject, $transitionName, array $context = []) + public function apply($subject, $transitionName/*, array $context = []*/) { + $context = \func_get_args()[2] ?? []; + $marking = $this->getMarking($subject); $transitionBlockerList = null; diff --git a/src/Symfony/Component/Workflow/WorkflowInterface.php b/src/Symfony/Component/Workflow/WorkflowInterface.php index d6de18fee5..b43a5c7bcc 100644 --- a/src/Symfony/Component/Workflow/WorkflowInterface.php +++ b/src/Symfony/Component/Workflow/WorkflowInterface.php @@ -53,12 +53,13 @@ interface WorkflowInterface * * @param object $subject A subject * @param string $transitionName A transition + * @param array $context Some context * * @return Marking The new Marking * * @throws LogicException If the transition is not applicable */ - public function apply($subject, $transitionName, array $context = []); + public function apply($subject, $transitionName/*, array $context = []*/); /** * Returns all enabled transitions.