Webmozart\Console\Api\Config\CommandConfig::markAnonymous PHP Method

markAnonymous() public method

Anonymous commands cannot be called by name: php protected function configure() { $this ->beginCommand('add') ->markAnonymous() ->addArgument('host', Argument::REQUIRED) ->end() ... ; } The name "add" is given to the command only to access the command later on. Since the command is anonymous, the name cannot be passed when when calling the command: php $ ./console add localhost Instead, the command should be called without name: php $ ./console localhost
public markAnonymous ( ) : static
return static The current instance.
    public function markAnonymous()
    {
        $this->default = true;
        $this->anonymous = true;
        return $this;
    }

Usage Example

示例#1
0
 public function testBuildAnonymousArgsFormat()
 {
     $baseFormat = new ArgsFormat();
     $this->config->setName('command');
     $this->config->setAliases(array('alias1', 'alias2'));
     $this->config->addOption('option');
     $this->config->addArgument('argument');
     $this->config->markAnonymous();
     $expected = ArgsFormat::build($baseFormat)->addArgument(new Argument('argument'))->addOption(new Option('option'))->getFormat();
     $this->assertEquals($expected, $this->config->buildArgsFormat($baseFormat));
 }
All Usage Examples Of Webmozart\Console\Api\Config\CommandConfig::markAnonymous