Skip to content

Commit 9566a74

Browse files
committed
Use short array syntax
Just because we can. :)
1 parent cf67da5 commit 9566a74

17 files changed

+63
-63
lines changed

doc/cache-invalidator.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Invalidate a URL with added header(s)::
5050

5151
$cacheInvalidator->invalidatePath(
5252
'http://www.example.com/users',
53-
array('Cookie' => 'foo=bar; fizz=bang')
53+
['Cookie' => 'foo=bar; fizz=bang']
5454
)->flush();
5555

5656
.. include:: includes/custom-headers.rst
@@ -75,7 +75,7 @@ Refresh a URL with added header(s)::
7575

7676
$cacheInvalidator->refreshPath(
7777
'http://www.example.com/users',
78-
array('Cookie' => 'foo=bar; fizz=bang')
78+
['Cookie' => 'foo=bar; fizz=bang']
7979
)->flush();
8080

8181
.. include:: includes/custom-headers.rst
@@ -105,7 +105,7 @@ caching proxy::
105105
To invalidate all ``.png`` files on host example.com::
106106

107107
$cacheInvalidator
108-
->invalidateRegex('.*', 'image/png', array('example.com'))
108+
->invalidateRegex('.*', 'image/png', ['example.com'])
109109
->flush()
110110
;
111111

@@ -124,7 +124,7 @@ default headers always present to simplify the cache configuration rules.
124124

125125
To invalidate on a custom header ``X-My-Header``, you would do::
126126

127-
$cacheInvalidator->invalidate(array('X-My-Header' => 'my-value'))->flush();
127+
$cacheInvalidator->invalidate(['X-My-Header' => 'my-value'])->flush();
128128

129129
.. _flush:
130130

doc/invalidation-handlers.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ With tags you can group related representations so it becomes easier to
3636
invalidate them. You will have to make sure your web application adds the
3737
correct tags on all responses. You can add tags to the handler using::
3838

39-
$tagHandler->addTags(array('tag-two', 'group-a'));
39+
$tagHandler->addTags(['tag-two', 'group-a']);
4040

4141
Before any content is sent out, you need to send the tag header_::
4242

@@ -67,7 +67,7 @@ Assume you sent four responses:
6767

6868
You can now invalidate some URLs using tags::
6969

70-
$tagHandler->invalidateTags(array('group-a', 'tag-four'))->flush();
70+
$tagHandler->invalidateTags(['group-a', 'tag-four'])->flush();
7171

7272
This will ban all requests having either the tag ``group-a`` /or/ ``tag-four``.
7373
In the above example, this will invalidate ``/two``, ``/three`` and ``/four``.

doc/proxy-clients.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Varnish runs on if it is not port 80::
7575

7676
use FOS\HttpCache\ProxyClient\Varnish;
7777

78-
$servers = array('10.0.0.1', '10.0.0.2:6081'); // Port 80 assumed for 10.0.0.1
78+
$servers = ['10.0.0.1', '10.0.0.2:6081']; // Port 80 assumed for 10.0.0.1
7979
$varnish = new Varnish($servers);
8080

8181
This is sufficient for invalidating absolute URLs. If you also wish to
@@ -102,7 +102,7 @@ NGINX runs on if it is not the default::
102102

103103
use FOS\HttpCache\ProxyClient\Nginx;
104104

105-
$servers = array('10.0.0.1', '10.0.0.2:8088'); // Port 80 assumed for 10.0.0.1
105+
$servers = ['10.0.0.1', '10.0.0.2:8088']; // Port 80 assumed for 10.0.0.1
106106
$nginx = new Nginx($servers);
107107

108108
This is sufficient for invalidating absolute URLs. If you also wish to
@@ -134,7 +134,7 @@ the web server runs on if it is not the default::
134134

135135
use FOS\HttpCache\ProxyClient\Symfony;
136136

