/** * Object constructor. Sets object properties * * @param CompositeCommand $parent Parent command dispatcher object * @param string $name Name of command to run * @param DocParser $docparser DocParser object for analysis of docs * @return CompositeCommand $this */ public function __construct(CompositeCommand $parent, $name, DocParser $docparser) { $this->name = $name; $this->parent = $parent; $this->shortdesc = $docparser->getShortdesc(); $this->longdesc = $docparser->getLongdesc(); }
private static function create_subcommand($parent, $name, $class_name, $method) { $docparser = new DocParser($method->getDocComment()); if (!$name) { $name = $docparser->get_tag('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 * @return Subcommand */ private static function createSubcommand(CompositeCommand $parent, $name, $class_name, \ReflectionMethod $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); }; $subcommand = new Subcommand($parent, $name, $docparser, $when_invoked); return $subcommand; }