public function getApplication(): Application
    {
        if (!empty($this->application)) {
            return $this->application;
        }

        $this->application = new Application($this->config->getName(), $this->config->getVersion());
        $this->application->setCatchExceptions(false);
        $this->application->setAutoExit(false);

        if (!is_null($this->locator)) {
            foreach ($this->locator->locateCommands() as $command) {
                $this->application->add($command);
            }
        }

        // Register user defined commands
        $static = new StaticLocator($this->config->getCommands(), $this->container);
        foreach ($static->locateCommands() as $command) {
            $this->application->add($command);
        }

        return $this->application;
    }