Skip to content

Commit 0af4e54

Browse files
authored
Merge pull request #339 from wp-cli/fix/runcommand-hardening
Fix `WPCliRuncommandDynamicReturnTypeExtension` when passing invalid options
2 parents 0c0b800 + 85501aa commit 0af4e54

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎src/PHPStan/WPCliRuncommandDynamicReturnTypeExtension.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function getTypeFromStaticMethodCall(
3939
): Type {
4040
$args = $methodCall->getArgs();
4141

42-
$returnOption = new ConstantBooleanType( true );
42+
$returnOption = new ConstantBooleanType( false );
4343
$parseOption = new ConstantBooleanType( false );
4444
$exitOnErrorOption = new ConstantBooleanType( true );
4545

‎tests/data/runcommand.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,14 @@
6565
]
6666
);
6767
assertType( 'string', $value );
68+
69+
$value = WP_CLI::runcommand( 'plugin list' );
70+
assertType( 'null', $value );
71+
72+
$value = WP_CLI::runcommand(
73+
'plugin list',
74+
[
75+
'exit_error' => false,
76+
]
77+
);
78+
assertType( 'null', $value );

0 commit comments

Comments
 (0)