Skip to content

Commit ff42db2

Browse files
committed
Clean up some PHPStan nonsense.
1 parent 396b8f6 commit ff42db2

File tree

4 files changed

+12
-31
lines changed

4 files changed

+12
-31
lines changed

src/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ function bin(): \Closure
395395
}
396396

397397
// Handle --help
398-
if ($usageException !== null || $input->getOption('help')) {
398+
if (!isset($config) || $usageException !== null || $input->getOption('help')) {
399399
if ($usageException !== null) {
400400
echo $usageException->getMessage().\PHP_EOL.\PHP_EOL;
401401
}

test/FakeShell.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ class FakeShell extends Shell
2020

2121
public function __construct(Configuration $config = null)
2222
{
23-
// This space intentionally left blank
23+
// Do something (silly) with $config for phpstan's sake.
24+
$config = null;
2425
}
2526

2627
public function addMatchers(array $matchers)

test/fixtures/config.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
if (!isset($config)) {
13+
throw new \Exception('$config not found');
14+
}
15+
1216
$config->setRuntimeDir(\sys_get_temp_dir().'/psysh_test/withconfig/temp');
1317

1418
return [

vendor-bin/phpstan/baseline.neon

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
parameters:
22
ignoreErrors:
3+
-
4+
message: '#^Variable \$string on left side of \?\? always exists and is not nullable\.$#'
5+
path: ../../src/Readline/Hoa/ConsoleOutput.php
6+
37
-
48
message: "#^Variable \\$_except in empty\\(\\) always exists and is always falsy\\.$#"
59
count: 1
@@ -10,6 +14,7 @@ parameters:
1014
count: 2
1115
path: ../../src/Readline/Hoa/Readline.php
1216

17+
# PHPStan appears incapable of dealing with constructor parameters required by an interface, so...
1318
-
1419
message: "#^Constructor of class Psy\\\\Readline\\\\Transient has an unused parameter \\$historyFile\\.$#"
1520
count: 1
@@ -29,32 +34,3 @@ parameters:
2934
message: "#^Constructor of class Psy\\\\Readline\\\\Userland has an unused parameter \\$historySize\\.$#"
3035
count: 1
3136
path: ../../src/Readline/Userland.php
32-
33-
-
34-
message: "#^Variable \\$config might not be defined\\.$#"
35-
count: 3
36-
path: ../../src/functions.php
37-
38-
-
39-
message: "#^Constructor of class Psy\\\\Test\\\\FakeShell has an unused parameter \\$config\\.$#"
40-
count: 1
41-
path: ../../test/FakeShell.php
42-
43-
-
44-
message: "#^Variable \\$config might not be defined\\.$#"
45-
count: 1
46-
path: ../../test/fixtures/config.php
47-
48-
-
49-
message: "#^Constructor of class Psy\\\\Command\\\\ShowCommand has an unused parameter \\$colorMode\\.$#"
50-
count: 1
51-
path: ../../src/Command/ShowCommand.php
52-
53-
-
54-
message: "#^Constructor of class Psy\\\\Command\\\\WhereamiCommand has an unused parameter \\$colorMode\\.$#"
55-
count: 1
56-
path: ../../src/Command/WhereamiCommand.php
57-
58-
-
59-
message: '#^Variable \$string on left side of \?\? always exists and is not nullable\.$#'
60-
path: ../../src/Readline/Hoa/ConsoleOutput.php

0 commit comments

Comments
 (0)