private static function create_subcommand($parent, $name, $class_name, $method) { $docparser = new DocParser($method->getDocComment()); if (!$name) { $name = $docparser->getTag('subcommand'); } if (!$name) { $name = $method->name; } $method_name = $method->name; $when_invoked = function ($args, $assoc_args) use($class_name, $method_name) { call_user_func(array(new $class_name(), $method_name), $args, $assoc_args); }; return new Subcommand($parent, $name, $docparser, $when_invoked); }
/** * Creates a new subcommand * * @param CompositeCommand $parent Parent command * @param string $name Name of command to create * @param string $class_name Name of class command belongs to * @param \ReflectionMethod $method Name of function to invoke in class * @param array $options Options to feed into the a command * @return Subcommand */ private static function createSubcommand(CompositeCommand $parent, $name, $class_name, \ReflectionMethod $method, $options) { $docparser = new DocParser($method->getDocComment()); if (!$name) { $name = $docparser->getTag('subcommand'); if (!$name) { $name = $method->name; } } $method_name = $method->name; $when_invoked = function ($args, $assoc_args) use($class_name, $method_name, $options) { call_user_func(array(new $class_name($options), $method_name), $args, $assoc_args); }; $subcommand = new Subcommand($parent, $name, $docparser, $when_invoked, $options); return $subcommand; }