php/WP_CLI/Runner.php
private function enumerate_commands( CompositeCommand $command, array &$list, $parent = '' ) {
		foreach ( $command->get_subcommands() as $subcommand ) {
			/** @var CompositeCommand $subcommand */
			$command_string = empty( $parent )
				? $subcommand->get_name()
				: "{$parent} {$subcommand->get_name()}";

			$list[] = $command_string;

			$this->enumerate_commands( $subcommand, $list, $command_string );
		}
	}
private function enumerate_commands( CompositeCommand $command, array &$list, $parent = '' ) {
		foreach ( $command->get_subcommands() as $subcommand ) {
			/** @var CompositeCommand $subcommand */
			$command_string = empty( $parent )
				? $subcommand->get_name()
				: "{$parent} {$subcommand->get_name()}";

			$list[] = $command_string;

			$this->enumerate_commands( $subcommand, $list, $command_string );
		}
	}
private function enumerate_commands ( CompositeCommand $ command , array & $ list , $ parent = '' ) { foreach ( $ command -> get_subcommands ( ) as $ subcommand ) { /** @var CompositeCommand $subcommand */ $ command_string = empty ( $ parent ) ? $ subcommand -> get_name ( ) : "{$parent} {$subcommand->get_name()}" ; $ list [ ] = $ command_string ; $ this -> enumerate_commands ( $ subcommand , $ list , $ command_string ) ; } }
Recursive method to enumerate all known commands.

@param CompositeCommand $command Composite command to recurse over.
@param array            $list    Reference to list accumulating results.
@param string           $parent  Parent command to use as prefix.
Recursive method to enumerate all known commands .