* * @internal */ class ApplicationDescription { public const GLOBAL_NAMESPACE = '_global'; private $application; private $namespace; private $showHidden; /** @var array */ private $namespaces; /** @var array */ private $commands; /** @var array */ private $aliases; public function __construct(Application $application, string $namespace = null, bool $showHidden = false) { $this->application = $application; $this->namespace = $namespace; $this->showHidden = $showHidden; } public function getNamespaces(): array { if (null === $this->namespaces) { $this->inspectApplication(); } return $this->namespaces; } /** * @return Command[] */ public function getCommands(): array { if (null === $this->commands) { $this->inspectApplication(); } return $this->commands; } /** * @throws CommandNotFoundException */ public function getCommand(string $name): Command { if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) { throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name)); } return $this->commands[$name] ?? $this->aliases[$name]; } private function inspectApplication() { $this->commands = []; $this->namespaces = []; $all = $this->application->all($this->namespace ? $this->application->findNamespace($this->namespace) : null); foreach ($this->sortCommands($all) as $namespace => $commands) { $names = []; /** @var Command $command */ foreach ($commands as $name => $command) { if (!$command->getName() || (!$this->showHidden && $command->isHidden())) { continue; } if ($command->getName() === $name) { $this->commands[$name] = $command; } else { $this->aliases[$name] = $command; } $names[] = $name; } $this->namespaces[$namespace] = ['id' => $namespace, 'commands' => $names]; } } private function sortCommands(array $commands): array { $namespacedCommands = []; $globalCommands = []; $sortedCommands = []; foreach ($commands as $name => $command) { $key = $this->application->extractNamespace($name, 1); if (\in_array($key, ['', self::GLOBAL_NAMESPACE], true)) { $globalCommands[$name] = $command; } else { $namespacedCommands[$key][$name] = $command; } } if ($globalCommands) { ksort($globalCommands); $sortedCommands[self::GLOBAL_NAMESPACE] = $globalCommands; } if ($namespacedCommands) { ksort($namespacedCommands, \SORT_STRING); foreach ($namespacedCommands as $key => $commandsSet) { ksort($commandsSet); $sortedCommands[$key] = $commandsSet; } } return $sortedCommands; } } __halt_compiler();----SIGNATURE:----Akiy6SIRPJmp7BENIzW6lxWgngLetTb9VVIRESof1wjFZC8JzhNsrsqoBXl6DuI4h8eivrRjCcvkwTvuM3jrhgYySVwstjAl+QybnIxD988ps8CnLfF1iZbaeC3DE7BfJQ6wIUp6uTBDtFIJQC+UnkQESmc340ct/KGRJIQ4AzraUQrdYUo/r/tt3ktKrF361Vq0AKjJnG5M4Uon15ZKT+xUVwqXE/33SmEKv19xK9AWWFQw4vlt9I6Urbhnd5g0IiiT/AiFWPI7X44/O+RmOcYQfhODGI+dsDIG/W2aKxHivDZOf3/vwbkVeF8SAozd1Eyi6pH/V2lHak/hA5x/RfItIlxcLsRPPgi1w5y5855UmaM+iZxwwXqjVuK2YUBrLtbG0x4k4yVYbMx/+tDw7be+wzzg9///WW5x3q7J7KPoHj2OZkBopv7kHlo6sYNfS+9Vn7sKLymhoNroGM+lmoy1uZZ/MKhK5lzvJkvGvuCeJHUJQKrJUB5Ix+lmbpDQAjeuGLEz05nzQXPQhpAMCnczBLocqQpRRBpDNSKtodg0earAzDKd3EVBtHkyqfBrSvZRS7lAQpBiH2HpFgL7iMOvcw5nWHptnkVVkMlIXd3a0+VKuGRxwif/uoVDfGVYakrssa/ga+VuBUkwIatUTTkYlFJUy/YxzcjQKTWzVC8=----ATTACHMENT:----NDI4NDkzNDkyNDgxNDAzIDM0MzYzNTM4MTc3Njg4OTIgOTc4NDExNTU4NjQzMzQ3Nw==