8000 minor #19187 [Workflow] CS tweaks (ro0NL) · symfony/symfony@f720444 · GitHub
[go: up one dir, main page]

Skip to content

Commit f720444

Browse files
committed
minor #19187 [Workflow] CS tweaks (ro0NL)
This PR was squashed before being merged into the 3.2-dev branch (closes #19187). Discussion ---------- [Workflow] CS tweaks | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | ~ | License | MIT | Doc PR | ~ Just a few minor tweaks/fixes after playing around with it. Some phpdoc should still be added imo, like missing `@throws`, right? Commits ------- 5428a92 [Workflow] CS tweaks
2 parents 764228f + 5428a92 commit f720444

13 files changed

+25
-36
lines changed

src/Symfony/Component/Workflow/Definition.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
class Definition
2222
{
2323
private $places = array();
24-
2524
private $transitions = array();
26-
2725
private $initialPlace;
2826

2927
/**

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,13 @@
2222
class Event extends BaseEvent
2323
{
2424
private $subject;
25-
2625
private $marking;
27-
2826
private $transition;
2927

3028
/**
3129
* Event constructor.
3230
*
33-
* @param mixed $subject
31+
* @param object $subject
3432
* @param Marking $marking
3533
* @param Transition $transition
3634
*/

src/Symfony/Component/Workflow/EventListener/AuditTrailListener.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ public function __construct(LoggerInterface $logger)
3030
public function onLeave(Event $event)
3131
{
3232
foreach ($event->getTransition()->getFroms() as $place) {
33-
$this->logger->info(sprintf('leaving "%s" for subject of class "%s"', $place, get_class($event->getSubject())));
33+
$this->logger->info(sprintf('Leaving "%s" for subject of class "%s".', $place, get_class($event->getSubject())));
3434
}
3535
}
3636

3737
public function onTransition(Event $event)
3838
{
39-
$this->logger->info(sprintf('transition "%s" for subject of class "%s"', $event->getTransition()->getName(), get_class($event->getSubject())));
39+
$this->logger->info(sprintf('Transition "%s" for subject of class "%s".', $event->getTransition()->getName(), get_class($event->getSubject())));
4040
}
4141

4242
public function onEnter(Event $event)
4343
{
4444
foreach ($event->getTransition()->getTos() as $place) {
45-
$this->logger->info(sprintf('entering "%s" for subject of class "%s"', $place, get_class($event->getSubject())));
45+
$this->logger->info(sprintf('Entering "%s" for subject of class "%s".', $place, get_class($event->getSubject())));
4646
}
4747
}
4848

src/Symfony/Component/Workflow/MarkingStore/PropertyAccessorMarkingStore.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
class PropertyAccessorMarkingStore implements MarkingStoreInterface
2424
{
2525
private $property;
26-
2726
private $propertyAccessor;
2827

2928
/**

src/Symfony/Component/Workflow/MarkingStore/ScalarMarkingStore.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
class ScalarMarkingStore implements MarkingStoreInterface, UniqueTransitionOutputInterface
2424
{
2525
private $property;
26-
2726
private $propertyAccessor;
2827

2928
/**

src/Symfony/Component/Workflow/Registry.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ class Registry
2323

2424
/**
2525
* @param Workflow $workflow
26-
* @param string $classname
26+
* @param string $className
2727
*/
28-
public function add(Workflow $workflow, $classname)
28+
public function add(Workflow $workflow, $className)
2929
{
30-
$this->workflows[] = array($workflow, $classname);
30+
$this->workflows[] = array($workflow, $className);
3131
}
3232

3333
public function get($subject, $workflowName = null)
3434
{
3535
$matched = null;
3636

37-
foreach ($this->workflows as list($workflow, $classname)) {
38-
if ($this->supports($workflow, $classname, $subject, $workflowName)) {
37+
foreach ($this->workflows as list($workflow, $className)) {
38+
if ($this->supports($workflow, $className, $subject, $workflowName)) {
3939
if ($matched) {
4040
throw new InvalidArgumentException('At least two workflows match this subject. Set a different name on each and use the second (name) argument of this method.');
4141
}
@@ -50,9 +50,9 @@ public function get($subject, $workflowName = null)
5050
return $matched;
5151
}
5252

53-
private function supports(Workflow $workflow, $classname, $subject, $name)
53+
private function supports(Workflow $workflow, $className, $subject, $name)
5454
{
55-
if (!$subject instanceof $classname) {
55+
if (!$subject instanceof $className) {
5656
return false;
5757
}
5858

src/Symfony/Component/Workflow/Tests/DefinitionTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testSetInitialPlace()
2828
}
2929

3030
/**
31-
* @expectedException Symfony\Component\Workflow\Exception\LogicException
31+
* @expectedException \Symfony\Component\Workflow\Exception\LogicException
3232
* @expectedExceptionMessage Place "d" cannot be the initial place as it does not exist.
3333
*/
3434
public function testSetInitialPlaceAndPlaceIsNotDefined()
@@ -50,7 +50,7 @@ public function testAddTransition()
5050
}
5151

5252
/**
53-
* @expectedException Symfony\Component\Workflow\Exception\LogicException
53+
* @expectedException \Symfony\Component\Workflow\Exception\LogicException
5454
* @expectedExceptionMessage Place "c" referenced in transition "name" does not exist.
5555
*/
5656
public function testAddTransitionAndFromPlaceIsNotDefined()
@@ -61,7 +61,7 @@ public function testAddTransitionAndFromPlaceIsNotDefined()
6161
}
6262

6363
/**
64-
* @expectedException Symfony\Component\Workflow\Exception\LogicException
64+
* @expectedException \Symfony\Component\Workflow\Exception\LogicException
6565
* @expectedExceptionMessage Place "c" referenced in transition "name" does not exist.
6666
*/
6767
public function testAddTransitionAndToPlaceIsNotDefined()

src/Symfony/Component/Workflow/Tests/EventListener/AuditTrailListenerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ public function testItWorks()
3434
$workflow->apply($object, 't1');
3535

3636
$expected = array(
37-
'leaving "a" for subject of class "stdClass"',
38-
'transition "t1" for subject of class "stdClass"',
39-
'entering "b" for subject of class "stdClass"',
37+
'Leaving "a" for subject of class "stdClass".',
38+
'Transition "t1" for subject of class "stdClass".',
39+
'Entering "b" for subject of class "stdClass".',
4040
);
4141

4242
$this->assertSame($expected, $logger->logs);

src/Symfony/Component/Workflow/Tests/RegistryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function testGetWithSuccess()
4444
}
4545

4646
/**
47-
* @expectedException Symfony\Component\Workflow\Exception\InvalidArgumentException
47+
* @expectedException \Symfony\Component\Workflow\Exception\InvalidArgumentException
4848
* @expectedExceptionMessage At least two workflows match this subject. Set a different name on each and use the second (name) argument of this method.
4949
*/
5050
public function testGetWithMultipleMatch()

src/Symfony/Component/Workflow/Tests/TransitionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class TransitionTest extends \PHPUnit_Framework_TestCase
88
{
99
/**
10-
* @expectedException Symfony\Component\Workflow\Exception\InvalidArgumentException
10+
* @expectedException \Symfony\Component\Workflow\Exception\InvalidArgumentException
1111
* @expectedExceptionMessage The transition "foo.bar" contains invalid characters.
1212
*/
1313
public function testValidateName()

src/Symfony/Component/Workflow/Tests/WorkflowTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class WorkflowTest extends \PHPUnit_Framework_TestCase
1616
{
1717
/**
18-
* @expectedException Symfony\Component\Workflow\Exception\LogicException
18+
* @expectedException \Symfony\Component\Workflow\Exception\LogicException
1919
* @expectedExceptionMessage The marking store (Symfony\Component\Workflow\MarkingStore\ScalarMarkingStore) of workflow "unnamed" can not store many places. But the transition "t1" has too many output (2). Only one is accepted.
2020
*/
2121
public function testConstructorWithUniqueTransitionOutputInterfaceAndComplexWorkflow()
@@ -35,7 +35,7 @@ public function testConstructorWithUniqueTransitionOutputInterfaceAndSimpleWorkf
3535
}
3636

3737
/**
38-
* @expectedException Symfony\Component\Workflow\Exception\LogicException
38+
* @expectedException \Symfony\Component\Workflow\Exception\LogicException
3939
* @expectedExceptionMessage The value returned by the MarkingStore is not an instance of "Symfony\Component\Workflow\Marking" for workflow "unnamed".
4040
*/
4141
public function testGetMarkingWithInvalidStoreReturn()
@@ -48,7 +48,7 @@ public function testGetMarkingWithInvalidStoreReturn()
4848
}
4949

5050
/**
51-
* @expectedException Symfony\Component\Workflow\Exception\LogicException
51+
* @expectedException \Symfony\Component\Workflow\Exception\LogicException
5252
* @expectedExceptionMessage The Marking is empty and there is no initial place for workflow "unnamed".
5353
*/
5454
public function testGetMarkingWithEmptyDefinition()
@@ -61,7 +61,7 @@ public function testGetMarkingWithEmptyDefinition()
6161
}
6262

6363
/**
64-
* @expectedException Symfony\Component\Workflow\Exception\LogicException
64+
* @expectedException \Symfony\Component\Workflow\Exception\LogicException
6565
* @expectedExceptionMessage Place "nope" is not valid for workflow "unnamed".
6666
*/
6767
public function testGetMarkingWithImpossiblePlace()
@@ -104,7 +104,7 @@ public function testGetMarkingWithExistingMarking()
104104
}
105105

106106
/**
107-
* @expectedException Symfony\Component\Workflow\Exception\LogicException
107+
* @expectedException \Symfony\Component\Workflow\Exception\LogicException
108108
* @expectedExceptionMessage Transition "foobar" does not exist for workflow "unnamed".
109109
*/
110110
public function testCanWithUnexistingTransition()
@@ -141,7 +141,7 @@ public function testCanWithGuard()
141141
}
142142

143143
/**
144-
* @expectedException Symfony\Component\Workflow\Exception\LogicException
144+
* @expectedException \Symfony\Component\Workflow\Exception\LogicException
145145
* @expectedExceptionMessage Unable to apply transition "t2" for workflow "unnamed".
146146
*/
147147
public function testApplyWithImpossibleTransition()

src/Symfony/Component/Workflow/Transition.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020
class Transition
2121
{
2222
private $name;
23-
2423
private $froms;
25-
2624
private $tos;
2725

2826
/**

src/Symfony/Component/Workflow/Workflow.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ public function can($subject, $transitionName)
109109
}
110110

111111
$transition = $transitions[$transitionName];
112-
113112
$marking = $this->getMarking($subject);
114113

115114
return $this->doCan($subject, $marking, $transition);
@@ -135,7 +134,6 @@ public function apply($subject, $transitionName)
135134
// We can shortcut the getMarking method in order to boost performance,
136135
// since the "can" method already checks the Marking state
137136
$marking = $this->markingStore->getMarking($subject);
138-
139137
$transition = $this->definition->getTransitions()[$transitionName];
140138

141139
$this->leave($subject, $transition, $marking);
@@ -161,7 +159,6 @@ public function apply($subject, $transitionName)
161159
public function getEnabledTransitions($subject)
162160
{
163161
$enabled = array();
164-
165162
$marking = $this->getMarking($subject);
166163

167164
foreach ($this->definition->getTransitions() as $transition) {

0 commit comments

Comments
 (0)
0