Skip to content

Commit fbe342e

Browse files
committed
switched array() to []
1 parent 224a8bc commit fbe342e

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

EventListener/AddLinkHeaderListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ public function onKernelResponse(FilterResponseEvent $event)
5252
*/
5353
public static function getSubscribedEvents()
5454
{
55-
return array(KernelEvents::RESPONSE => 'onKernelResponse');
55+
return [KernelEvents::RESPONSE => 'onKernelResponse'];
5656
}
5757
}

HttpHeaderSerializer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ final class HttpHeaderSerializer
3131
*/
3232
public function serialize($links)
3333
{
34-
$elements = array();
34+
$elements = [];
3535
foreach ($links as $link) {
3636
if ($link->isTemplated()) {
3737
continue;
3838
}
3939

40-
$attributesParts = array('', sprintf('rel="%s"', implode(' ', $link->getRels())));
40+
$attributesParts = ['', sprintf('rel="%s"', implode(' ', $link->getRels()))];
4141
foreach ($link->getAttributes() as $key => $value) {
4242
if (\is_array($value)) {
4343
foreach ($value as $v) {

Tests/EventListener/AddLinkHeaderListenerTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class AddLinkHeaderListenerTest extends TestCase
2828
{
2929
public function testOnKernelResponse()
3030
{
31-
$request = new Request(array(), array(), array('_links' => new GenericLinkProvider(array(new Link('preload', '/foo')))));
32-
$response = new Response('', 200, array('Link' => '<https://demo.api-platform.com/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'));
31+
$request = new Request([], [], ['_links' => new GenericLinkProvider([new Link('preload', '/foo')])]);
32+
$response = new Response('', 200, ['Link' => '<https://demo.api-platform.com/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"']);
3333

3434
$subscriber = new AddLinkHeaderListener();
3535

@@ -42,16 +42,16 @@ public function testOnKernelResponse()
4242

4343
$this->assertInstanceOf(EventSubscriberInterface::class, $subscriber);
4444

45-
$expected = array(
45+
$expected = [
4646
'<https://demo.api-platform.com/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"',
4747
'</foo>; rel="preload"',
48-
);
48+
];
4949

5050
$this->assertEquals($expected, $response->headers->get('Link', null, false));
5151
}
5252

5353
public function testSubscribedEvents()
5454
{
55-
$this->assertEquals(array(KernelEvents::RESPONSE => 'onKernelResponse'), AddLinkHeaderListener::getSubscribedEvents());
55+
$this->assertEquals([KernelEvents::RESPONSE => 'onKernelResponse'], AddLinkHeaderListener::getSubscribedEvents());
5656
}
5757
}

Tests/HttpHeaderSerializerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ protected function setUp()
2929

3030
public function testSerialize()
3131
{
32-
$links = array(
32+
$links = [
3333
new Link('prerender', '/1'),
3434
(new Link('dns-prefetch', '/2'))->withAttribute('pr', 0.7),
3535
(new Link('preload', '/3'))->withAttribute('as', 'script')->withAttribute('nopush', false),
3636
(new Link('preload', '/4'))->withAttribute('as', 'image')->withAttribute('nopush', true),
37-
(new Link('alternate', '/5'))->withRel('next')->withAttribute('hreflang', array('fr', 'de'))->withAttribute('title', 'Hello'),
38-
);
37+
(new Link('alternate', '/5'))->withRel('next')->withAttribute('hreflang', ['fr', 'de'])->withAttribute('title', 'Hello'),
38+
];
3939

4040
$this->assertEquals('</1>; rel="prerender",</2>; rel="dns-prefetch"; pr="0.7",</3>; rel="preload"; as="script",</4>; rel="preload"; as="image"; nopush,</5>; rel="alternate next"; hreflang="fr"; hreflang="de"; title="Hello"', $this->serializer->serialize($links));
4141
}
4242

4343
public function testSerializeEmpty()
4444
{
45-
$this->assertNull($this->serializer->serialize(array()));
45+
$this->assertNull($this->serializer->serialize([]));
4646
}
4747
}

0 commit comments

Comments
 (0)