Webmozart\Console\Api\Command\CommandCollection::getNames PHP Method

getNames() public method

The names are sorted alphabetically in ascending order. If you set $includeAliases to true, the alias names are included in the result.
public getNames ( boolean $includeAliases = false ) : string[]
$includeAliases boolean Whether to include alias names in the result.
return string[] The sorted command names.
    public function getNames($includeAliases = false)
    {
        $names = array_keys($this->commands);
        if ($includeAliases) {
            $names = array_merge($names, array_keys($this->aliasIndex));
        }
        sort($names);
        return $names;
    }

Usage Example

Ejemplo n.º 1
0
 public function testGetNamesWithAliases()
 {
     $ls = new Command(CommandConfig::create('ls')->addAlias('ls-alias'));
     $cd = new Command(CommandConfig::create('cd')->addAlias('cd-alias'));
     $this->collection->add($ls);
     $this->collection->add($cd);
     $this->assertSame(array('cd', 'cd-alias', 'ls', 'ls-alias'), $this->collection->getNames(true));
 }
All Usage Examples Of Webmozart\Console\Api\Command\CommandCollection::getNames