php/class-wp-cli.php
public static function launch_self( $command, $args = array(), $assoc_args = array(), $exit_on_error = true, $return_detailed = false, $runtime_args = array() ) {
		$reused_runtime_args = array(
			'path',
			'url',
			'user',
			'allow-root',
		);

		foreach ( $reused_runtime_args as $key ) {
			if ( isset( $runtime_args[ $key ] ) ) {
				$assoc_args[ $key ] = $runtime_args[ $key ];
				continue;
			}

			$value = self::get_runner()->config[ $key ];
			if ( $value ) {
				$assoc_args[ $key ] = $value;
			}
		}

		$php_bin = escapeshellarg( Utils\get_php_binary() );

		$script_path = $GLOBALS['argv'][0];

		if ( getenv( 'WP_CLI_CONFIG_PATH' ) ) {
			$config_path = getenv( 'WP_CLI_CONFIG_PATH' );
		} else {
			$config_path = Utils\get_home_dir() . '/.wp-cli/config.yml';
		}
		$config_path = escapeshellarg( $config_path );

		$args       = implode( ' ', array_map( 'escapeshellarg', $args ) );
		$assoc_args = \WP_CLI\Utils\assoc_args_to_str( $assoc_args );

		$full_command = "WP_CLI_CONFIG_PATH={$config_path} {$php_bin} {$script_path} {$command} {$args} {$assoc_args}";

		return self::launch( $full_command, $exit_on_error, $return_detailed );
	}
public static function launch_self( $command, $args = array(), $assoc_args = array(), $exit_on_error = true, $return_detailed = false, $runtime_args = array() ) {
		$reused_runtime_args = array(
			'path',
			'url',
			'user',
			'allow-root',
		);

		foreach ( $reused_runtime_args as $key ) {
			if ( isset( $runtime_args[ $key ] ) ) {
				$assoc_args[ $key ] = $runtime_args[ $key ];
				continue;
			}

			$value = self::get_runner()->config[ $key ];
			if ( $value ) {
				$assoc_args[ $key ] = $value;
			}
		}

		$php_bin = escapeshellarg( Utils\get_php_binary() );

		$script_path = $GLOBALS['argv'][0];

		if ( getenv( 'WP_CLI_CONFIG_PATH' ) ) {
			$config_path = getenv( 'WP_CLI_CONFIG_PATH' );
		} else {
			$config_path = Utils\get_home_dir() . '/.wp-cli/config.yml';
		}
		$config_path = escapeshellarg( $config_path );

		$args       = implode( ' ', array_map( 'escapeshellarg', $args ) );
		$assoc_args = \WP_CLI\Utils\assoc_args_to_str( $assoc_args );

		$full_command = "WP_CLI_CONFIG_PATH={$config_path} {$php_bin} {$script_path} {$command} {$args} {$assoc_args}";

		return self::launch( $full_command, $exit_on_error, $return_detailed );
	}
public static function launch_self ( $ command , $ args = array ( ) , $ assoc_args = array ( ) , $ exit_on_error = true , $ return_detailed = false , $ runtime_args = array ( ) ) { $ reused_runtime_args = array ( 'path' , 'url' , 'user' , 'allow-root' , ) ; foreach ( $ reused_runtime_args as $ key ) { if ( isset ( $ runtime_args [ $ key ] ) ) { $ assoc_args [ $ key ] = $ runtime_args [ $ key ] ; continue ; } $ value = self :: get_runner ( ) -> config [ $ key ] ; if ( $ value ) { $ assoc_args [ $ key ] = $ value ; } } $ php_bin = escapeshellarg ( Utils \ get_php_binary ( ) ) ; $ script_path = $ GLOBALS [ 'argv' ] [ 0 ] ; if ( getenv ( 'WP_CLI_CONFIG_PATH' ) ) { $ config_path = getenv ( 'WP_CLI_CONFIG_PATH' ) ; } else { $ config_path = Utils \ get_home_dir ( ) . '/.wp-cli/config.yml' ; } $ config_path = escapeshellarg ( $ config_path ) ; $ args = implode ( ' ' , array_map ( 'escapeshellarg' , $ args ) ) ; $ assoc_args = \ WP_CLI \ Utils \ assoc_args_to_str ( $ assoc_args ) ; $ full_command = "WP_CLI_CONFIG_PATH={$config_path} {$php_bin} {$script_path} {$command} {$args} {$assoc_args}" ; return self :: launch ( $ full_command , $ exit_on_error , $ return_detailed ) ; }
Run a WP-CLI command in a new process reusing the current runtime arguments.

Use `WP_CLI::runcommand()` instead, which is easier to use and works better.

Note: While this command does persist a limited set of runtime arguments,
it *does not* persist environment variables. Practically speaking, WP-CLI
packages won't be loaded when using WP_CLI::launch_self() because the
launched process doesn't have access to the current process $HOME.

@access public
@category Execution

@param string $command WP-CLI command to call.
@param array $args Positional arguments to include when calling the command.
@param array $assoc_args Associative arguments to include when calling the command.
@param bool $exit_on_error Whether to exit if the command returns an elevated return code.
@param bool $return_detailed Whether to return an exit status (default) or detailed execution results.
@param array $runtime_args Override one or more global args (path,url,user,allow-root)
@return int|ProcessRun The command exit status, or a ProcessRun instance
Run a WP - CLI command in a new process reusing the current runtime arguments .