@@ -60,7 +60,6 @@ class Shell_Command extends WP_CLI_Command {
6060 *
6161 * @param string[] $_ Positional arguments. Unused.
6262 * @param array{basic?: bool, watch?: string} $assoc_args Associative arguments.
63-
6463 */
6564 public function __invoke ( $ _ , $ assoc_args ) {
6665 $ watch_path = Utils \get_flag_value ( $ assoc_args , 'watch ' , false );
@@ -99,9 +98,16 @@ public function __invoke( $_, $assoc_args ) {
9998 /**
10099 * Start the shell REPL.
101100 *
102- * @param array<string, bool| string> $assoc_args Associative arguments.
101+ * @param array{basic?: bool, watch?: string} $assoc_args Associative arguments.
103102 */
104103 private function start_shell ( $ assoc_args ) {
104+ $ watch_path = Utils \get_flag_value ( $ assoc_args , 'watch ' , '' );
105+
106+ if ( $ watch_path && ! Utils \get_flag_value ( $ assoc_args , 'basic ' ) ) {
107+ WP_CLI ::warning ( 'The --watch option only works with the built-in REPL. Enabling --basic mode. ' );
108+ $ assoc_args ['basic ' ] = true ;
109+ }
110+
105111 $ class = WP_CLI \Shell \REPL ::class;
106112
107113 $ implementations = array (
@@ -178,6 +184,11 @@ private function resolve_watch_path( $path ) {
178184 * @param array{basic?: bool, watch?: string} $assoc_args Command arguments to preserve.
179185 */
180186 private function restart_process ( $ assoc_args ) {
187+ /**
188+ * @var array{0?: string} $argv
189+ */
190+ global $ argv ;
191+
181192 // Check if pcntl_exec is available
182193 if ( ! function_exists ( 'pcntl_exec ' ) ) {
183194 WP_CLI ::debug ( 'pcntl_exec not available, falling back to in-process restart ' , 'shell ' );
@@ -187,10 +198,14 @@ private function restart_process( $assoc_args ) {
187198 // Build the command to restart wp shell with the same arguments
188199 $ php_binary = Utils \get_php_binary ();
189200
201+ /**
202+ * @var array{argv: array{0?: string}} $_SERVER
203+ */
204+
190205 // Get the WP-CLI script path
191206 $ wp_cli_script = null ;
192- if ( isset ( $ GLOBALS [ ' argv ' ] [0 ] ) ) {
193- $ wp_cli_script = $ GLOBALS [ ' argv ' ] [0 ];
207+ if ( isset ( $ argv [0 ] ) ) {
208+ $ wp_cli_script = $ argv [0 ];
194209 } elseif ( isset ( $ _SERVER ['argv ' ][0 ] ) ) {
195210 $ wp_cli_script = $ _SERVER ['argv ' ][0 ];
196211 }
0 commit comments