@@ -785,15 +785,13 @@ private static function terminate_proc( $master_pid ): void {
785785
786786 $ output = shell_exec ( "ps -o ppid,pid,command | grep $ master_pid " );
787787
788- if ( is_string ( $ output ) ) {
789- foreach ( explode ( PHP_EOL , $ output ) as $ line ) {
790- if ( preg_match ( '/^\s*(\d+)\s+(\d+)/ ' , $ line , $ matches ) ) {
791- $ parent = $ matches [1 ];
792- $ child = $ matches [2 ];
793-
794- if ( (int ) $ parent === (int ) $ master_pid ) {
795- self ::terminate_proc ( (int ) $ child );
796- }
788+ foreach ( explode ( PHP_EOL , $ output ? $ output : '' ) as $ line ) {
789+ if ( preg_match ( '/^\s*(\d+)\s+(\d+)/ ' , $ line , $ matches ) ) {
790+ $ parent = $ matches [1 ];
791+ $ child = $ matches [2 ];
792+
793+ if ( (int ) $ parent === (int ) $ master_pid ) {
794+ self ::terminate_proc ( (int ) $ child );
797795 }
798796 }
799797 }
@@ -968,10 +966,10 @@ protected static function bootstrap_feature_context(): void {
968966 * @return string
969967 */
970968 public function replace_variables ( $ str ) {
969+ $ str = preg_replace_callback ( '/\{([A-Z_][A-Z_0-9]*)\}/ ' , [ $ this , 'replace_var ' ], $ str );
971970 if ( false !== strpos ( $ str , '{INVOKE_WP_CLI_WITH_PHP_ARGS- ' ) ) {
972971 $ str = $ this ->replace_invoke_wp_cli_with_php_args ( $ str );
973972 }
974- $ str = preg_replace_callback ( '/\{([A-Z_][A-Z_0-9]*)\}/ ' , [ $ this , 'replace_var ' ], $ str );
975973 if ( false !== strpos ( $ str , '{WP_VERSION- ' ) ) {
976974 $ str = $ this ->replace_wp_versions ( $ str );
977975 }
@@ -1010,7 +1008,7 @@ private function replace_invoke_wp_cli_with_php_args( $str ) {
10101008 }
10111009
10121010 $ str = preg_replace_callback (
1013- '/{INVOKE_WP_CLI_WITH_PHP_ARGS-([^}] *)}/ ' ,
1011+ '/{INVOKE_WP_CLI_WITH_PHP_ARGS-(. *)}/ ' ,
10141012 static function ( $ matches ) use ( $ phar_path , $ shell_path ) {
10151013 return $ phar_path ? "php {$ matches [1 ]} {$ phar_path }" : ( 'WP_CLI_PHP_ARGS= ' . escapeshellarg ( $ matches [1 ] ) . ' ' . $ shell_path );
10161014 },
0 commit comments