10000 feature #27092 [Workflow] "clear()" instead of "reset()" (nicolas-gre… · symfony/symfony@5a5b925 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5a5b925

Browse files
committed
feature #27092 [Workflow] "clear()" instead of "reset()" (nicolas-grekas)
This PR was merged into the 4.1-dev branch. Discussion ---------- [Workflow] "clear()" instead of "reset()" | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - While working on another PR (to come), I noticed that the workflow component is using the word "reset" for something that is consistently called "clear" in the rest of the code base (emptying the state of an object) - and also that "reset" is consistently used for setting an object back to its initial state (which might not be the empty state, contrary to what clear does). Here is a PR fixing this inconsistency. Should be on 4.1 so that we won't have to deal with another BC layer in 4.2. Commits ------- 858fabb [Workflow] "clear()" instead of "reset()"
2 parents 697791c + 858fabb commit 5a5b925

File tree

6 files changed

+20
-5
lines changed

6 files changed

+20
-5
lines changed

UPGRADE-4.1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ Validator
154154
Workflow
155155
--------
156156

157+
* Deprecated the `DefinitionBuilder::reset()` method, use the `clear()` one instead.
157158
* Deprecated the `add` method in favor of the `addWorkflow` method in `Workflow\Registry`.
158159
* Deprecated `SupportStrategyInterface` in favor of `WorkflowSupportStrategyInterface`.
159160
* Deprecated the class `ClassInstanceSupportStrategy` in favor of the class `InstanceOfSupportStrategy`.

UPGRADE-5.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ Validator
107107
Workflow
108108
--------
109109

110+
* The `DefinitionBuilder::reset()` method has been removed, use the `clear()` one instead.
110111
* `add` method has been removed use `addWorkflow` method in `Workflow\Registry` instead.
111112
* `SupportStrategyInterface` has been removed, use `WorkflowSupportStrategyInterface` instead.
112113
* `ClassInstanceSupportStrategy` has been removed, use `InstanceOfSupportStrategy` instead.

src/Symfony/Component/Workflow/CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ CHANGELOG
44
4.1.0
55
-----
66

7-
* Deprecate the usage of `add(Workflow $workflow, $supportStrategy)` in `Workflow/Registry`, use `addWorkflow(WorkflowInterface, $supportStrategy)` instead.
8-
* Deprecate the usage of `SupportStrategyInterface`, use `WorkflowSupportStrategyInterface` instead.
7+
* Deprecated the `DefinitionBuilder::reset()` method, use the `clear()` one instead.
8+
* Deprecated the usage of `add(Workflow $workflow, $supportStrategy)` in `Workflow/Registry`, use `addWorkflow(WorkflowInterface, $supportStrategy)` instead.
9+
* Deprecated the usage of `SupportStrategyInterface`, use `WorkflowSupportStrategyInterface` instead.
910
* The `Workflow` class now implements `WorkflowInterface`.
1011
* Deprecated the class `ClassInstanceSupportStrategy` in favor of the class `InstanceOfSupportStrategy`.
1112
* Added TransitionBlockers as a way to pass around reasons why exactly

src/Symfony/Component/Workflow/DefinitionBuilder.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function build()
4747
*
4848
* @return $this
4949
*/
50-
public function reset()
50+
public function clear()
5151
{
5252
$this->places = array();
5353
$this->transitions = array();
@@ -121,4 +121,16 @@ public function addTransition(Transition $transition)
121121

122122
return $this;
123123
}
124+
125+
/**
126+
* @deprecated since Symfony 4.1, use the clear() method instead.
127+
*
128+
* @return $this
129+
*/
130+
public function reset()
131+
{
132+
@trigger_error(sprintf('The "%s" method is deprecated since Symfony 4.1, use the "clear()" method instead.', __METHOD__), E_USER_DEPRECATED);
133+
134+
return $this->clear();
135+
}
124136
}

src/Symfony/Component/Workflow/Event/GuardEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function isBlocked()
4242
public function setBlocked($blocked)
4343
{
4444
if (!$blocked) {
45-
$this->transitionBlockerList->reset();
45+
$this->transitionBlockerList->clear();
4646

4747
return;
4848
}

src/Symfony/Component/Workflow/TransitionBlockerList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function add(TransitionBlocker $blocker): void
3737
$this->blockers[] = $blocker;
3838
}
3939

40-
public function reset(): void
40+
public function clear(): void
4141
{
4242
$this->blockers = array();
4343
}

0 commit comments

Comments
 (0)
0