php/WP_CLI/Dispatcher/CommandFactory.php
private static function create_subcommand( $parent, $name, $callable, $reflection ) {
		$doc_comment = self::get_doc_comment( $reflection );
		$docparser   = new \WP_CLI\DocParser( $doc_comment );

		if ( is_array( $callable ) ) {
			if ( ! $name ) {
				$name = $docparser->get_tag( 'subcommand' );
			}

			if ( ! $name ) {
				$name = $reflection->name;
			}
		}
		if ( ! $doc_comment ) {
			\WP_CLI::debug( null === $doc_comment ? "Failed to get doc comment for {$name}." : "No doc comment for {$name}.", 'commandfactory' );
		}

		$when_invoked = function ( $args, $assoc_args ) use ( $callable ) {
			if ( is_array( $callable ) ) {
				$callable[0] = is_object( $callable[0] ) ? $callable[0] : new $callable[0]();
				call_user_func( array( $callable[0], $callable[1] ), $args, $assoc_args );
			} else {
				call_user_func( $callable, $args, $assoc_args );
			}
		};

		return new Subcommand( $parent, $name, $docparser, $when_invoked );
	}
private static function create_subcommand( $parent, $name, $callable, $reflection ) {
		$doc_comment = self::get_doc_comment( $reflection );
		$docparser   = new \WP_CLI\DocParser( $doc_comment );

		if ( is_array( $callable ) ) {
			if ( ! $name ) {
				$name = $docparser->get_tag( 'subcommand' );
			}

			if ( ! $name ) {
				$name = $reflection->name;
			}
		}
		if ( ! $doc_comment ) {
			\WP_CLI::debug( null === $doc_comment ? "Failed to get doc comment for {$name}." : "No doc comment for {$name}.", 'commandfactory' );
		}

		$when_invoked = function ( $args, $assoc_args ) use ( $callable ) {
			if ( is_array( $callable ) ) {
				$callable[0] = is_object( $callable[0] ) ? $callable[0] : new $callable[0]();
				call_user_func( array( $callable[0], $callable[1] ), $args, $assoc_args );
			} else {
				call_user_func( $callable, $args, $assoc_args );
			}
		};

		return new Subcommand( $parent, $name, $docparser, $when_invoked );
	}
private static function create_subcommand ( $ parent , $ name , $ callable , $ reflection ) { $ doc_comment = self :: get_doc_comment ( $ reflection ) ; $ docparser = new \ WP_CLI \ DocParser ( $ doc_comment ) ; if ( is_array ( $ callable ) ) { if ( ! $ name ) { $ name = $ docparser -> get_tag ( 'subcommand' ) ; } if ( ! $ name ) { $ name = $ reflection -> name ; } } if ( ! $ doc_comment ) { \ WP_CLI :: debug ( null === $ doc_comment ? "Failed to get doc comment for {$name}." : "No doc comment for {$name}." , 'commandfactory' ) ; } $ when_invoked = function ( $ args , $ assoc_args ) use ( $ callable ) { if ( is_array ( $ callable ) ) { $ callable [ 0 ] = is_object ( $ callable [ 0 ] ) ? $ callable [ 0 ] : new $ callable [ 0 ] ( ) ; call_user_func ( array ( $ callable [ 0 ] , $ callable [ 1 ] ) , $ args , $ assoc_args ) ; } else { call_user_func ( $ callable , $ args , $ assoc_args ) ; } } ; return new Subcommand ( $ parent , $ name , $ docparser , $ when_invoked ) ; }
Create a new Subcommand instance.

@param mixed $parent The new command's parent Composite command
@param string|bool $name Represents how the command should be invoked.
If false, will be determined from the documented subject, represented by `$reflection`.
@param mixed $callable A callable function or closure, or class name and method
@param object $reflection Reflection instance, for doc parsing
@param string $class A subclass of WP_CLI_Command
@param string $method Class method to be called upon invocation.
Create a new Subcommand instance .