From abf0d444c3ee4ef6f2238158ac0d41e38c7d2018 Mon Sep 17 00:00:00 2001 From: Ben Davies Date: Fri, 29 Jan 2016 16:34:34 +0000 Subject: [PATCH] run sylius-cs-fixer --- .../Compiler/RegisterScenariosPass.php | 2 +- .../Compiler/RegisterSessionBagsPass.php | 2 +- .../Compiler/RegisterStepsPass.php | 2 +- DependencyInjection/SyliusFlowExtension.php | 4 +-- Process/Builder/ProcessBuilderInterface.php | 2 +- Process/Context/ProcessContext.php | 6 ++-- Process/Coordinator/Coordinator.php | 12 +++---- Process/Process.php | 10 +++--- Storage/SessionFlowsBag.php | 2 +- .../Compiler/RegisterScenariosPassSpec.php | 14 ++++---- .../Compiler/RegisterStepsPassSpec.php | 14 ++++---- spec/Process/Context/ProcessContextSpec.php | 34 +++++++++---------- .../InvalidArgumentExceptionSpec.php | 1 - spec/Process/ProcessSpec.php | 20 +++++------ spec/Process/Step/ActionResultSpec.php | 10 +++++- spec/Storage/SessionFlowsBagSpec.php | 1 - spec/Storage/SessionStorageSpec.php | 1 - .../ProcessValidatorExceptionSpec.php | 1 - spec/Validator/ProcessValidatorSpec.php | 7 ++-- 19 files changed, 72 insertions(+), 73 deletions(-) diff --git a/DependencyInjection/Compiler/RegisterScenariosPass.php b/DependencyInjection/Compiler/RegisterScenariosPass.php index 43f07fe..fc3bb23 100644 --- a/DependencyInjection/Compiler/RegisterScenariosPass.php +++ b/DependencyInjection/Compiler/RegisterScenariosPass.php @@ -30,7 +30,7 @@ public function process(ContainerBuilder $container) $coordinator = $container->getDefinition('sylius.process.coordinator'); foreach ($container->findTaggedServiceIds('sylius.process.scenario') as $id => $attributes) { - $coordinator->addMethodCall('registerScenario', array($attributes[0]['alias'], new Reference($id))); + $coordinator->addMethodCall('registerScenario', [$attributes[0]['alias'], new Reference($id)]); } } } diff --git a/DependencyInjection/Compiler/RegisterSessionBagsPass.php b/DependencyInjection/Compiler/RegisterSessionBagsPass.php index fcc97c4..29834e0 100644 --- a/DependencyInjection/Compiler/RegisterSessionBagsPass.php +++ b/DependencyInjection/Compiler/RegisterSessionBagsPass.php @@ -28,6 +28,6 @@ class RegisterSessionBagsPass implements CompilerPassInterface public function process(ContainerBuilder $container) { $session = $container->getDefinition('session'); - $session->addMethodCall('registerBag', array(new Reference('sylius.process_storage.session.bag'))); + $session->addMethodCall('registerBag', [new Reference('sylius.process_storage.session.bag')]); } } diff --git a/DependencyInjection/Compiler/RegisterStepsPass.php b/DependencyInjection/Compiler/RegisterStepsPass.php index 3b05a76..e74c30d 100644 --- a/DependencyInjection/Compiler/RegisterStepsPass.php +++ b/DependencyInjection/Compiler/RegisterStepsPass.php @@ -30,7 +30,7 @@ public function process(ContainerBuilder $container) $processBuilder = $container->getDefinition('sylius.process.builder'); foreach ($container->findTaggedServiceIds('sylius.process.step') as $id => $attributes) { - $processBuilder->addMethodCall('registerStep', array($attributes[0]['alias'], new Reference($id))); + $processBuilder->addMethodCall('registerStep', [$attributes[0]['alias'], new Reference($id)]); } } } diff --git a/DependencyInjection/SyliusFlowExtension.php b/DependencyInjection/SyliusFlowExtension.php index 137c21f..e39ea6e 100644 --- a/DependencyInjection/SyliusFlowExtension.php +++ b/DependencyInjection/SyliusFlowExtension.php @@ -38,14 +38,14 @@ public function load(array $config, ContainerBuilder $container) $container->setAlias('sylius.process_storage', $config['storage']); - $configurations = array( + $configurations = [ 'builders', 'validators', 'contexts', 'controllers', 'coordinators', 'storages', - ); + ]; foreach ($configurations as $basename) { $loader->load(sprintf('%s.xml', $basename)); diff --git a/Process/Builder/ProcessBuilderInterface.php b/Process/Builder/ProcessBuilderInterface.php index 0b2aae8..5565693 100644 --- a/Process/Builder/ProcessBuilderInterface.php +++ b/Process/Builder/ProcessBuilderInterface.php @@ -52,7 +52,7 @@ public function remove($name); * * @param string $name * - * @return Boolean + * @return bool */ public function has($name); diff --git a/Process/Context/ProcessContext.php b/Process/Context/ProcessContext.php index bf82cb0..7e549e2 100644 --- a/Process/Context/ProcessContext.php +++ b/Process/Context/ProcessContext.php @@ -104,8 +104,8 @@ public function initialize(ProcessInterface $process, StepInterface $currentStep foreach ($steps as $index => $step) { if ($step === $currentStep) { - $this->previousStep = isset($steps[$index-1]) ? $steps[$index-1] : null; - $this->nextStep = isset($steps[$index+1]) ? $steps[$index+1] : null; + $this->previousStep = isset($steps[$index - 1]) ? $steps[$index - 1] : null; + $this->nextStep = isset($steps[$index + 1]) ? $steps[$index + 1] : null; $this->calculateProgress($index); } @@ -251,7 +251,7 @@ public function getProgress() */ public function getStepHistory() { - return $this->storage->get('history', array()); + return $this->storage->get('history', []); } /** diff --git a/Process/Coordinator/Coordinator.php b/Process/Coordinator/Coordinator.php index 7abe31b..6d377d5 100644 --- a/Process/Coordinator/Coordinator.php +++ b/Process/Coordinator/Coordinator.php @@ -57,7 +57,7 @@ class Coordinator implements CoordinatorInterface * * @var array */ - protected $scenarios = array(); + protected $scenarios = []; /** * Constructor. @@ -216,18 +216,18 @@ protected function redirectToStepDisplayAction( if (null !== $route = $process->getDisplayRoute()) { $url = $this->router->generate($route, array_merge( $process->getDisplayRouteParams(), - array('stepName' => $step->getName()), - $queryParameters ? $queryParameters->all() : array() + ['stepName' => $step->getName()], + $queryParameters ? $queryParameters->all() : [] )); return new RedirectResponse($url); } // Default parameters for display route - $routeParameters = array( + $routeParameters = [ 'scenarioAlias' => $process->getScenarioAlias(), - 'stepName' => $step->getName(), - ); + 'stepName' => $step->getName(), + ]; if (null !== $queryParameters) { $routeParameters = array_merge($queryParameters->all(), $routeParameters); diff --git a/Process/Process.php b/Process/Process.php index b55fe44..9b2291e 100644 --- a/Process/Process.php +++ b/Process/Process.php @@ -34,14 +34,14 @@ class Process implements ProcessInterface * * @var StepInterface[] */ - protected $steps = array(); + protected $steps = []; /** * Ordered steps. * * @var StepInterface[] */ - protected $orderedSteps = array(); + protected $orderedSteps = []; /** * @var ProcessValidatorInterface @@ -60,7 +60,7 @@ class Process implements ProcessInterface * * @var array */ - protected $displayRouteParams = array(); + protected $displayRouteParams = []; /** * Forward action route. @@ -74,7 +74,7 @@ class Process implements ProcessInterface * * @var array */ - protected $forwardRouteParams = array(); + protected $forwardRouteParams = []; /** * Redirect route. @@ -88,7 +88,7 @@ class Process implements ProcessInterface * * @var array */ - protected $redirectParams = array(); + protected $redirectParams = []; /** * {@inheritdoc} diff --git a/Storage/SessionFlowsBag.php b/Storage/SessionFlowsBag.php index a9dbac3..d6c5059 100644 --- a/Storage/SessionFlowsBag.php +++ b/Storage/SessionFlowsBag.php @@ -21,7 +21,7 @@ class SessionFlowsBag extends NamespacedAttributeBag { const STORAGE_KEY = '_sylius_flow_bag'; - const NAME = '_sylius_flow_bag'; + const NAME = '_sylius_flow_bag'; /** * Constructor. diff --git a/spec/DependencyInjection/Compiler/RegisterScenariosPassSpec.php b/spec/DependencyInjection/Compiler/RegisterScenariosPassSpec.php index c0332ce..3e96b9e 100644 --- a/spec/DependencyInjection/Compiler/RegisterScenariosPassSpec.php +++ b/spec/DependencyInjection/Compiler/RegisterScenariosPassSpec.php @@ -32,13 +32,13 @@ function it_is_compiler_pass() function it_processes(ContainerBuilder $container, Definition $coordinator) { $container->getDefinition('sylius.process.coordinator')->shouldBeCalled()->willreturn($coordinator); - $container->findTaggedServiceIds('sylius.process.scenario')->shouldBeCalled()->willreturn(array( - 'id' => array( - array( - 'alias' => 'alias' - ) - ) - )); + $container->findTaggedServiceIds('sylius.process.scenario')->shouldBeCalled()->willreturn([ + 'id' => [ + [ + 'alias' => 'alias', + ], + ], + ]); $coordinator->addMethodCall('registerScenario', Argument::type('array'))->shouldBeCalled(); diff --git a/spec/DependencyInjection/Compiler/RegisterStepsPassSpec.php b/spec/DependencyInjection/Compiler/RegisterStepsPassSpec.php index 48964b4..57cf19f 100644 --- a/spec/DependencyInjection/Compiler/RegisterStepsPassSpec.php +++ b/spec/DependencyInjection/Compiler/RegisterStepsPassSpec.php @@ -32,13 +32,13 @@ function it_is_compiler_pass() function it_processes(ContainerBuilder $container, Definition $coordinator) { $container->getDefinition('sylius.process.builder')->shouldBeCalled()->willreturn($coordinator); - $container->findTaggedServiceIds('sylius.process.step')->shouldBeCalled()->willreturn(array( - 'id' => array( - array( - 'alias' => 'alias' - ) - ) - )); + $container->findTaggedServiceIds('sylius.process.step')->shouldBeCalled()->willreturn([ + 'id' => [ + [ + 'alias' => 'alias', + ], + ], + ]); $coordinator->addMethodCall('registerStep', Argument::type('array'))->shouldBeCalled(); diff --git a/spec/Process/Context/ProcessContextSpec.php b/spec/Process/Context/ProcessContextSpec.php index a4cb352..eb36445 100644 --- a/spec/Process/Context/ProcessContextSpec.php +++ b/spec/Process/Context/ProcessContextSpec.php @@ -46,7 +46,7 @@ function it_initializes( ) { $process->getScenarioAlias()->shouldBeCalled(); $storage->initialize(Argument::type('string'))->shouldBeCalled(); - $process->getOrderedSteps()->shouldBeCalled()->willReturn(array($previousStep, $currentStep, $nextStep)); + $process->getOrderedSteps()->shouldBeCalled()->willReturn([$previousStep, $currentStep, $nextStep]); $process->countSteps()->shouldBeCalled()->willReturn(3); $this->initialize($process, $currentStep); @@ -56,7 +56,6 @@ function it_initializes( $this->getPreviousStep()->shouldReturn($previousStep); } - function it_is_valid( $storage, ProcessInterface $process, @@ -67,7 +66,7 @@ function it_is_valid( ) { $process->getScenarioAlias()->shouldBeCalled(); $storage->initialize(Argument::type('string'))->shouldBeCalled(); - $process->getOrderedSteps()->shouldBeCalled()->willReturn(array($previousStep, $currentStep, $nextStep)); + $process->getOrderedSteps()->shouldBeCalled()->willReturn([$previousStep, $currentStep, $nextStep]); $process->countSteps()->shouldBeCalled()->willReturn(3); $this->initialize($process, $currentStep); @@ -81,21 +80,20 @@ function it_is_valid( $process->getValidator()->willReturn(null); $currentStep->getName()->willReturn('current_step'); - $storage->get('history', array())->shouldBeCalled()->willReturn(array()); + $storage->get('history', [])->shouldBeCalled()->willReturn([]); $this->isValid()->shouldReturn(true); $process->getValidator()->willReturn(null); $currentStep->getName()->shouldBeCalled()->willReturn('current_step'); - $storage->get('history', array())->shouldBeCalled()->willReturn(array('current_step')); + $storage->get('history', [])->shouldBeCalled()->willReturn(['current_step']); $this->isValid()->shouldReturn(true); $process->getValidator()->willReturn(null); $currentStep->getName()->shouldBeCalled()->willReturn('other_step'); - $storage->get('history', array())->shouldBeCalled()->willReturn(array('current_step')); + $storage->get('history', [])->shouldBeCalled()->willReturn(['current_step']); $this->isValid()->shouldReturn(false); } - function it_checks_if_it_is_the_first_step( $storage, ProcessInterface $process, @@ -104,7 +102,7 @@ function it_checks_if_it_is_the_first_step( ) { $process->getScenarioAlias()->shouldBeCalled(); $storage->initialize(Argument::type('string'))->shouldBeCalled(); - $process->getOrderedSteps()->shouldBeCalled()->willReturn(array($firstStep, $lastStep)); + $process->getOrderedSteps()->shouldBeCalled()->willReturn([$firstStep, $lastStep]); $process->countSteps()->shouldBeCalled()->willReturn(2); $this->initialize($process, $firstStep); @@ -120,7 +118,7 @@ function it_checks_if_it_is_the_last_step( ) { $process->getScenarioAlias()->shouldBeCalled(); $storage->initialize(Argument::type('string'))->shouldBeCalled(); - $process->getOrderedSteps()->shouldBeCalled()->willReturn(array($firstStep, $lastStep)); + $process->getOrderedSteps()->shouldBeCalled()->willReturn([$firstStep, $lastStep]); $process->countSteps()->shouldBeCalled()->willReturn(2); $this->initialize($process, $lastStep); @@ -136,7 +134,7 @@ function it_closes_the_storage( ) { $process->getScenarioAlias()->shouldBeCalled(); $storage->initialize(Argument::type('string'))->shouldBeCalled(); - $process->getOrderedSteps()->shouldBeCalled()->willReturn(array($firstStep, $lastStep)); + $process->getOrderedSteps()->shouldBeCalled()->willReturn([$firstStep, $lastStep]); $process->countSteps()->shouldBeCalled()->willReturn(2); $this->initialize($process, $lastStep); @@ -160,12 +158,12 @@ function its_storage_is_mutable(StorageInterface $storage) function its_step_history_is_mutable($storage) { - $storage->set('history', array('step_one'))->shouldBeCalled(); - $storage->get('history', array())->willReturn(array('step_one')); - $storage->set('history', array('step_one', 'step_two'))->shouldBeCalled(); - $storage->get('history', array('step_one'))->willReturn(array('step_one', 'step_two')); + $storage->set('history', ['step_one'])->shouldBeCalled(); + $storage->get('history', [])->willReturn(['step_one']); + $storage->set('history', ['step_one', 'step_two'])->shouldBeCalled(); + $storage->get('history', ['step_one'])->willReturn(['step_one', 'step_two']); - $this->setStepHistory(array('step_one')); + $this->setStepHistory(['step_one']); $this->addStepToHistory('step_two'); } @@ -179,12 +177,12 @@ function it_rewind_history( $currentStep->getName()->willReturn('step_two'); $process->getScenarioAlias()->shouldBeCalled(); $storage->initialize(Argument::type('string'))->shouldBeCalled(); - $process->getOrderedSteps()->shouldBeCalled()->willReturn(array($previousStep, $currentStep, $nextStep)); + $process->getOrderedSteps()->shouldBeCalled()->willReturn([$previousStep, $currentStep, $nextStep]); $process->countSteps()->shouldBeCalled()->willReturn(2); $this->initialize($process, $currentStep); - $storage->get("history", array())->shouldBeCalled()->willreturn(array("step_one", "step_two", "step_three")); - $storage->set('history', array('step_one', 'step_two'))->shouldBeCalled(); + $storage->get('history', [])->shouldBeCalled()->willreturn(['step_one', 'step_two', 'step_three']); + $storage->set('history', ['step_one', 'step_two'])->shouldBeCalled(); $this->rewindHistory(); } diff --git a/spec/Process/Coordinator/InvalidArgumentExceptionSpec.php b/spec/Process/Coordinator/InvalidArgumentExceptionSpec.php index 64ac8a0..b3ea41c 100644 --- a/spec/Process/Coordinator/InvalidArgumentExceptionSpec.php +++ b/spec/Process/Coordinator/InvalidArgumentExceptionSpec.php @@ -12,7 +12,6 @@ namespace spec\Sylius\Bundle\FlowBundle\Process\Coordinator; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; class InvalidArgumentExceptionSpec extends ObjectBehavior { diff --git a/spec/Process/ProcessSpec.php b/spec/Process/ProcessSpec.php index 1909a16..324649a 100644 --- a/spec/Process/ProcessSpec.php +++ b/spec/Process/ProcessSpec.php @@ -12,7 +12,6 @@ namespace spec\Sylius\Bundle\FlowBundle\Process; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; use Sylius\Bundle\FlowBundle\Process\ProcessInterface; use Sylius\Bundle\FlowBundle\Process\Step\StepInterface; use Sylius\Bundle\FlowBundle\Validator\ProcessValidatorInterface; @@ -37,8 +36,8 @@ function its_forward_route_is_mutable() function its_forward_route_params_is_mutable() { - $this->setForwardRouteParams(array('name' => 'value')); - $this->getForwardRouteParams()->shouldReturn(array('name' => 'value')); + $this->setForwardRouteParams(['name' => 'value']); + $this->getForwardRouteParams()->shouldReturn(['name' => 'value']); } function its_display_route_is_mutable() @@ -49,14 +48,14 @@ function its_display_route_is_mutable() function its_display_params_is_mutable() { - $this->setDisplayRouteParams(array('name' => 'value')); - $this->getDisplayRouteParams()->shouldReturn(array('name' => 'value')); + $this->setDisplayRouteParams(['name' => 'value']); + $this->getDisplayRouteParams()->shouldReturn(['name' => 'value']); } function its_redirect_params_is_mutable() { - $this->setRedirectParams(array('name' => 'value')); - $this->getRedirectParams()->shouldReturn(array('name' => 'value')); + $this->setRedirectParams(['name' => 'value']); + $this->getRedirectParams()->shouldReturn(['name' => 'value']); } function its_redirect_is_mutable() @@ -81,13 +80,12 @@ function its_step_is_mutable(StepInterface $step, StepInterface $secondStep) { $step->getName()->shouldBeCalled()->willReturn('name'); $secondStep->getName()->shouldBeCalled()->willReturn('other_name'); - $this->setSteps(array('name' => $step)); + $this->setSteps(['name' => $step]); $this->addStep('other_name', $secondStep); $this->removeStep('name'); - $this->getSteps()->shouldReturn(array('other_name' => $secondStep)); - $this->getOrderedSteps()->shouldReturn(array($secondStep)); + $this->getSteps()->shouldReturn(['other_name' => $secondStep]); + $this->getOrderedSteps()->shouldReturn([$secondStep]); } - } diff --git a/spec/Process/Step/ActionResultSpec.php b/spec/Process/Step/ActionResultSpec.php index ee3bba8..0202ac6 100644 --- a/spec/Process/Step/ActionResultSpec.php +++ b/spec/Process/Step/ActionResultSpec.php @@ -1,9 +1,17 @@ beConstructedWith('message', 'step_name', function(){}); + $this->beConstructedWith('message', 'step_name', function () {}); } function it_is_initializable() @@ -48,7 +47,7 @@ function its_message_is_mutable() function its_validation_is_mutable() { - $closure = function(){}; + $closure = function () {}; $this->setValidation($closure)->shouldReturn($this); $this->getValidation()->shouldReturn($closure); @@ -56,7 +55,7 @@ function its_validation_is_mutable() function it_calls_validation_closure(ProcessContextInterface $processContext) { - $this->setValidation(function() { + $this->setValidation(function () { return true; });