Skip to content

Commit 3b9ccbf

Browse files
author
Douglas Greenshields
committed
use short array syntax
1 parent e26a7b8 commit 3b9ccbf

13 files changed

+28
-28
lines changed

Command/TestFormattingCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
6262
);
6363

6464
$renderer = $this->getContainer()->get('markup_addressing.address.renderer');
65-
$renderedLines = explode("\n", $renderer->render($address, array('format' => 'plaintext')));
65+
$renderedLines = explode("\n", $renderer->render($address, ['format' => 'plaintext']));
6666

6767
$output->writeln('<info>Formatted address:</info>');
6868
foreach ($renderedLines as $line) {

DependencyInjection/Compiler/RegisterAddressFormatExtensionsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function process(ContainerBuilder $container)
2424
if (!isset($attributes['alias'])) {
2525
continue;
2626
}
27-
$provider->addMethodCall('registerExtension', array($attributes['alias'], new Reference($id)));
27+
$provider->addMethodCall('registerExtension', [$attributes['alias'], new Reference($id)]);
2828
}
2929
}
3030
}

DependencyInjection/Compiler/RegisterAddressNodeProvidersPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function process(ContainerBuilder $container)
2424
if (!isset($attributes['alias'])) {
2525
continue;
2626
}
27-
$fac->addMethodCall('registerProvider', array($attributes['alias'], new Reference($id)));
27+
$fac->addMethodCall('registerProvider', [$attributes['alias'], new Reference($id)]);
2828
}
2929
}
3030
}

DependencyInjection/MarkupAddressingExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private function loadCountryPostalCodeOverrides(array $config, ContainerBuilder
5353
return;
5454
}
5555
$overridesProvider = $container->getDefinition('markup_addressing.country_regex_override_provider');
56-
$overridesProvider->addMethodCall('setOverrideRegexes', array($config['country_postal_code_regex_overrides']));
56+
$overridesProvider->addMethodCall('setOverrideRegexes', [$config['country_postal_code_regex_overrides']]);
5757
}
5858