137-
$servers = array('10.0.0.1', '10.0.0.2:8088'); // Port 80 assumed for 10.0.0.1
137+
$servers = ['10.0.0.1', '10.0.0.2:8088']; // Port 80 assumed for 10.0.0.1
138138
$client = new Symfony($servers);
139139

140140
This is sufficient for invalidating absolute URLs. If you also wish to
@@ -193,7 +193,7 @@ You can specify HTTP headers as the second argument to ``purge()``.
193193
For instance::
194194

195195
$client
196-
->purge('/some/path', array('X-Foo' => 'bar')
196+
->purge('/some/path', ['X-Foo' => 'bar'])
197197
->flush()
198198
;
199199

@@ -221,7 +221,7 @@ You can specify HTTP headers as the second argument to ``refresh()``. For
221221
instance, to only refresh the JSON representation of an URL::
222222

223223
$client
224-
->refresh('/some/path', array('Accept' => 'application/json')
224+
->refresh('/some/path', ['Accept' => 'application/json'])
225225
->flush()
226226
;
227227

@@ -256,11 +256,11 @@ Varnish client::
256256

257257
use FOS\HttpCache\ProxyClient\Varnish;
258258

259-
$varnish->ban(array(
259+
$varnish->ban([
260260
Varnish::HTTP_HEADER_URL => '.*\.png$',
261261
Varnish::HTTP_HEADER_HOST => '.*example\.com',
262262
Varnish::HTTP_HEADER_CACHE => 'my-tag',
263-
));
263+
]);
264264

265265
Make sure to add any headers that you want to ban on to your
266266
:doc:`proxy configuration <proxy-configuration>`.

doc/user-context.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ implement at least one ContextProvider and register that with the HashGenerator:
5656

5757
use FOS\HttpCache\UserContext\HashGenerator;
5858

59-
$hashGenerator = new HashGenerator(array(
59+
$hashGenerator = new HashGenerator([
6060
new IsAuthenticatedProvider(),
6161
new RoleProvider(),
62-
));
62+
]);
6363

6464
Once all providers are registered, call ``generateHash()`` to get the hash for
6565
the current user context.

src/EventListener/LogSubscriber.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ public function __construct(LoggerInterface $logger)
3434
*/
3535
public static function getSubscribedEvents()
3636
{
37-
return array(
37+
return [
3838
Events::PROXY_UNREACHABLE_ERROR => 'onProxyUnreachableError',
3939
Events::PROXY_RESPONSE_ERROR => 'onProxyResponseError'
40-
);
40+
];
4141
}
4242

4343
public function onProxyUnreachableError(Event $event)
@@ -52,9 +52,9 @@ public function onProxyResponseError(Event $event)
5252

5353
private function log($level, \Exception $exception)
5454
{
55-
$context = array(
56-
'exception' => $exception
57-
);
55+
$context = [
56+
'exception' => $exception,
57+
];
5858

5959
$this->logger->log($level, $exception->getMessage(), $context);
6060
}

src/ProxyClient/Symfony.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ public function __construct(
5252
parent::__construct($servers, $baseUrl, $httpAdapter);
5353

5454
$resolver = new OptionsResolver();
55-
$resolver->setDefaults(array(
55+
$resolver->setDefaults([
5656
'purge_method' => PurgeSubscriber::DEFAULT_PURGE_METHOD,
57-
));
57+
]);
5858

5959
$this->options = $resolver->resolve($options);
6060
}

src/SymfonyCache/PurgeSubscriber.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ public function __construct(array $options = [])
5858
} else {
5959
$resolver->setOptional(['purge_client_matcher', 'purge_client_ips', 'purge_method']);
6060
}
61-
$resolver->setDefaults(array(
61+
$resolver->setDefaults([
6262
'purge_client_matcher' => null,
6363
'purge_client_ips' => null,
6464
'purge_method' => static::DEFAULT_PURGE_METHOD,
65-
));
65+
]);
6666

6767
$this->options = $resolver->resolve($options);
6868

@@ -74,9 +74,9 @@ public function __construct(array $options = [])
7474
*/
7575
public static function getSubscribedEvents()
7676
{
77-
return array(
77+
return [
7878
Events::PRE_INVALIDATE => 'handlePurge',
79-
);
79+
];
8080
}
8181

8282
/**

src/SymfonyCache/RefreshSubscriber.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ class RefreshSubscriber extends AccessControlledSubscriber
4545
public function __construct(array $options = [])
4646
{
4747
$resolver = new OptionsResolver();
48-
$resolver->setDefaults(array(
48+
$resolver->setDefaults([
4949
'refresh_client_matcher' => null,
5050
'refresh_client_ips' => null,
51-
));
51+
]);
5252
$options = $resolver->resolve($options);
5353

5454
parent::__construct($options['refresh_client_matcher'], $options['refresh_client_ips']);
@@ -59,9 +59,9 @@ public function __construct(array $options = [])
5959
*/
6060
public static function getSubscribedEvents()
6161
{
62-
return array(
62+
return [
6363
Events::PRE_HANDLE => 'handleRefresh',
64-
);
64+
];
6565
}
6666

6767
/**

src/SymfonyCache/UserContextSubscriber.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ class UserContextSubscriber implements EventSubscriberInterface
5959
public function __construct(array $options = [])
6060
{
6161
$resolver = new OptionsResolver();
62-
$resolver->setDefaults(array(
62+
$resolver->setDefaults([
6363
'anonymous_hash' => '38015b703d82206ebc01d17a39c727e5',
6464
'user_hash_accept_header' => 'application/vnd.fos.user-context-hash',
6565
'user_hash_header' => 'X-User-Context-Hash',
6666
'user_hash_uri' => '/_fos_user_context_hash',
6767
'user_hash_method' => 'GET',
6868
'session_name_prefix' => 'PHPSESSID',
69-
));
69+
]);
7070

7171
$this->options = $resolver->resolve($options);
7272
}
@@ -76,9 +76,9 @@ public function __construct(array $options = [])
7676
*/
7777
public static function getSubscribedEvents()
7878
{
79-
return array(
79+
return [
8080
Events::PRE_HANDLE => 'preHandle',
81-
);
81+
];
8282
}
8383

8484
/**

src/Test/Proxy/NginxProxy.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ public function start()
3737
{
3838
$this->runCommand(
3939
$this->getBinary(),
40-
array(
41-
'-c', $this->getConfigFile() ,
42-
'-g', 'pid ' . $this->pid . ';'
43-
)
40+
[
41+
'-c', $this->getConfigFile(),
42+
'-g', 'pid ' . $this->pid . ';',
43+
]
4444
);
4545

4646
$this->waitFor($this->getIp(), $this->getPort(), 2000);

src/Test/Proxy/VarnishProxy.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ public function start()
4242
{
4343
$this->runCommand(
4444
$this->getBinary(),
45-
array(
45+
[
4646
'-a', $this->ip . ':' . $this->getPort(),
4747
'-T', $this->ip . ':' . $this->getManagementPort(),
4848
'-f', $this->getConfigFile(),
4949
'-n', $this->getCacheDir(),
5050
'-p', 'vcl_dir=' . $this->getConfigDir(),
51-
'-P', $this->pid
52-
)
51+
'-P', $this->pid,
52+
]
5353
);
5454

5555
$this->waitFor($this->ip, $this->getPort(), 2000);

tests/Unit/CacheInvalidatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ public function testRefreshPath()
9393

9494
public function testInvalidate()
9595
{
96-
$headers = array(
96+
$headers = [
9797
'X-Header' => '^value.*$',
9898
'Other-Header' => '^a|b|c$',
99-
);
99+
];
100100

101101
$ban = \Mockery::mock('\FOS\HttpCache\ProxyClient\Invalidation\BanInterface')
102102
->shouldReceive('ban')

tests/Unit/SymfonyCache/EventDispatchingHttpCacheTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ protected function getHttpCachePartialMock(array $mockedMethods = null)
3434
;
3535

3636
// Force setting options property since we can't use original constructor.
37-
$options = array(
37+
$options = [
3838
'debug' => false,
3939
'default_ttl' => 0,
4040
'private_headers' => [ 'Authorization', 'Cookie' ],
4141
'allow_reload' => false,
4242
'allow_revalidate' => false,
4343
'stale_while_revalidate' => 2,
4444
'stale_if_error' => 60,
45-
);
45+
];
4646

4747
$refHttpCache = new \ReflectionClass('Symfony\Component\HttpKernel\HttpCache\HttpCache');
4848
// Workaround for Symfony 2.3 where $options property is not defined.
@@ -161,10 +161,10 @@ public function __construct($test, $kernel, $request)
161161

162162
public static function getSubscribedEvents()
163163
{
164-
return array(
164+
return [
165165
Events::PRE_HANDLE => 'preHandle',
166-
Events::PRE_INVALIDATE => 'preInvalidate'
167-
);
166+
Events::PRE_INVALIDATE => 'preInvalidate',
167+
];
168168
}
169169

170170
public function preHandle(CacheEvent $event)

tests/Unit/SymfonyCache/PurgeSubscriberTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ public function testOtherMethod()
131131
->method('isRequestAllowed')
132132
;
133133

134-
$purgeSubscriber = new PurgeSubscriber(array(
134+
$purgeSubscriber = new PurgeSubscriber([
135135
'purge_client_matcher' => $matcher,
136136
'purge_method' => 'FOO',
137-
));
137+
]);
138138
$request = Request::create('http://example.com/foo', 'PURGE');
139139
$event = new CacheEvent($this->kernel, $request);
140140

tests/Unit/SymfonyCache/UserContextSubscriberTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ public function provideConfigOptions()
4646
$prop->setAccessible(true);
4747
$options = $prop->getValue($subscriber);
4848

49-
$custom = array(
49+
$custom = [
5050
'user_hash_uri' => '/test-uri',
5151
'user_hash_header' => 'test/header',
5252
'user_hash_accept_header' => 'test accept',
5353
'anonymous_hash' => 'test hash',
54-
);;
54+
];
5555

56-
return array(
56+
return [
5757
[[], $options],
5858
[$custom, $custom + $options]
59-
);
59+
];
6060
}
6161

6262
/**
@@ -124,11 +124,11 @@ public function testUserHashUserWithSession($arg, $options)
124124
$catch = true;
125125
$sessionId1 = 'my_session_id';
126126
$sessionId2 = 'another_session_id';
127-
$cookies = array(
127+
$cookies = [
128128
'PHPSESSID' => $sessionId1,
129129
'PHPSESSIDsdiuhsdf4535d4f' => $sessionId2,
130-
'foo' => 'bar'
131-
);
130+
'foo' => 'bar',
131+
];
132132
$cookieString = "PHPSESSID=$sessionId1; foo=bar; PHPSESSIDsdiuhsdf4535d4f=$sessionId2";
133133
$request = Request::create('/foo', 'GET', [], $cookies, [], ['Cookie' => $cookieString]);
134134

tests/Unit/Test/Proxy/VarnishProxyTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ public function testStart()
3636

3737
$this->assertEquals('/usr/sbin/varnishd', $proxy->command);
3838
$this->assertEquals(
39-
array(
39+
[
4040
'-a', '192.168.0.1:6181',
4141
'-T', '192.168.0.1:1331',
4242
'-f', 'config.vcl',
4343
'-n', '/tmp/cache/dir',
4444
'-p', 'vcl_dir=/my/varnish/dir',
4545
'-P', '/tmp/foshttpcache-varnish.pid',
46-
),
46+
],
4747
$proxy->arguments
4848
);
4949
}

0 commit comments

Comments
 (0)