Skip to content

Commit 4b25bea

Browse files
committed
switched array() to []
1 parent 5036cc9 commit 4b25bea

29 files changed

+142
-142
lines changed

Definition.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
*/
2222
final class Definition
2323
{
24-
private $places = array();
25-
private $transitions = array();
24+
private $places = [];
25+
private $transitions = [];
2626
private $initialPlace;
2727

2828
/**

DefinitionBuilder.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
*/
2323
class DefinitionBuilder
2424
{
25-
private $places = array();
26-
private $transitions = array();
25+
private $places = [];
26+
private $transitions = [];
2727
private $initialPlace;
2828

2929
/**
3030
* @param string[] $places
3131
* @param Transition[] $transitions
3232
*/
33-
public function __construct(array $places = array(), array $transitions = array())
33+
public function __construct(array $places = [], array $transitions = [])
3434
{
3535
$this->addPlaces($places);
3636
$this->addTransitions($transitions);
@@ -51,8 +51,8 @@ public function build()
5151
*/
5252
public function reset()
5353
{
54-
$this->places = array();
55-
$this->transitions = array();
54+
$this->places = [];
55+
$this->transitions = [];
5656
$this->initialPlace = null;
5757

5858
return $this;

Dumper/DumperInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ interface DumperInterface
3131
*
3232
* @return string The representation of the workflow
3333
*/
34-
public function dump(Definition $definition, Marking $marking = null, array $options = array());
34+
public function dump(Definition $definition, Marking $marking = null, array $options = []);
3535
}

Dumper/GraphvizDumper.php

+21-21
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
*/
2727
class GraphvizDumper implements DumperInterface
2828
{
29-
protected static $defaultOptions = array(
30-
'graph' => array('ratio' => 'compress', 'rankdir' => 'LR'),
31-
'node' => array('fontsize' => 9, 'fontname' => 'Arial', 'color' => '#333333', 'fillcolor' => 'lightblue', 'fixedsize' => true, 'width' => 1),
32-
'edge' => array('fontsize' => 9, 'fontname' => 'Arial', 'color' => '#333333', 'arrowhead' => 'normal', 'arrowsize' => 0.5),
33-
);
29+
protected static $defaultOptions = [
30+
'graph' => ['ratio' => 'compress', 'rankdir' => 'LR'],
31+
'node' => ['fontsize' => 9, 'fontname' => 'Arial', 'color' => '#333333', 'fillcolor' => 'lightblue', 'fixedsize' => true, 'width' => 1],
32+
'edge' => ['fontsize' => 9, 'fontname' => 'Arial', 'color' => '#333333', 'arrowhead' => 'normal', 'arrowsize' => 0.5],
33+
];
3434

3535
/**
3636
* {@inheritdoc}
@@ -43,7 +43,7 @@ class GraphvizDumper implements DumperInterface
4343
* * node: The default options for nodes (places + transitions)
4444
* * edge: The default options for edges
4545
*/
46-
public function dump(Definition $definition, Marking $marking = null, array $options = array())
46+
public function dump(Definition $definition, Marking $marking = null, array $options = [])
4747
{
4848
$places = $this->findPlaces($definition, $marking);
4949
$transitions = $this->findTransitions($definition);
@@ -63,20 +63,20 @@ public function dump(Definition $definition, Marking $marking = null, array $opt
6363
*/
6464
protected function findPlaces(Definition $definition, Marking $marking = null)
6565
{
66-
$places = array();
66+
$places = [];
6767

6868
foreach ($definition->getPlaces() as $place) {
69-
$attributes = array();
69+
$attributes = [];
7070
if ($place === $definition->getInitialPlace()) {
7171
$attributes['style'] = 'filled';
7272
}
7373
if ($marking && $marking->has($place)) {
7474
$attributes['color'] = '#FF0000';
7575
$attributes['shape'] = 'doublecircle';
7676
}
77-
$places[$place] = array(
77+
$places[$place] = [
7878
'attributes' => $attributes,
79-
);
79+
];
8080
}
8181

8282
return $places;
@@ -87,13 +87,13 @@ protected function findPlaces(Definition $definition, Marking $marking = null)
8787
*/
8888
protected function findTransitions(Definition $definition)
8989
{
90-
$transitions = array();
90+
$transitions = [];
9191

9292
foreach ($definition->getTransitions() as $transition) {
93-
$transitions[] = array(
94-
'attributes' => array('shape' => 'box', 'regular' => true),
93+
$transitions[] = [
94+
'attributes' => ['shape' => 'box', 'regular' => true],
9595
'name' => $transition->getName(),
96-
);
96+
];
9797
}
9898

9999
return $transitions;
@@ -132,22 +132,22 @@ protected function addTransitions(array $transitions)
132132
*/
133133
protected function findEdges(Definition $definition)
134134
{
135-
$dotEdges = array();
135+
$dotEdges = [];
136136

137137
foreach ($definition->getTransitions() as $transition) {
138138
foreach ($transition->getFroms() as $from) {
139-
$dotEdges[] = array(
139+
$dotEdges[] = [
140140
'from' => $from,
141141
'to' => $transition->getName(),
142142
'direction' => 'from',
143-
);
143+
];
144144
}
145145
foreach ($transition->getTos() as $to) {
146-
$dotEdges[] = array(
146+
$dotEdges[] = [
147147
'from' => $transition->getName(),
148148
'to' => $to,
149149
'direction' => 'to',
150-
);
150+
];
151151
}
152152
}
153153

@@ -203,7 +203,7 @@ protected function dotize($id)
203203

204204
private function addAttributes(array $attributes)
205205
{
206-
$code = array();
206+
$code = [];
207207

208208
foreach ($attributes as $k => $v) {
209209
$code[] = sprintf('%s="%s"', $k, $v);
@@ -214,7 +214,7 @@ private function addAttributes(array $attributes)
214214

215215
private function addOptions(array $options)
216216
{
217-
$code = array();
217+
$code = [];
218218

219219
foreach ($options as $k => $v) {
220220
$code[] = sprintf('%s="%s"', $k, $v);

Dumper/StateMachineGraphvizDumper.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class StateMachineGraphvizDumper extends GraphvizDumper
2727
* * node: The default options for nodes (places)
2828
* * edge: The default options for edges
2929
*/
30-
public function dump(Definition $definition, Marking $marking = null, array $options = array())
30+
public function dump(Definition $definition, Marking $marking = null, array $options = [])
3131
{
3232
$places = $this->findPlaces($definition, $marking);
3333
$edges = $this->findEdges($definition);
@@ -46,15 +46,15 @@ public function dump(Definition $definition, Marking $marking = null, array $opt
4646
*/
4747
protected function findEdges(Definition $definition)
4848
{
49-
$edges = array();
49+
$edges = [];
5050

5151
foreach ($definition->getTransitions() as $transition) {
5252
foreach ($transition->getFroms() as $from) {
5353
foreach ($transition->getTos() as $to) {
54-
$edges[$from][] = array(
54+
$edges[$from][] = [
5555
'name' => $transition->getName(),
5656
'to' => $to,
57-
);
57+
];
5858
}
5959
}
6060
}

EventListener/AuditTrailListener.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ public function onEnter(Event $event)
4848

4949
public static function getSubscribedEvents()
5050
{
51-
return array(
52-
'workflow.leave' => array('onLeave'),
53-
'workflow.transition' => array('onTransition'),
54-
'workflow.enter' => array('onEnter'),
55-
);
51+
return [
52+
'workflow.leave' => ['onLeave'],
53+
'workflow.transition' => ['onTransition'],
54+
'workflow.enter' => ['onEnter'],
55+
];
5656
}
5757
}

EventListener/GuardListener.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private function getVariables(GuardEvent $event)
8484
$roles = $token->getRoles();
8585
}
8686

87-
$variables = array(
87+
$variables = [
8888
'token' => $token,
8989
'user' => $token->getUser(),
9090
'subject' => $event->getSubject(),
@@ -97,7 +97,7 @@ private function getVariables(GuardEvent $event)
9797
'trust_resolver' => $this->trustResolver,
9898
// needed for the is_valid expression function
9999
'validator' => $this->validator,
100-
);
100+
];
101101

102102
return $variables;
103103
}

Marking.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
*/
1919
class Marking
2020
{
21-
private $places = array();
21+
private $places = [];
2222

2323
/**
2424
* @param int[] $representation Keys are the place name and values should be 1
2525
*/
26-
public function __construct(array $representation = array())
26+
public function __construct(array $representation = [])
2727
{
2828
foreach ($representation as $place => $nbToken) {
2929
$this->mark($place);

MarkingStore/MultipleStateMarkingStore.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct($property = 'marking', PropertyAccessorInterface $pr
4444
*/
4545
public function getMarking($subject)
4646
{
47-
return new Marking($this->propertyAccessor->getValue($subject, $this->property) ?: array());
47+
return new Marking($this->propertyAccessor->getValue($subject, $this->property) ?: []);
4848
}
4949

5050
/**

MarkingStore/SingleStateMarkingStore.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function getMarking($subject)
4949
return new Marking();
5050
}
5151

52-
return new Marking(array($placeName => 1));
52+
return new Marking([$placeName => 1]);
5353
}
5454

5555
/**

Registry.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
class Registry
2323
{
24-
private $workflows = array();
24+
private $workflows = [];
2525

2626
/**
2727
* @param Workflow $workflow
@@ -35,7 +35,7 @@ public function add(Workflow $workflow, $supportStrategy)
3535
$supportStrategy = new ClassInstanceSupportStrategy($supportStrategy);
3636
}
3737

38-
$this->workflows[] = array($workflow, $supportStrategy);
38+
$this->workflows[] = [$workflow, $supportStrategy];
3939
}
4040

4141
/**

Tests/DefinitionBuilderTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ class DefinitionBuilderTest extends TestCase
1313
*/
1414
public function testAddPlaceInvalidName()
1515
{
16-
$builder = new DefinitionBuilder(array('a"', 'b'));
16+
$builder = new DefinitionBuilder(['a"', 'b']);
1717
}
1818

1919
public function testSetInitialPlace()
2020
{
21-
$builder = new DefinitionBuilder(array('a', 'b'));
21+
$builder = new DefinitionBuilder(['a', 'b']);
2222
$builder->setInitialPlace('b');
2323
$definition = $builder->build();
2424

@@ -31,7 +31,7 @@ public function testAddTransition()
3131

3232
$transition0 = new Transition('name0', $places[0], $places[1]);
3333
$transition1 = new Transition('name1', $places[0], $places[1]);
34-
$builder = new DefinitionBuilder($places, array($transition0));
34+
$builder = new DefinitionBuilder($places, [$transition0]);
3535
$builder->addTransition($transition1);
3636

3737
$definition = $builder->build();
@@ -43,7 +43,7 @@ public function testAddTransition()
4343

4444
public function testAddPlace()
4545
{
46-
$builder = new DefinitionBuilder(array('a'), array());
46+
$builder = new DefinitionBuilder(['a'], []);
4747
$builder->addPlace('b');
4848

4949
$definition = $builder->build();

Tests/DefinitionTest.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class DefinitionTest extends TestCase
1111
public function testAddPlaces()
1212
{
1313
$places = range('a', 'e');
14-
$definition = new Definition($places, array());
14+
$definition = new Definition($places, []);
1515

1616
$this->assertCount(5, $definition->getPlaces());
1717

@@ -23,14 +23,14 @@ public function testAddPlaces()
2323
*/
2424
public function testAddPlacesInvalidArgument()
2525
{
26-
$places = array('a"', 'e"');
27-
$definition = new Definition($places, array());
26+
$places = ['a"', 'e"'];
27+
$definition = new Definition($places, []);
2828
}
2929

3030
public function testSetInitialPlace()
3131
{
3232
$places = range('a', 'e');
33-
$definition = new Definition($places, array(), $places[3]);
33+
$definition = new Definition($places, [], $places[3]);
3434

3535
$this->assertEquals($places[3], $definition->getInitialPlace());
3636
}
@@ -41,15 +41,15 @@ public function testSetInitialPlace()
4141
*/
4242
public function testSetInitialPlaceAndPlaceIsNotDefined()
4343
{
44-
$definition = new Definition(array(), array(), 'd');
44+
$definition = new Definition([], [], 'd');
4545
}
4646

4747
public function testAddTransition()
4848
{
4949
$places = range('a', 'b');
5050

5151
$transition = new Transition('name', $places[0], $places[1]);
52-
$definition = new Definition($places, array($transition));
52+
$definition = new Definition($places, [$transition]);
5353

5454
$this->assertCount(1, $definition->getTransitions());
5555
$this->assertSame($transition, $definition->getTransitions()[0]);
@@ -63,7 +63,7 @@ public function testAddTransitionAndFromPlaceIsNotDefined()
6363
{
6464
$places = range('a', 'b');
6565

66-
new Definition($places, array(new Transition('name', 'c', $places[1])));
66+
new Definition($places, [new Transition('name', 'c', $places[1])]);
6767
}
6868

6969
/**
@@ -74,6 +74,6 @@ public function testAddTransitionAndToPlaceIsNotDefined()
7474
{
7575
$places = range('a', 'b');
7676

77-
new Definition($places, array(new Transition('name', $places[0], 'c')));
77+
new Definition($places, [new Transition('name', $places[0], 'c')]);
7878
}
7979
}

Tests/DependencyInjection/ValidateWorkflowsPassTest.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ public function testProcess()
1515
{
1616
$container = new ContainerBuilder();
1717
$container->register('definition1', WorkflowDefinition::class)
18-
->addArgument(array('a', 'b', 'c'))
19-
->addArgument(array(
20-
new Definition(Transition::class, array('t1', 'a', 'b')),
21-
new Definition(Transition::class, array('t2', 'a', 'c')),
22-
))
23-
->addTag('workflow.definition', array('name' => 'wf1', 'type' => 'state_machine', 'marking_store' => 'foo'));
18+
->addArgument(['a', 'b', 'c'])
19+
->addArgument([
20+
new Definition(Transition::class, ['t1', 'a', 'b']),
21+
new Definition(Transition::class, ['t2', 'a', 'c']),
22+
])
23+
->addTag('workflow.definition', ['name' => 'wf1', 'type' => 'state_machine', 'marking_store' => 'foo']);
2424

2525
(new ValidateWorkflowsPass())->process($container);
2626

2727
$workflowDefinition = $container->get('definition1');
2828

29-
$this->assertSame(array('a' => 'a', 'b' => 'b', 'c' => 'c'), $workflowDefinition->getPlaces());
30-
$this->assertEquals(array(new Transition('t1', 'a', 'b'), new Transition('t2', 'a', 'c')), $workflowDefinition->getTransitions());
29+
$this->assertSame(['a' => 'a', 'b' => 'b', 'c' => 'c'], $workflowDefinition->getPlaces());
30+
$this->assertEquals([new Transition('t1', 'a', 'b'), new Transition('t2', 'a', 'c')], $workflowDefinition->getTransitions());
3131
}
3232
}

0 commit comments

Comments
 (0)