Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 29a930f

Browse files
committed
Merge branch 'feature/php-short-array-syntax'
2 parents 5a281c5 + b2a5536 commit 29a930f

File tree

143 files changed

+3114
-3113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+3114
-3113
lines changed

.php_cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ $config->fixers(
3232
'object_operator',
3333
'php_closing_tag',
3434
'remove_lines_between_uses',
35+
'short_array_syntax',
3536
'short_tag',
3637
'standardize_not_equal',
3738
'trailing_spaces',

src/Annotation/AnnotationBuilder.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class AnnotationBuilder implements EventManagerAwareInterface, FormFactoryAwareI
5757
/**
5858
* @var array Default annotations to register
5959
*/
60-
protected $defaultAnnotations = array(
60+
protected $defaultAnnotations = [
6161
'AllowEmpty',
6262
'Attributes',
6363
'ComposedObject',
@@ -77,7 +77,7 @@ class AnnotationBuilder implements EventManagerAwareInterface, FormFactoryAwareI
7777
'Type',
7878
'ValidationGroup',
7979
'Validator'
80-
);
80+
];
8181

8282
/**
8383
* @var bool
@@ -122,10 +122,10 @@ public function setAnnotationManager(AnnotationManager $annotationManager)
122122
*/
123123
public function setEventManager(EventManagerInterface $events)
124124
{
125-
$events->setIdentifiers(array(
125+
$events->setIdentifiers([
126126
__CLASS__,
127127
get_class($this),
128-
));
128+
]);
129129
$events->attach(new ElementAnnotationsListener());
130130
$events->attach(new FormAnnotationsListener());
131131
$this->events = $events;
@@ -271,18 +271,18 @@ protected function configureForm($annotations, $reflection, $formSpec, $filterSp
271271
{
272272
$name = $this->discoverName($annotations, $reflection);
273273
$formSpec['name'] = $name;
274-
$formSpec['attributes'] = array();
275-
$formSpec['elements'] = array();
276-
$formSpec['fieldsets'] = array();
274+
$formSpec['attributes'] = [];
275+
$formSpec['elements'] = [];
276+
$formSpec['fieldsets'] = [];
277277

278278
$events = $this->getEventManager();
279279
foreach ($annotations as $annotation) {
280-
$events->trigger(__FUNCTION__, $this, array(
280+
$events->trigger(__FUNCTION__, $this, [
281281
'annotation' => $annotation,
282282
'name' => $name,
283283
'formSpec' => $formSpec,
284284
'filterSpec' => $filterSpec,
285-
));
285+
]);
286286
}
287287
}
288288

@@ -308,24 +308,24 @@ protected function configureElement($annotations, $reflection, $formSpec, $filte
308308
$events = $this->getEventManager();
309309
$name = $this->discoverName($annotations, $reflection);
310310

311-
$elementSpec = new ArrayObject(array(
312-
'flags' => array(),
313-
'spec' => array(
311+
$elementSpec = new ArrayObject([
312+
'flags' => [],
313+
'spec' => [
314314
'name' => $name
315-
),
316-
));
317-
$inputSpec = new ArrayObject(array(
315+
],
316+
]);
317+
$inputSpec = new ArrayObject([
318318
'name' => $name,
319-
));
319+
]);
320320

321321
$event = new Event();
322-
$event->setParams(array(
322+
$event->setParams([
323323
'name' => $name,
324324
'elementSpec' => $elementSpec,
325325
'inputSpec' => $inputSpec,
326326
'formSpec' => $formSpec,
327327
'filterSpec' => $filterSpec,
328-
));
328+
]);
329329
foreach ($annotations as $annotation) {
330330
$event->setParam('annotation', $annotation);
331331
$events->trigger(__FUNCTION__, $this, $event);
@@ -351,12 +351,12 @@ protected function configureElement($annotations, $reflection, $formSpec, $filte
351351
// If preserve defined order is true, all elements are composed as elements to keep their ordering
352352
if (!$this->preserveDefinedOrder() && is_subclass_of($type, 'Zend\Form\FieldsetInterface')) {
353353
if (!isset($formSpec['fieldsets'])) {
354-
$formSpec['fieldsets'] = array();
354+
$formSpec['fieldsets'] = [];
355355
}
356356
$formSpec['fieldsets'][] = $elementSpec;
357357
} else {
358358
if (!isset($formSpec['elements'])) {
359-
$formSpec['elements'] = array();
359+
$formSpec['elements'] = [];
360360
}
361361
$formSpec['elements'][] = $elementSpec;
362362
}
@@ -389,10 +389,10 @@ public function preserveDefinedOrder()
389389
*/
390390
protected function discoverName($annotations, $reflection)
391391
{
392-
$results = $this->getEventManager()->trigger('discoverName', $this, array(
392+
$results = $this->getEventManager()->trigger('discoverName', $this, [
393393
'annotations' => $annotations,
394394
'reflection' => $reflection,
395-
), function ($r) {
395+
], function ($r) {
396396
return (is_string($r) && !empty($r));
397397
});
398398
return $results->last();
@@ -406,9 +406,9 @@ protected function discoverName($annotations, $reflection)
406406
*/
407407
protected function checkForExclude($annotations)
408408
{
409-
$results = $this->getEventManager()->trigger('checkForExclude', $this, array(
409+
$results = $this->getEventManager()->trigger('checkForExclude', $this, [
410410
'annotations' => $annotations,
411-
), function ($r) {
411+
], function ($r) {
412412
return (true === $r);
413413
});
414414
return (bool) $results->last();

src/Annotation/ComposedObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ public function isCollection()
5151
*/
5252
public function getOptions()
5353
{
54-
return is_array($this->value) && isset($this->value['options']) ? $this->value['options'] : array();
54+
return is_array($this->value) && isset($this->value['options']) ? $this->value['options'] : [];
5555
}
5656
}

src/Annotation/ElementAnnotationsListener.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,25 @@ class ElementAnnotationsListener extends AbstractAnnotationsListener
4141
*/
4242
public function attach(EventManagerInterface $events)
4343
{
44-
$this->listeners[] = $events->attach('configureElement', array($this, 'handleAllowEmptyAnnotation'));
45-
$this->listeners[] = $events->attach('configureElement', array($this, 'handleAttributesAnnotation'));
46-
$this->listeners[] = $events->attach('configureElement', array($this, 'handleComposedObjectAnnotation'));
47-
$this->listeners[] = $events->attach('configureElement', array($this, 'handleContinueIfEmptyAnnotation'));
48-
$this->listeners[] = $events->attach('configureElement', array($this, 'handleErrorMessageAnnotation'));
49-
$this->listeners[] = $events->attach('configureElement', array($this, 'handleFilterAnnotation'));
50-
$this->listeners[] = $events->attach('configureElement', array($this, 'handleFlagsAnnotation'));
51-
$this->listeners[] = $events->attach('configureElement', array($this, 'handleHydratorAnnotation'));
52-
$this->listeners[] = $events->attach('configureElement', array($this, 'handleInputAnnotation'));
53-
$this->listeners[] = $events->attach('configureElement', array($this, 'handleObjectAnnotation'));
54-
$this->listeners[] = $events->attach('configureElement', array($this, 'handleOptionsAnnotation'));
55-
$this->listeners[] = $events->attach('configureElement', array($this, 'handleRequiredAnnotation'));
56-
$this->listeners[] = $events->attach('configureElement', array($this, 'handleTypeAnnotation'));
57-
$this->listeners[] = $events->attach('configureElement', array($this, 'handleValidatorAnnotation'));
58-
59-
$this->listeners[] = $events->attach('discoverName', array($this, 'handleNameAnnotation'));
60-
$this->listeners[] = $events->attach('discoverName', array($this, 'discoverFallbackName'));
61-
62-
$this->listeners[] = $events->attach('checkForExclude', array($this, 'handleExcludeAnnotation'));
44+
$this->listeners[] = $events->attach('configureElement', [$this, 'handleAllowEmptyAnnotation']);
45+
$this->listeners[] = $events->attach('configureElement', [$this, 'handleAttributesAnnotation']);
46+
$this->listeners[] = $events->attach('configureElement', [$this, 'handleComposedObjectAnnotation']);
47+
$this->listeners[] = $events->attach('configureElement', [$this, 'handleContinueIfEmptyAnnotation']);
48+
$this->listeners[] = $events->attach('configureElement', [$this, 'handleErrorMessageAnnotation']);
49+
$this->listeners[] = $events->attach('configureElement', [$this, 'handleFilterAnnotation']);
50+
$this->listeners[] = $events->attach('configureElement', [$this, 'handleFlagsAnnotation']);
51+
$this->listeners[] = $events->attach('configureElement', [$this, 'handleHydratorAnnotation']);
52+
$this->listeners[] = $events->attach('configureElement', [$this, 'handleInputAnnotation']);
53+
$this->listeners[] = $events->attach('configureElement', [$this, 'handleObjectAnnotation']);
54+
$this->listeners[] = $events->attach('configureElement', [$this, 'handleOptionsAnnotation']);
55+
$this->listeners[] = $events->attach('configureElement', [$this, 'handleRequiredAnnotation']);
56+
$this->listeners[] = $events->attach('configureElement', [$this, 'handleTypeAnnotation']);
57+
$this->listeners[] = $events->attach('configureElement', [$this, 'handleValidatorAnnotation']);
58+
59+
$this->listeners[] = $events->attach('discoverName', [$this, 'handleNameAnnotation']);
60+
$this->listeners[] = $events->attach('discoverName', [$this, 'discoverFallbackName']);
61+
62+
$this->listeners[] = $events->attach('checkForExclude', [$this, 'handleExcludeAnnotation']);
6363
}
6464

6565
/**
@@ -167,7 +167,7 @@ public function handleComposedObjectAnnotation($e)
167167
}
168168

169169
if (isset($elementSpec['spec']['options'])) {
170-
$specification['options'] = isset($specification['options']) ? $specification['options'] : array();
170+
$specification['options'] = isset($specification['options']) ? $specification['options'] : [];
171171
$specification['options'] = array_merge($elementSpec['spec']['options'], $specification['options']);
172172
}
173173

@@ -248,7 +248,7 @@ public function handleFilterAnnotation($e)
248248

249249
$inputSpec = $e->getParam('inputSpec');
250250
if (!isset($inputSpec['filters'])) {
251-
$inputSpec['filters'] = array();
251+
$inputSpec['filters'] = [];
252252
}
253253
$inputSpec['filters'][] = $annotation->getFilter();
254254
}
@@ -374,7 +374,7 @@ public function handleRequiredAnnotation($e)
374374
if ($required) {
375375
$elementSpec = $e->getParam('elementSpec');
376376
if (!isset($elementSpec['spec']['attributes'])) {
377-
$elementSpec['spec']['attributes'] = array();
377+
$elementSpec['spec']['attributes'] = [];
378378
}
379379

380380
$elementSpec['spec']['attributes']['required'] = 'required';
@@ -417,7 +417,7 @@ public function handleValidatorAnnotation($e)
417417

418418
$inputSpec = $e->getParam('inputSpec');
419419
if (!isset($inputSpec['validators'])) {
420-
$inputSpec['validators'] = array();
420+
$inputSpec['validators'] = [];
421421
}
422422
$inputSpec['validators'][] = $annotation->getValidator();
423423
}

src/Annotation/FormAnnotationsListener.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ class FormAnnotationsListener extends AbstractAnnotationsListener
3939
*/
4040
public function attach(EventManagerInterface $events)
4141
{
42-
$this->listeners[] = $events->attach('configureForm', array($this, 'handleAttributesAnnotation'));
43-
$this->listeners[] = $events->attach('configureForm', array($this, 'handleFlagsAnnotation'));
44-
$this->listeners[] = $events->attach('configureForm', array($this, 'handleHydratorAnnotation'));
45-
$this->listeners[] = $events->attach('configureForm', array($this, 'handleInputFilterAnnotation'));
46-
$this->listeners[] = $events->attach('configureForm', array($this, 'handleObjectAnnotation'));
47-
$this->listeners[] = $events->attach('configureForm', array($this, 'handleOptionsAnnotation'));
48-
$this->listeners[] = $events->attach('configureForm', array($this, 'handleTypeAnnotation'));
49-
$this->listeners[] = $events->attach('configureForm', array($this, 'handleValidationGroupAnnotation'));
50-
51-
$this->listeners[] = $events->attach('discoverName', array($this, 'handleNameAnnotation'));
52-
$this->listeners[] = $events->attach('discoverName', array($this, 'discoverFallbackName'));
42+
$this->listeners[] = $events->attach('configureForm', [$this, 'handleAttributesAnnotation']);
43+
$this->listeners[] = $events->attach('configureForm', [$this, 'handleFlagsAnnotation']);
44+
$this->listeners[] = $events->attach('configureForm', [$this, 'handleHydratorAnnotation']);
45+
$this->listeners[] = $events->attach('configureForm', [$this, 'handleInputFilterAnnotation']);
46+
$this->listeners[] = $events->attach('configureForm', [$this, 'handleObjectAnnotation']);
47+
$this->listeners[] = $events->attach('configureForm', [$this, 'handleOptionsAnnotation']);
48+
$this->listeners[] = $events->attach('configureForm', [$this, 'handleTypeAnnotation']);
49+
$this->listeners[] = $events->attach('configureForm', [$this, 'handleValidationGroupAnnotation']);
50+
51+
$this->listeners[] = $events->attach('discoverName', [$this, 'handleNameAnnotation']);
52+
$this->listeners[] = $events->attach('discoverName', [$this, 'discoverFallbackName']);
5353
}
5454

5555
/**

src/Element.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Element implements
2222
/**
2323
* @var array
2424
*/
25-
protected $attributes = array();
25+
protected $attributes = [];
2626

2727
/**
2828
* @var null|string
@@ -32,24 +32,24 @@ class Element implements
3232
/**
3333
* @var array
3434
*/
35-
protected $labelAttributes = array();
35+
protected $labelAttributes = [];
3636

3737
/**
3838
* Label specific options
3939
*
4040
* @var array
4141
*/
42-
protected $labelOptions = array();
42+
protected $labelOptions = [];
4343

4444
/**
4545
* @var array Validation error messages
4646
*/
47-
protected $messages = array();
47+
protected $messages = [];
4848

4949
/**
5050
* @var array custom options
5151
*/
52-
protected $options = array();
52+
protected $options = [];
5353

5454
/**
5555
* @var mixed
@@ -61,7 +61,7 @@ class Element implements
6161
* @param array $options Optional options for the element
6262
* @throws Exception\InvalidArgumentException
6363
*/
64-
public function __construct($name = null, $options = array())
64+
public function __construct($name = null, $options = [])
6565
{
6666
if (null !== $name) {
6767
$this->setName($name);
@@ -291,7 +291,7 @@ public function removeAttributes(array $keys)
291291
*/
292292
public function clearAttributes()
293293
{
294-
$this->attributes = array();
294+
$this->attributes = [];
295295
return $this;
296296
}
297297

@@ -405,7 +405,7 @@ public function getLabelOptions()
405405
*/
406406
public function clearLabelOptions()
407407
{
408-
$this->labelOptions = array();
408+
$this->labelOptions = [];
409409
return $this;
410410
}
411411

src/Element/Button.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Button extends Element
1818
*
1919
* @var array
2020
*/
21-
protected $attributes = array(
21+
protected $attributes = [
2222
'type' => 'button',
23-
);
23+
];
2424
}

src/Element/Captcha.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,18 @@ public function getCaptcha()
8282
*/
8383
public function getInputSpecification()
8484
{
85-
$spec = array(
85+
$spec = [
8686
'name' => $this->getName(),
8787
'required' => true,
88-
'filters' => array(
89-
array('name' => 'Zend\Filter\StringTrim'),
90-
),
91-
);
88+
'filters' => [
89+
['name' => 'Zend\Filter\StringTrim'],
90+
],
91+
];
9292

9393
// Test that we have a captcha before adding it to the spec
9494
$captcha = $this->getCaptcha();
9595
if ($captcha instanceof ZendCaptcha\AdapterInterface) {
96-
$spec['validators'] = array($captcha);
96+
$spec['validators'] = [$captcha];
9797
}
9898

9999
return $spec;

0 commit comments

Comments
 (0)