Skip to content

Commit 46b89ef

Browse files
committed
Exclude MissingParentheses rule and revert the change
1 parent 0bc243b commit 46b89ef

10 files changed

+31
-26
lines changed

phpcs.xml.dist

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@
1010

1111
<rule ref="PSR12"/>
1212

13+
<rule ref="PSR12">
14+
<exclude name="PSR12.Classes.ClassInstantiation.MissingParentheses" />
15+
</rule>
16+
1317
<rule ref="PSR2.Classes.PropertyDeclaration.Underscore">
14-
<exclude-pattern>/src/</exclude-pattern>
18+
<exclude-pattern>/src/Input/Command.php</exclude-pattern>
19+
<exclude-pattern>/src/Input/Parser.php</exclude-pattern>
1520
</rule>
1621

1722
<rule ref="PSR12.Properties.ConstantVisibility.NotFound">

src/Application.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public function commandFor(array $argv): Command
220220
public function io(Interactor $io = null)
221221
{
222222
if ($io || !$this->io) {
223-
$this->io = $io ?? new Interactor();
223+
$this->io = $io ?? new Interactor;
224224
}
225225

226226
if (\func_num_args() === 0) {

src/Helper/OutputHelper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class OutputHelper
3636

3737
public function __construct(Writer $writer = null)
3838
{
39-
$this->writer = $writer ?? new Writer();
39+
$this->writer = $writer ?? new Writer;
4040
}
4141

4242
/**

src/Input/Command.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ public function action(callable $action = null)
425425
*/
426426
protected function writer(): Writer
427427
{
428-
return $this->_app ? $this->_app->io()->writer() : new Writer();
428+
return $this->_app ? $this->_app->io()->writer() : new Writer;
429429
}
430430

431431
/**
@@ -435,6 +435,6 @@ protected function writer(): Writer
435435
*/
436436
protected function io(): Interactor
437437
{
438-
return $this->_app ? $this->_app->io() : new Interactor();
438+
return $this->_app ? $this->_app->io() : new Interactor;
439439
}
440440
}

src/Input/Parser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ abstract class Parser
5151
*/
5252
public function parse(array $argv): self
5353
{
54-
$this->_normalizer = new Normalizer();
54+
$this->_normalizer = new Normalizer;
5555

5656
\array_shift($argv);
5757

src/Output/Writer.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ public function __construct(string $path = null, Color $colorizer = null)
182182
$this->stream = $path ?: \STDOUT;
183183
$this->eStream = $path ?: \STDERR;
184184

185-
$this->cursor = new Cursor();
186-
$this->colorizer = $colorizer ?? new Color();
185+
$this->cursor = new Cursor;
186+
$this->colorizer = $colorizer ?? new Color;
187187
}
188188

189189
/**
@@ -286,7 +286,7 @@ public function raw($text, bool $error = false): self
286286
*/
287287
public function table(array $rows, array $styles = []): self
288288
{
289-
$table = (new Table())->render($rows, $styles);
289+
$table = (new Table)->render($rows, $styles);
290290

291291
return $this->colors($table);
292292
}

tests/ApplicationTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public function test_io()
221221

222222
$this->assertInstanceOf(Interactor::class, $oio = $a->io());
223223

224-
$a->io(new Interactor());
224+
$a->io(new Interactor);
225225

226226
$this->assertInstanceOf(Interactor::class, $a->io());
227227
$this->assertNotSame($oio, $a->io());

tests/Output/ColorTest.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ class ColorTest extends TestCase
1919
/** @dataProvider methods */
2020
public function test_methods($method, $color)
2121
{
22-
$this->assertSame("\033[0;{$color}m{$method}\033[0m", (new Color())->{$method}($method));
22+
$this->assertSame("\033[0;{$color}m{$method}\033[0m", (new Color)->{$method}($method));
2323
}
2424

2525
public function test_comment()
2626
{
27-
$this->assertSame("\033[2;37mcomment\033[0m", (new Color())->comment('comment'));
27+
$this->assertSame("\033[2;37mcomment\033[0m", (new Color)->comment('comment'));
2828
}
2929

3030
public function test_custom_style()
3131
{
3232
Color::style('alert', ['bg' => Color::YELLOW, 'fg' => Color::RED, 'bold' => 1]);
3333

34-
$this->assertSame("\033[1;31;43malert\033[0m", (new Color())->alert('alert'));
34+
$this->assertSame("\033[1;31;43malert\033[0m", (new Color)->alert('alert'));
3535

3636
$this->expectException(\InvalidArgumentException::class);
3737
$this->expectExceptionMessage('Trying to define existing style');
@@ -49,7 +49,7 @@ public function test_invalid_custom_style()
4949

5050
public function test_colors()
5151
{
52-
$c = new Color();
52+
$c = new Color;
5353

5454
$this->assertSame("\nabc\n", $c->colors('<eol>abc</eol>'));
5555
$this->assertSame("\033[0;31mRed\033[0m", $c->colors('<red>Red</end>'));
@@ -63,25 +63,25 @@ public function test_colors()
6363

6464
public function test_magic_call()
6565
{
66-
$this->assertSame("\033[1;37mline\033[0m", (new Color())->bold('line'));
66+
$this->assertSame("\033[1;37mline\033[0m", (new Color)->bold('line'));
6767

6868
$this->expectException(\InvalidArgumentException::class);
6969
$this->expectExceptionMessage('Text required');
7070

71-
(new Color())->bgRed();
71+
(new Color)->bgRed();
7272
}
7373

7474
public function test_magic_call_color()
7575
{
76-
$this->assertSame("\033[0;35mpurple\033[0m", (new Color())->purple('purple'));
76+
$this->assertSame("\033[0;35mpurple\033[0m", (new Color)->purple('purple'));
7777
}
7878

7979
public function test_magic_call_invalid()
8080
{
8181
$this->expectException(\InvalidArgumentException::class);
8282
$this->expectExceptionMessage('Style "random" not defined');
8383

84-
(new Color())->random('Rand');
84+
(new Color)->random('Rand');
8585
}
8686

8787
public function methods()

tests/Output/CursorTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function test()
2020
{
2121
ob_start();
2222

23-
$c = new Cursor();
23+
$c = new Cursor;
2424

2525
echo $c->up(1) . $c->down(2) . $c->right(3) . $c->left(4) . $c->next(0) . $c->prev(2);
2626

@@ -31,7 +31,7 @@ public function test_clean()
3131
{
3232
ob_start();
3333

34-
$c = new Cursor();
34+
$c = new Cursor;
3535

3636
echo $c->eraseLine() . $c->clear() . $c->clearUp() . $c->clearDown();
3737

@@ -42,7 +42,7 @@ public function test_move()
4242
{
4343
ob_start();
4444

45-
$c = new Cursor();
45+
$c = new Cursor;
4646

4747
echo $c->moveTo(1, 2) . $c->moveTo(5, 8);
4848

tests/Output/WriterTest.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,31 @@ class WriterTest extends CliTestCase
1919
{
2020
public function test_simple_write()
2121
{
22-
(new Writer())->write('Hey');
22+
(new Writer)->write('Hey');
2323

2424
$this->assertContains('Hey', $this->buffer());
2525
$this->assertSame("\033[0;37mHey\033[0m", $this->buffer());
2626
}
2727

2828
public function test_write_error()
2929
{
30-
(new Writer())->error->write('Something wrong');
30+
(new Writer)->error->write('Something wrong');
3131

3232
$this->assertContains('Something wrong', $this->buffer());
3333
$this->assertSame("\033[0;31mSomething wrong\033[0m", $this->buffer());
3434
}
3535

3636
public function test_write_with_newline()
3737
{
38-
(new Writer())->write('Hello', true);
38+
(new Writer)->write('Hello', true);
3939

4040
$this->assertContains('Hello', $this->buffer());
4141
$this->assertSame("\033[0;37mHello\033[0m" . PHP_EOL, $this->buffer());
4242
}
4343

4444
public function test_write_bold_red_bggreen()
4545
{
46-
(new Writer())->bold->red->bgGreen->write('bold->red->bgGreen');
46+
(new Writer)->bold->red->bgGreen->write('bold->red->bgGreen');
4747

4848
$this->assertContains('bold->red->bgGreen', $this->buffer());
4949
$this->assertSame("\033[1;31;42mbold->red->bgGreen\033[0m", $this->buffer());
@@ -106,6 +106,6 @@ public function test_table_throws()
106106

107107
public function test_colorizer()
108108
{
109-
$this->assertInstanceOf(Color::class, (new Writer())->colorizer());
109+
$this->assertInstanceOf(Color::class, (new Writer)->colorizer());
110110
}
111111
}

0 commit comments

Comments
 (0)