10000 [Workflow] CS tweaks by ro0NL · Pull Request #19187 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Workflow] CS tweaks #19187

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

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/Symfony/Component/Workflow/Definition.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
class Definition
{
private $places = array();

private $transitions = array();

private $initialPlace;

/**
Expand Down
4 changes: 1 addition & 3 deletions src/Symfony/Component/Workflow/Event/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@
class Event extends BaseEvent
{
private $subject;

private $marking;

private $transition;

/**
* Event constructor.
*
* @param mixed $subject
* @param object $subject
* @param Marking $marking
* @param Transition $transition
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ public function __construct(LoggerInterface $logger)
public function onLeave(Event $event)
{
foreach ($event->getTransition()->getFroms() as $place) {
$this->logger->info(sprintf('leaving "%s" for subject of class "%s"', $place, get_class($event->getSubject())));
$this->logger->info(sprintf('Leaving "%s" for subject of class "%s".', $place, get_class($event->getSubject())));
}
}

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
class PropertyAccessorMarkingStore implements MarkingStoreInterface
{
private $property;

private $propertyAccessor;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
class ScalarMarkingStore implements MarkingStoreInterface, UniqueTransitionOutputInterface
{
private $property;

private $propertyAccessor;

/**
Expand Down
14 changes: 7 additions & 7 deletions src/Symfony/Component/Workflow/Registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ class Registry

/**
* @param Workflow $workflow
* @param string $classname
* @param string $className
*/
public function add(Workflow $workflow, $classname)
public function add(Workflow $workflow, $className)
{
$this->workflows[] = array($workflow, $classname);
$this->workflows[] = array($workflow, $className);
}

public function get($subject, $workflowName = null)
{
$matched = null;

foreach ($this->workflows as list($workflow, $classname)) {
if ($this->supports($workflow, $classname, $subject, $workflowName)) {
foreach ($this->workflows as list($workflow, $className)) {
if ($this->supports($workflow, $className, $subject, $workflowName)) {
if ($matched) {
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.');
}
Expand All @@ -50,9 +50,9 @@ public function get($subject, $workflowName = null)
return $matched;
}

private function supports(Workflow $workflow, $classname, $subject, $name)
private function supports(Workflow $workflow, $className, $subject, $name)
{
if (!$subject instanceof $classname) {
if (!$subject instanceof $className) {
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Workflow/Tests/DefinitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testSetInitialPlace()
}

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

/**
* @expectedException Symfony\Component\Workflow\Exception\LogicException
* @expectedException \Symfony\Component\Workflow\Exception\LogicException
* @expectedExceptionMessage Place "c" referenced in transition "name" does not exist.
*/
public function testAddTransitionAndFromPlaceIsNotDefined()
Expand All @@ -61,7 +61,7 @@ public function testAddTransitionAndFromPlaceIsNotDefined()
}

/**
* @expectedException Symfony\Component\Workflow\Exception\LogicException
* @expectedException \Symfony\Component\Workflow\Exception\LogicException
* @expectedExceptionMessage Place "c" referenced in transition "name" does not exist.
*/
public function testAddTransitionAndToPlaceIsNotDefined()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public function testItWorks()
$workflow->apply($object, 't1');

$expected = array(
'leaving "a" for subject of class "stdClass"',
'transition "t1" for subject of class "stdClass"',
'entering "b" for subject of class "stdClass"',
'Leaving "a" for subject of class "stdClass".',
'Transition "t1" for subject of class "stdClass".',
'Entering "b" for subject of class "stdClass".',
);

$this->assertSame($expected, $logger->logs);
Expan F438 d Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Workflow/Tests/RegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testGetWithSuccess()
}

/**
* @expectedException Symfony\Component\Workflow\Exception\InvalidArgumentException
* @expectedException \Symfony\Component\Workflow\Exception\InvalidArgumentException
* @expectedExceptionMessage At least two workflows match this subject. Set a different name on each and use the second (name) argument of this method.
*/
public function testGetWithMultipleMatch()
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Workflow/Tests/TransitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class TransitionTest extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException Symfony\Component\Workflow\Exception\InvalidArgumentException
* @expectedException \Symfony\Component\Workflow\Exception\InvalidArgumentException
* @expectedExceptionMessage The transition "foo.bar" contains invalid characters.
*/
public function testValidateName()
Expand Down
12 changes: 6 additions & 6 deletions src/Symfony/Component/Workflow/Tests/WorkflowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class WorkflowTest extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException Symfony\Component\Workflow\Exception\LogicException
* @expectedException \Symfony\Component\Workflow\Exception\LogicException
* @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.
*/
public function testConstructorWithUniqueTransitionOutputInterfaceAndComplexWorkflow()
Expand All @@ -35,7 +35,7 @@ public function testConstructorWithUniqueTransitionOutputInterfaceAndSimpleWorkf
}

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

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

/**
* @expectedException Symfony\Component\Workflow\Exception\LogicException
* @expectedException \Symfony\Component\Workflow\Exception\LogicException
* @expectedExceptionMessage Place "nope" is not valid for workflow "unnamed".
*/
public function testGetMarkingWithImpossiblePlace()
Expand Down Expand Up @@ -104,7 +104,7 @@ public function testGetMarkingWithExistingMarking()
}

/**
* @expectedException Symfony\Component\Workflow\Exception\LogicException
* @expectedException \Symfony\Component\Workflow\Exception\LogicException
* @expectedExceptionMessage Transition "foobar" does not exist for workflow "unnamed".
*/
public function testCanWithUnexistingTransition()
Expand Down Expand Up @@ -141,7 +141,7 @@ public function testCanWithGuard()
}

/**
* @expectedException Symfony\Component\Workflow\Exception\LogicException
* @expectedException \Symfony\Component\Workflow\Exception\LogicException
* @expectedExceptionMessage Unable to apply transition "t2" for workflow "unnamed".
*/
public function testApplyWithImpossibleTransition()
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Workflow/Transition.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
class Transition
{
private $name;

private $froms;

private $tos;

/**
Expand Down
3 changes: 0 additions & 3 deletions src/Symfony/Component/Workflow/Workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ public function can($subject, $transitionName)
}

$transition = $transitions[$transitionName];

$marking = $this->getMarking($subject);

return $this->doCan($subject, $marking, $transition);
Expand All @@ -135,7 +134,6 @@ public function apply($subject, $transitionName)
// We can shortcut the getMarking method in order to boost performance,
// since the "can" method already checks the Marking state
$marking = $this->markingStore->getMarking($subject);

$transition = $this->definition->getTransitions()[$transitionName];

$this->leave($subject, $transition, $marking);
Expand All @@ -161,7 +159,6 @@ public function apply($subject, $transitionName)
public function getEnabledTransitions($subject)
{
$enabled = array();

$marking = $this->getMarking($subject);

foreach ($this->definition->getTransitions() as $transition) {
Expand Down
0