/** * Creates a new composite command * * @param CompositeCommand $parent Parent command * @param string $name Name of command to create * @param \ReflectionClass $reflection Object with name of class to call * @param array $options Options to feed into a called command * @return CompositeCommand */ private static function createCompositeCommand(CompositeCommand $parent, $name, \ReflectionClass $reflection, $options) { $docparser = new DocParser($reflection->getDocComment()); // If the composite command already exists, don't recreate it. // This allows plugins to add to existing commands. $args = array($name); $container = $parent->findSubcommand($args); if (!$container) { $container = new CompositeCommand($parent, $name, $docparser); } foreach ($reflection->getMethods() as $method) { if (!self::isGoodMethod($method)) { continue; } $subcommand = self::createSubcommand($container, false, $reflection->name, $method, $options); $subcommand_name = $subcommand->getName(); $container->addSubcommand($subcommand_name, $subcommand); } return $container; }