Skip to content
This repository has been archived by the owner on Nov 30, 2017. It is now read-only.

Commit

Permalink
run sylius-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
bendavies committed Jan 29, 2016
1 parent 532a32f commit abf0d44
Show file tree
Hide file tree
Showing 19 changed files with 72 additions and 73 deletions.
2 changes: 1 addition & 1 deletion DependencyInjection/Compiler/RegisterScenariosPass.php
Expand Up @@ -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)]);
}
}
}
2 changes: 1 addition & 1 deletion DependencyInjection/Compiler/RegisterSessionBagsPass.php
Expand Up @@ -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')]);
}
}
2 changes: 1 addition & 1 deletion DependencyInjection/Compiler/RegisterStepsPass.php
Expand Up @@ -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)]);
}
}
}
4 changes: 2 additions & 2 deletions DependencyInjection/SyliusFlowExtension.php
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion Process/Builder/ProcessBuilderInterface.php
Expand Up @@ -52,7 +52,7 @@ public function remove($name);
*
* @param string $name
*
* @return Boolean
* @return bool
*/
public function has($name);

Expand Down
6 changes: 3 additions & 3 deletions Process/Context/ProcessContext.php
Expand Up @@ -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);
}
Expand Down Expand Up @@ -251,7 +251,7 @@ public function getProgress()
*/
public function getStepHistory()
{
return $this->storage->get('history', array());
return $this->storage->get('history', []);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions Process/Coordinator/Coordinator.php
Expand Up @@ -57,7 +57,7 @@ class Coordinator implements CoordinatorInterface
*
* @var array
*/
protected $scenarios = array();
protected $scenarios = [];

/**
* Constructor.
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions Process/Process.php
Expand Up @@ -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
Expand All @@ -60,7 +60,7 @@ class Process implements ProcessInterface
*
* @var array
*/
protected $displayRouteParams = array();
protected $displayRouteParams = [];

/**
* Forward action route.
Expand All @@ -74,7 +74,7 @@ class Process implements ProcessInterface
*
* @var array
*/
protected $forwardRouteParams = array();
protected $forwardRouteParams = [];

/**
* Redirect route.
Expand All @@ -88,7 +88,7 @@ class Process implements ProcessInterface
*
* @var array
*/
protected $redirectParams = array();
protected $redirectParams = [];

/**
* {@inheritdoc}
Expand Down
2 changes: 1 addition & 1 deletion Storage/SessionFlowsBag.php
Expand Up @@ -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.
Expand Down
14 changes: 7 additions & 7 deletions spec/DependencyInjection/Compiler/RegisterScenariosPassSpec.php
Expand Up @@ -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();

Expand Down
14 changes: 7 additions & 7 deletions spec/DependencyInjection/Compiler/RegisterStepsPassSpec.php
Expand Up @@ -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();

Expand Down
34 changes: 16 additions & 18 deletions spec/Process/Context/ProcessContextSpec.php
Expand Up @@ -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);
Expand All @@ -56,7 +56,6 @@ function it_initializes(
$this->getPreviousStep()->shouldReturn($previousStep);
}


function it_is_valid(
$storage,
ProcessInterface $process,
Expand All @@ -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);
Expand All @@ -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,
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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');
}

Expand All @@ -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();
}
Expand Down
1 change: 0 additions & 1 deletion spec/Process/Coordinator/InvalidArgumentExceptionSpec.php
Expand Up @@ -12,7 +12,6 @@
namespace spec\Sylius\Bundle\FlowBundle\Process\Coordinator;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

class InvalidArgumentExceptionSpec extends ObjectBehavior
{
Expand Down
20 changes: 9 additions & 11 deletions spec/Process/ProcessSpec.php
Expand Up @@ -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;
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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]);
}

}
10 changes: 9 additions & 1 deletion spec/Process/Step/ActionResultSpec.php
@@ -1,9 +1,17 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace spec\Sylius\Bundle\FlowBundle\Process\Step;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

class ActionResultSpec extends ObjectBehavior
{
Expand Down

0 comments on commit abf0d44

Please sign in to comment.