Skip to content

Commit 80ba5dd

Browse files
committed
[!]: "php": ">=7.0" v2
1 parent 3cf4bda commit 80ba5dd

7 files changed

+47
-41
lines changed

tests/HooksActionTest.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ public function testAction()
2020
{
2121
$done = false;
2222

23-
$this->hooks->add_action('bar', function () use (&$done) {
24-
$done = true;
25-
});
23+
$this->hooks->add_action(
24+
'bar',
25+
function () use (&$done) {
26+
$done = true;
27+
}
28+
);
2629

2730
$this->hooks->do_action('bar');
2831

tests/HooksFilterTest.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ class HooksFilterTest extends \PHPUnit\Framework\TestCase
1818
*/
1919
public function testFilter()
2020
{
21-
$this->hooks->add_filter('foo', function ($content) {
22-
return '<b>' . $content . '</b>';
23-
});
21+
$this->hooks->add_filter(
22+
'foo', function ($content) {
23+
return '<b>' . $content . '</b>';
24+
}
25+
);
2426

2527
self::assertSame('<b>Hello world</b>', $this->hooks->apply_filters('foo', 'Hello world'));
2628
}

tests/HooksFooBar.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ public function doSomethingFunction($attrs, $content = '')
2020

2121
extract(
2222
\voku\helper\Hooks::getInstance()->shortcode_atts(
23-
array(
23+
[
2424
'foo',
25-
),
25+
],
2626
$attrs
2727
),
2828
EXTR_OVERWRITE

tests/HooksShortcodeStrictTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function parse_youtube($attrs)
3737

3838
extract(
3939
$hooks->shortcode_atts(
40-
array(
40+
[
4141
'autoplay',
4242
'noControls',
4343
'list' => null,
@@ -47,7 +47,7 @@ public function parse_youtube($attrs)
4747
'color' => 'red',
4848
'theme' => 'dark',
4949
'start' => 0,
50-
),
50+
],
5151
$attrs
5252
),
5353
EXTR_OVERWRITE
@@ -75,7 +75,7 @@ public function parse_youtube($attrs)
7575
public function testShortcode()
7676
{
7777
$hooks = Hooks::getInstance();
78-
$hooks->add_shortcode('youtube', array($this, 'parse_youtube'));
78+
$hooks->add_shortcode('youtube', [$this, 'parse_youtube']);
7979

8080
$default_content = '[youtube id=iCUV3iv9xOs color=white theme=light]';
8181
$parsed_content = $hooks->do_shortcode($default_content);

tests/HooksShortcodeTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function parse_youtube($attrs)
3535

3636
extract(
3737
$hooks->shortcode_atts(
38-
array(
38+
[
3939
'autoplay',
4040
'noControls',
4141
'list' => null,
@@ -45,7 +45,7 @@ public function parse_youtube($attrs)
4545
'color' => 'red',
4646
'theme' => 'dark',
4747
'start' => 0,
48-
),
48+
],
4949
$attrs
5050
),
5151
EXTR_OVERWRITE
@@ -73,7 +73,7 @@ public function parse_youtube($attrs)
7373
public function testShortcode()
7474
{
7575
$hooks = Hooks::getInstance();
76-
$hooks->add_shortcode('youtube', array($this, 'parse_youtube'));
76+
$hooks->add_shortcode('youtube', [$this, 'parse_youtube']);
7777

7878
$default_content = '[youtube id=iCUV3iv9xOs color=white theme=light]';
7979
$parsed_content = $hooks->do_shortcode($default_content);

tests/HooksStrictTest.php

+14-14
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public function hookTestString_2($input)
5050
*/
5151
public function testHooks()
5252
{
53-
$this->hooks->add_filter('test_strict', array($this, 'hookTestString_1'));
54-
$this->hooks->add_filter('test_strict', array($this, 'hookTestString_2'));
53+
$this->hooks->add_filter('test_strict', [$this, 'hookTestString_1']);
54+
$this->hooks->add_filter('test_strict', [$this, 'hookTestString_2']);
5555

5656
$lall = $this->hooks->apply_filters('test_strict', '');
5757

@@ -67,7 +67,7 @@ public function testHooksInstance()
6767
{
6868
$lall = $this->hooks->apply_filters('test_strict', '');
6969

70-
self::assertSame($this->testString_1 . $this->testString_2, $lall, );
70+
self::assertSame($this->testString_1 . $this->testString_2, $lall);
7171
}
7272

7373
public function testHasFunctions()
@@ -163,34 +163,34 @@ public function testRunHookFunctions()
163163
self::assertSame(true, $hooks->remove_all_actions('testAction'));
164164

165165
self::assertSame(false, $hooks->do_action('testAction'));
166-
self::assertSame(false, $hooks->do_action_ref_array('testNotExistingAction', array()));
166+
self::assertSame(false, $hooks->do_action_ref_array('testNotExistingAction', []));
167167
self::assertSame('Foo', $hooks->apply_filters('testFilter', 'Foo'));
168168

169-
self::assertSame(false, $hooks->do_action_ref_array('testAction', array('test')));
170-
self::assertSame('Foo', $hooks->apply_filters_ref_array('testFilter', array('Foo')));
169+
self::assertSame(false, $hooks->do_action_ref_array('testAction', ['test']));
170+
self::assertSame('Foo', $hooks->apply_filters_ref_array('testFilter', ['Foo']));
171171

172-
$mock = $this->getMockBuilder('stdClass')->setMethods( array('doSomeAction', 'applySomeFilter'))->getMock();
172+
$mock = $this->getMockBuilder('stdClass')->setMethods(['doSomeAction', 'applySomeFilter'])->getMock();
173173
$mock->expects(self::exactly(4))->method('doSomeAction');
174174
$mock->expects(self::exactly(10))->method('applySomeFilter')->willReturn('foo');
175175

176-
self::assertSame(true, $hooks->add_action('testAction', array($mock, 'doSomeAction')));
177-
self::assertSame(true, $hooks->add_filter('testFilter', array($mock, 'applySomeFilter')));
176+
self::assertSame(true, $hooks->add_action('testAction', [$mock, 'doSomeAction']));
177+
self::assertSame(true, $hooks->add_filter('testFilter', [$mock, 'applySomeFilter']));
178178

179179
self::assertSame(2, $hooks->did_action('testAction'));
180180
self::assertSame(true, $hooks->do_action('testAction'));
181181
self::assertSame(3, $hooks->did_action('testAction'));
182182
self::assertSame('foo', $hooks->apply_filters('testFilter', 'Foo'));
183183

184-
self::assertSame(true, $hooks->add_filter('all', array($mock, 'applySomeFilter')));
184+
self::assertSame(true, $hooks->add_filter('all', [$mock, 'applySomeFilter']));
185185

186186
self::assertSame(false, $hooks->do_action('notExistingAction'));
187187
self::assertSame('Foo', $hooks->apply_filters('notExistingFilter', 'Foo')); // unmodified value
188188

189-
self::assertSame(true, $hooks->do_action('testAction', (object)array('foo' => 'bar')));
189+
self::assertSame(true, $hooks->do_action('testAction', (object)['foo' => 'bar']));
190190
self::assertSame(true, $hooks->do_action('testAction', 'param1', 'param2', 'param3', 'param4'));
191-
self::assertSame(true, $hooks->do_action_ref_array('testAction', array('test')));
191+
self::assertSame(true, $hooks->do_action_ref_array('testAction', ['test']));
192192
self::assertSame('foo', $hooks->apply_filters('testFilter', 'Foo'));
193-
self::assertSame('foo', $hooks->apply_filters_ref_array('testFilter', array('Foo')));
193+
self::assertSame('foo', $hooks->apply_filters_ref_array('testFilter', ['Foo']));
194194
}
195195

196196
public function testRunShortcodeFunctions()
@@ -204,7 +204,7 @@ public function testRunShortcodeFunctions()
204204
self::assertSame('testAction', $hooks->do_shortcode('testAction'));
205205

206206
$testClass = new HooksFooBar();
207-
self::assertSame(true, $hooks->add_shortcode('testAction', array($testClass, 'doSomethingFunction')));
207+
self::assertSame(true, $hooks->add_shortcode('testAction', [$testClass, 'doSomethingFunction']));
208208
self::assertTrue($hooks->shortcode_exists('testAction'));
209209

210210
self::assertSame('foo bar <li class="">content</li>', $hooks->do_shortcode('foo bar [testAction foo="bar"]content[/testAction]'));

tests/HooksTest.php

+14-13
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public function hookTestString_2($input)
4848
*/
4949
public function testHooks()
5050
{
51-
$this->hooks->add_filter('test', array($this, 'hookTestString_1'));
52-
$this->hooks->add_filter('test', array($this, 'hookTestString_2'));
51+
$this->hooks->add_filter('test', [$this, 'hookTestString_1']);
52+
$this->hooks->add_filter('test', [$this, 'hookTestString_2']);
5353

5454
$lall = $this->hooks->apply_filters('test', '');
5555

@@ -161,33 +161,34 @@ public function testRunHookFunctions()
161161
self::assertSame(true, $hooks->remove_all_actions('testAction'));
162162

163163
self::assertSame(false, $hooks->do_action('testAction'));
164-
self::assertSame(false, $hooks->do_action_ref_array('testNotExistingAction', array()));
164+
self::assertSame(false, $hooks->do_action_ref_array('testNotExistingAction', []));
165165
self::assertSame('Foo', $hooks->apply_filters('testFilter', 'Foo'));
166166

167-
self::assertSame(false, $hooks->do_action_ref_array('testAction', array('test')));
168-
self::assertSame('Foo', $hooks->apply_filters_ref_array('testFilter', array('Foo')));
167+
self::assertSame(false, $hooks->do_action_ref_array('testAction', ['test']));
168+
self::assertSame('Foo', $hooks->apply_filters_ref_array('testFilter', ['Foo']));
169169

170-
$mock = $this->getMockBuilder('stdClass')->setMethods( array('doSomeAction', 'applySomeFilter'))->getMock();$mock->expects(self::exactly(4))->method('doSomeAction');
170+
$mock = $this->getMockBuilder('stdClass')->setMethods(['doSomeAction', 'applySomeFilter'])->getMock();
171+
$mock->expects(self::exactly(4))->method('doSomeAction');
171172
$mock->expects(self::exactly(10))->method('applySomeFilter')->willReturn('foo');
172173

173-
self::assertSame(true, $hooks->add_action('testAction', array($mock, 'doSomeAction')));
174-
self::assertSame(true, $hooks->add_filter('testFilter', array($mock, 'applySomeFilter')));
174+
self::assertSame(true, $hooks->add_action('testAction', [$mock, 'doSomeAction']));
175+
self::assertSame(true, $hooks->add_filter('testFilter', [$mock, 'applySomeFilter']));
175176

176177
self::assertSame(8, $hooks->did_action('testAction'));
177178
self::assertSame(true, $hooks->do_action('testAction'));
178179
self::assertSame(9, $hooks->did_action('testAction'));
179180
self::assertSame('foo', $hooks->apply_filters('testFilter', 'Foo'));
180181

181-
self::assertSame(true, $hooks->add_filter('all', array($mock, 'applySomeFilter')));
182+
self::assertSame(true, $hooks->add_filter('all', [$mock, 'applySomeFilter']));
182183

183184
self::assertSame(false, $hooks->do_action('notExistingAction'));
184185
self::assertSame('Foo', $hooks->apply_filters('notExistingFilter', 'Foo')); // unmodified value
185186

186-
self::assertSame(true, $hooks->do_action('testAction', (object)array('foo' => 'bar')));
187+
self::assertSame(true, $hooks->do_action('testAction', (object)['foo' => 'bar']));
187188
self::assertSame(true, $hooks->do_action('testAction', 'param1', 'param2', 'param3', 'param4'));
188-
self::assertSame(true, $hooks->do_action_ref_array('testAction', array('test')));
189+
self::assertSame(true, $hooks->do_action_ref_array('testAction', ['test']));
189190
self::assertSame('foo', $hooks->apply_filters('testFilter', 'Foo'));
190-
self::assertSame('foo', $hooks->apply_filters_ref_array('testFilter', array('Foo')));
191+
self::assertSame('foo', $hooks->apply_filters_ref_array('testFilter', ['Foo']));
191192
}
192193

193194
public function testRunShortcodeFunctions()
@@ -201,7 +202,7 @@ public function testRunShortcodeFunctions()
201202
self::assertSame('testAction', $hooks->do_shortcode('testAction'));
202203

203204
$testClass = new HooksFooBar();
204-
self::assertSame(true, $hooks->add_shortcode('testAction', array($testClass, 'doSomethingFunction')));
205+
self::assertSame(true, $hooks->add_shortcode('testAction', [$testClass, 'doSomethingFunction']));
205206
self::assertTrue($hooks->shortcode_exists('testAction'));
206207

207208
self::assertSame('foo bar <li class="">content</li>', $hooks->do_shortcode('foo bar [testAction foo="bar"]content[/testAction]'));

0 commit comments

Comments
 (0)