Skip to content

Commit 5b7d5d8

Browse files
committed
Use short array syntax
1 parent 55f461f commit 5b7d5d8

6 files changed

Lines changed: 37 additions & 37 deletions

src/Growl.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Growl
2525
*
2626
* @var array
2727
*/
28-
protected $options = array();
28+
protected $options = [];
2929

3030
/**
3131
* Whether or not to escape the command arguments.
@@ -40,7 +40,7 @@ class Growl
4040
*
4141
* @var array
4242
*/
43-
protected $safe = array();
43+
protected $safe = [];
4444

4545
/**
4646
* Constructor.
@@ -166,7 +166,7 @@ public function setSafe($options)
166166
*/
167167
protected function escape(array $options)
168168
{
169-
$results = array();
169+
$results = [];
170170
foreach ($options as $key => $value) {
171171
if (!in_array($key, $this->safe)) {
172172
$results[$key] = escapeshellarg($value);

tests/GrowlNotifyBuilderTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,35 @@ public function tearDown()
1919

2020
public function testBuild()
2121
{
22-
$options = array(
22+
$options = [
2323
'title' => 'Hello',
2424
'message' => 'World',
2525
'appIcon' => 'Mail',
2626
'url' => 'http://www.example.com',
2727
'sticky' => true
28-
);
28+
];
2929
$expected = 'growlnotify -t Hello -m World -a Mail --url' .
3030
' http://www.example.com -s';
3131
$result = $this->GrowlNotifyBuilder->build($options);
3232
$this->assertSame($expected, $result);
3333

34-
$options = array(
34+
$options = [
3535
'title' => 'Hello',
3636
'message' => 'World',
3737
'sticky' => false
38-
);
38+
];
3939
$expected = 'growlnotify -t Hello -m World';
4040
$result = $this->GrowlNotifyBuilder->build($options);
4141
$this->assertSame($expected, $result);
4242
}
4343

4444
public function testBuildWithAlias()
4545
{
46-
$options = array(
46+
$options = [
4747
'title' => 'Hello',
4848
'message' => 'World',
4949
'sticky' => true
50-
);
50+
];
5151
$expected = 'grwl -t Hello -m World -s';
5252
$result = $this->GrowlNotifyBuilderAliased->build($options);
5353
$this->assertSame($expected, $result);
@@ -58,6 +58,6 @@ public function testBuildWithAlias()
5858
*/
5959
public function testAliasException()
6060
{
61-
$exception = new GrowlNotifyBuilder(array('no' => 'arraysplz'));
61+
$exception = new GrowlNotifyBuilder(['no' => 'arraysplz']);
6262
}
6363
}

tests/GrowlNotifyWindowsBuilderTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@ public function tearDown()
1717

1818
public function testBuild()
1919
{
20-
$options = array(
20+
$options = [
2121
'title' => 'Hello',
2222
'appIcon' => 'Mail',
2323
'url' => 'http://www.example.com',
2424
'message' => 'World',
2525
'sticky' => true
26-
);
26+
];
2727
$expected = 'growlnotify /t:Hello /ai:Mail /cu:' .
2828
'http://www.example.com /s:true World';
2929
$result = $this->GrowlNotifyWindowsBuilder->build($options);
3030
$this->assertSame($expected, $result);
3131

32-
$options = array(
32+
$options = [
3333
'title' => 'Hello',
3434
'message' => 'World',
3535
'sticky' => false
36-
);
36+
];
3737
$expected = 'growlnotify /t:Hello World';
3838
$result = $this->GrowlNotifyWindowsBuilder->build($options);
3939
$this->assertSame($expected, $result);

tests/GrowlTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ public function testBuildCommand()
2020
{
2121
$expected = 'growlnotify -t \'Hello\' -m World';
2222
$result = $this->Growl
23-
->setOptions(array(
23+
->setOptions([
2424
'title' => 'Hello',
2525
'message' => 'World'
26-
))
26+
])
2727
->setSafe('message')
2828
->buildCommand();
2929

@@ -32,50 +32,50 @@ public function testBuildCommand()
3232

3333
public function testSet()
3434
{
35-
$expected = array(
35+
$expected = [
3636
'hello' => 'world',
3737
'title' => 'Hey',
3838
'message' => 'Whatsup?'
39-
);
39+
];
4040

4141
$result = $this->Growl->setOption('hello', 'world')
4242
->setOption('title', 'Hey')
4343
->setOption('message', 'Whatsup?');
4444
$this->assertEquals($expected, PHPUnit_Framework_Assert::readAttribute($result, 'options'));
4545

46-
$result = $this->Growl->setOptions(array(
46+
$result = $this->Growl->setOptions([
4747
'hello' => 'world',
4848
'title' => 'Hey',
4949
'message' => 'Whatsup?'
50-
));
50+
]);
5151
$this->assertEquals($expected, PHPUnit_Framework_Assert::readAttribute($result, 'options'));
5252
}
5353

5454
public function testEscape()
5555
{
56-
$expected = array(
56+
$expected = [
5757
'hello' => '\'world\''
58-
);
58+
];
5959

6060
$growl = new Growl(new GrowlNotifyBuilder());
6161
$growlReflection = new ReflectionClass($growl);
6262
$method = $growlReflection->getMethod('escape');
6363
$method->setAccessible(true);
6464

65-
$this->assertEquals($expected, $method->invokeArgs($growl, array(array('hello' => 'world'))));
65+
$this->assertEquals($expected, $method->invokeArgs($growl, [['hello' => 'world']]));
6666

67-
$expected = array(
67+
$expected = [
6868
'hello' => '\'world\'',
6969
'something' => 'else'
70-
);
70+
];
7171

7272
$growl = new Growl(new GrowlNotifyBuilder());
7373
$growl->setSafe('something');
7474
$growlReflection = new ReflectionClass($growl);
7575
$method = $growlReflection->getMethod('escape');
7676
$method->setAccessible(true);
7777

78-
$this->assertEquals($expected, $method->invokeArgs($growl, array(array('hello' => 'world', 'something' => 'else'))));
78+
$this->assertEquals($expected, $method->invokeArgs($growl, [['hello' => 'world', 'something' => 'else']]));
7979
}
8080

8181
public function testSetEscape()
@@ -86,12 +86,12 @@ public function testSetEscape()
8686

8787
public function testSetSafe()
8888
{
89-
$expected = array('hello');
89+
$expected = ['hello'];
9090
$growl = $this->Growl->setSafe('hello');
9191
$this->assertEquals($expected, PHPUnit_Framework_Assert::readAttribute($growl, 'safe'));
9292

93-
$expected = array('hello', 'world', 'again');
94-
$growl->setSafe(array('world', 'again'));
93+
$expected = ['hello', 'world', 'again'];
94+
$growl->setSafe(['world', 'again']);
9595
$this->assertEquals($expected, PHPUnit_Framework_Assert::readAttribute($growl, 'safe'));
9696
}
9797

tests/NotifySendBuilderTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ public function tearDown()
1717

1818
public function testBuild()
1919
{
20-
$options = array(
20+
$options = [
2121
'title' => 'Hello',
2222
'message' => 'World',
2323
'sticky' => true
24-
);
24+
];
2525
$expected = 'notify-send Hello World -t 0';
2626
$result = $this->NotifySendBuilder->build($options);
2727
$this->assertSame($expected, $result);
2828

29-
$options = array(
29+
$options = [
3030
'title' => 'Hello',
3131
'message' => 'Welcome'
32-
);
32+
];
3333
$expected = 'notify-send Hello Welcome';
3434
$result = $this->NotifySendBuilder->build($options);
3535
$this->assertSame($expected, $result);

tests/TerminalNotifierBuilderTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,24 @@ public function tearDown()
1717

1818
public function testBuild()
1919
{
20-
$options = array(
20+
$options = [
2121
'title' => 'Hello',
2222
'subtitle' => 'World',
2323
'message' => 'Welcome',
2424
'appIcon' => 'Mail',
2525
'contentImage' => 'http://www.example.com/hello.jpg',
2626
'open' => 'http://www.example.com'
27-
);
27+
];
2828
$expected = 'terminal-notifier -title Hello -subtitle World -message Welcome' .
2929
' -appIcon Mail -contentImage http://www.example.com/hello.jpg' .
3030
' -open http://www.example.com';
3131
$result = $this->TerminalNotifierBuilder->build($options);
3232
$this->assertSame($expected, $result);
3333

34-
$options = array(
34+
$options = [
3535
'title' => 'Hello',
3636
'message' => 'Welcome'
37-
);
37+
];
3838
$expected = 'terminal-notifier -title Hello -message Welcome';
3939
$result = $this->TerminalNotifierBuilder->build($options);
4040
$this->assertSame($expected, $result);

0 commit comments

Comments
 (0)