Issue Bug Closed

#92313Wrongly Hint in method 'getCommandByIdentifier'

Dieter Porth 09/15/20, 16:53 updated 09/29/20, 15:06

Description

The hint `:command` in the function `getCommandByIdentifier` will cause an error, if $this->commands[$identifier] is not defined. PHPStorm mark the ‘null’ as error

Line 87 in TYPO3\CMS\Core\Console\CommandRegistry

/**
     * @param string $identifier
     * @throws CommandNameAlreadyInUseException
     * @throws UnknownCommandException
     * @return Command
     */
    public function getCommandByIdentifier(string $identifier): Command
    {
        $this->populateCommandsFromPackages();

        if (!isset($this->commands[$identifier])) {
            throw new UnknownCommandException(
                sprintf('Command "%s" has not been registered.', $identifier),
                1510906768
            );
        }

        return $this->commands[$identifier] ?? null;
    }

Reviews 2