CLI_Command::command_to_array()privateWP-CLI 1.0

{} It's a method of the class: CLI_Command{}

No Hooks.

Return

null. Nothing.

Usage

// private - for code of main (parent) class only
$result = $this->command_to_array( $command );
$command (required)
-

Code of CLI_Command::command_to_array() WP-CLI 2.7.0-alpha

private function command_to_array( $command ) {
	$dump = [
		'name'        => $command->get_name(),
		'description' => $command->get_shortdesc(),
		'longdesc'    => $command->get_longdesc(),
	];

	foreach ( $command->get_subcommands() as $subcommand ) {
		$dump['subcommands'][] = $this->command_to_array( $subcommand );
	}

	if ( empty( $dump['subcommands'] ) ) {
		$dump['synopsis'] = (string) $command->get_synopsis();
	}

	return $dump;
}