Skip to content

Commit 297d895

Browse files
committed
PHPStan fixes
1 parent cf64d50 commit 297d895

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

‎composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313
],
1414
"require": {
15-
"wp-cli/wp-cli": "^2.12"
15+
"wp-cli/wp-cli": "^2.13"
1616
},
1717
"require-dev": {
1818
"wp-cli/wp-cli-tests": "^5"

‎src/Shell_Command.php‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ class Shell_Command extends WP_CLI_Command {
4646
* wp> // Make changes to files in the plugin directory
4747
* Detected changes in wp-content/plugins/my-plugin, restarting shell...
4848
* wp>
49+
*
50+
* @param string[] $_ Positional arguments. Unused.
51+
* @param array{basic?: bool, watch?: string} $assoc_args Associative arguments.
4952
*/
5053
public function __invoke( $_, $assoc_args ) {
5154
$watch_path = Utils\get_flag_value( $assoc_args, 'watch', false );
@@ -107,7 +110,7 @@ public function __invoke( $_, $assoc_args ) {
107110
* Resolve and validate the watch path.
108111
*
109112
* @param string $path Path to watch.
110-
* @return string Absolute path to watch.
113+
* @return string|never Absolute path to watch.
111114
*/
112115
private function resolve_watch_path( $path ) {
113116
if ( ! file_exists( $path ) ) {
@@ -128,7 +131,7 @@ private function resolve_watch_path( $path ) {
128131
* This replaces the current process with a new one to fully reload all code.
129132
* Falls back to in-process restart if pcntl_exec is not available.
130133
*
131-
* @param array $assoc_args Command arguments to preserve.
134+
* @param array{basic?: bool, watch?: string} $assoc_args Command arguments to preserve.
132135
*/
133136
private function restart_process( $assoc_args ) {
134137
// Check if pcntl_exec is available
@@ -143,10 +146,10 @@ private function restart_process( $assoc_args ) {
143146
// Get the WP-CLI script path
144147
$wp_cli_script = null;
145148
foreach ( array( 'argv', '_SERVER' ) as $source ) {
146-
if ( 'argv' === $source && isset( $GLOBALS['argv'][0] ) ) {
149+
if ( 'argv' === $source && is_array( $GLOBALS['argv'] ) && isset( $GLOBALS['argv'][0] ) ) {
147150
$wp_cli_script = $GLOBALS['argv'][0];
148151
break;
149-
} elseif ( '_SERVER' === $source && isset( $_SERVER['argv'][0] ) ) {
152+
} elseif ( '_SERVER' === $source && is_array( $_SERVER['argv'] ) && isset( $_SERVER['argv'][0] ) ) {
150153
$wp_cli_script = $_SERVER['argv'][0];
151154
break;
152155
}
@@ -170,9 +173,9 @@ private function restart_process( $assoc_args ) {
170173
}
171174

172175
// Add the path argument if present in $_SERVER
173-
if ( isset( $_SERVER['argv'] ) ) {
176+
if ( isset( $_SERVER['argv'] ) && is_array( $_SERVER['argv'] ) ) {
174177
foreach ( $_SERVER['argv'] as $arg ) {
175-
if ( '--path=' === substr( $arg, 0, 7 ) ) {
178+
if ( is_string( $arg ) && '--path=' === substr( $arg, 0, 7 ) ) {
176179
$args[] = $arg;
177180
}
178181
}

‎src/WP_CLI/Shell/REPL.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ private static function create_prompt_cmd( $prompt, $history_path ) {
153153
$prompt = escapeshellarg( $prompt );
154154
$history_path = escapeshellarg( $history_path );
155155
if ( getenv( 'WP_CLI_CUSTOM_SHELL' ) ) {
156-
$shell_binary = getenv( 'WP_CLI_CUSTOM_SHELL' );
156+
$shell_binary = (string) getenv( 'WP_CLI_CUSTOM_SHELL' );
157157
} else {
158158
$shell_binary = '/bin/bash';
159159
}

0 commit comments

Comments
 (0)