5959
/**

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ Add MarkupAddressingBundle to your AppKernel.php:
2121
```php
2222
public function registerBundles()
2323
{
24-
$bundles = array(
24+
$bundles = [
2525
...
2626
new Markup\AddressingBundle\MarkupAddressingBundle(),
27-
);
27+
];
2828
...
2929
}
3030
```
@@ -42,7 +42,7 @@ Simple usage example:
4242
```php
4343
$renderer = $this->get('markup_addressing.address.renderer');
4444
$address = new MyAddressAdapter($myAddress); //MyAddressAdapter here wraps a different address definition and makes it implement Markup\Addressing\AddressInterface
45-
echo $renderer->render($address, array('format' => 'plaintext'));
45+
echo $renderer->render($address, ['format' => 'plaintext']);
4646
```
4747

4848
This would echo out an address, formatted correctly according to the country, using plaintext.

Tests/Validator/CountryRegexOverrideProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class CountryRegexOverrideProviderTest extends \PHPUnit_Framework_TestCase
88
{
99
protected function setUp()
1010
{
11-
$this->overrides = array('IT' => '/^\d{5}$/');
11+
$this->overrides = ['IT' => '/^\d{5}$/'];
1212
$this->provider = new CountryRegexOverrideProvider($this->overrides);
1313
}
1414

Tests/Validator/MultipleRegexValidatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testIsConstraintValidator()
3030
public function testPassingPostalCode()
3131
{
3232
$postalCode = '123-456';
33-
$patterns = array('/^\d{3}\-\d{3}$/', '/^\d{5}$/');
33+
$patterns = ['/^\d{3}\-\d{3}$/', '/^\d{5}$/'];
3434
$constraint = new MultipleRegexConstraint();
3535
$constraint->patterns = $patterns;
3636
$this->context
@@ -42,7 +42,7 @@ public function testPassingPostalCode()
4242
public function testFailingPostalCode()
4343
{
4444
$postalCode = '123';
45-
$patterns = array('/^[A-Z]{4}$/');
45+
$patterns = ['/^[A-Z]{4}$/'];
4646
$constraint = new MultipleRegexConstraint();
4747
$constraint->patterns = $patterns;
4848
$this->context

Tests/Validator/RegionValidatorTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ public function testValidationCases($country, $region, $expectedPass)
5454

5555
public function cases()
5656
{
57-
return array(
58-
array('FR', 'Île de France', true),
59-
array('US', 'NY', true),
60-
array('US', 'New York', false),
61-
array('CA', 'ON', true),
62-
array('US', 'Ontario', false),
63-
);
57+
return [
58+
['FR', 'Île de France', true],
59+
['US', 'NY', true],
60+
['US', 'New York', false],
61+
['CA', 'ON', true],
62+
['US', 'Ontario', false],
63+
];
6464
}
6565

6666
public function testNonAbbreviationsPassWhenNotStrict()

Validator/CountryRegexOverrideProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class CountryRegexOverrideProvider
1717
/**
1818
* @param array $overrideRegexes
1919
*/
20-
public function __construct(array $overrideRegexes = array())
20+
public function __construct(array $overrideRegexes = [])
2121
{
2222
$this->setOverrideRegexes($overrideRegexes);
2323
}
@@ -39,7 +39,7 @@ public function getOverrideFor($country)
3939
* @param array $overrideRegexes
4040
* @return self
4141
*/
42-
public function setOverrideRegexes(array $overrideRegexes = array())
42+
public function setOverrideRegexes(array $overrideRegexes = [])
4343
{
4444
$this->overrideRegexes = $overrideRegexes;
4545

Validator/LocalizedPostalCodeValidatorClosureProvider.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function fetchValidatorForCountry($country, $message = null)
4444
$override = $this->countryRegexOverrideProvider->getOverrideFor($country);
4545
if ($override) {
4646
if (!is_array($override)) {
47-
$override = array($override);
47+
$override = [$override];
4848
}
4949

5050
return $this->createValidatorClosureForConstraint($this->getMultipleRegexConstraint($override, $message));
@@ -84,19 +84,19 @@ public function fetchValidatorForCountry($country, $message = null)
8484
return $this->createValidatorClosureForConstraint($this->getFixedLengthDigitConstraint(5, $message));
8585

8686
case 'NL':
87-
return $this->createValidatorClosureForConstraint($this->getMultipleRegexConstraint(array('/^\d{4}\s[A-Z]{2}$/'), $message));
87+
return $this->createValidatorClosureForConstraint($this->getMultipleRegexConstraint(['/^\d{4}\s[A-Z]{2}$/'], $message));
8888

8989
case 'PL':
90-
return $this->createValidatorClosureForConstraint($this->getMultipleRegexConstraint(array('/^\d{2}\-\d{3}$/'), $message));
90+
return $this->createValidatorClosureForConstraint($this->getMultipleRegexConstraint(['/^\d{2}\-\d{3}$/'], $message));
9191

9292
case 'PT':
93-
return $this->createValidatorClosureForConstraint($this->getMultipleRegexConstraint(array('/^\d{4}\-\d{3}$/'), $message));
93+
return $this->createValidatorClosureForConstraint($this->getMultipleRegexConstraint(['/^\d{4}\-\d{3}$/'], $message));
9494

9595
case 'CA':
96-
return $this->createValidatorClosureForConstraint($this->getMultipleRegexConstraint(array('/^[A-Z][0-9][A-Z] [0-9][A-Z][0-9]$/'), $message));
96+
return $this->createValidatorClosureForConstraint($this->getMultipleRegexConstraint(['/^[A-Z][0-9][A-Z] [0-9][A-Z][0-9]$/'], $message));
9797

9898
case 'US':
99-
return $this->createValidatorClosureForConstraint($this->getMultipleRegexConstraint(array('/^[0-9]{5}$/', '/^[0-9]{5}\-[0-9]{4}$/'), $message));
99+
return $this->createValidatorClosureForConstraint($this->getMultipleRegexConstraint(['/^[0-9]{5}$/', '/^[0-9]{5}\-[0-9]{4}$/'], $message));
100100

101101
default:
102102
return null;

0 commit comments

Comments
 (0)