Repository: symfony/symfony
File: src/Symfony/Component/Console/Command/Command.php (PHP)

Code before:

        if (self::class !== (new \ReflectionMethod($this, 'getDefaultName'))->getDeclaringClass()->getName()) {
            trigger_deprecation('symfony/console', '7.3', 'The static method "%s::getDefaultName()" is deprecated, define the command name in the "%s" attribute instead.', static::class, AsCommand::class);

            $defaultName = static::getDefaultName();
        } else {
            $defaultName = $attribute?->name;
        }

        if (null === $name && null !== $name = $defaultName) {
            $aliases = explode('|', $name);

            if ('' === $name = array_shift($aliases)) {
                $this->setHidden(true);
                $name = array_shift($aliases);
            }

            $this->setAliases($aliases);
        }

        if (null !== $name) {
            $this->setName($name);
        }

        if (self::class !== (new \ReflectionMethod($this, 'getDefaultDescription'))->getDeclaringClass()->getName()) {
            trigger_deprecation('symfony/console', '7.3', 'The static method "%s::getDefaultDescription()" is deprecated, define the command description in the "%s" attribute instead.', static::class, AsCommand::class);

            $defaultDescription = static::getDefaultDescription();
        } else {
            $defaultDescription = $attribute?->description;
        }

        if ('' === $this->description) {
            $this->setDescription($defaultDescription ?? '');
        }

        if ('' === $this->help) {
            $this->setHelp($attribute?->help ?? '');
        }

        if (\is_callable($this)) {
            $this->code = new InvokableCommand($this, $this(...));
        }

        $this->configure();
    }

    /**
     * Ignores validation errors.
     *
     * This is mainly useful for the help command.

Review comment (suggestion):
```suggestion
            trigger_deprecation('symfony/console', '7.3', 'Method "%s()" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.', static::class);
```

Code after:
        $attribute = ((new \ReflectionClass(static::class))->getAttributes(AsCommand::class)[0] ?? null)?->newInstance();

        if (null === $name) {
            if (self::class !== (new \ReflectionMethod($this, 'getDefaultName'))->class) {
                trigger_deprecation('symfony/console', '7.3', 'Overriding "Command::getDefaultName()" in "%s" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.', static::class);

                $defaultName = static::getDefaultName();
            } else {
                $defaultName = $attribute?->name;
            }
        }

        if (null === $name && null !== $name = $defaultName) {
            $aliases = explode('|', $name);

            if ('' === $name = array_shift($aliases)) {
                $this->setHidden(true);
                $name = array_shift($aliases);
            }

            $this->setAliases($aliases);
        }

        if (null !== $name) {
            $this->setName($name);
        }

        if ('' === $this->description) {
            if (self::class !== (new \ReflectionMethod($this, 'getDefaultDescription'))->class) {
                trigger_deprecation('symfony/console', '7.3', 'Overriding "Command::getDefaultDescription()" in "%s" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.', static::class);

                $defaultDescription = static::getDefaultDescription();
            } else {
                $defaultDescription = $attribute?->description;
            }

            $this->setDescription($defaultDescription ?? '');
        }

        if ('' === $this->help) {
            $this->setHelp($attribute?->help ?? '');
        }

        if (\is_callable($this)) {
            $this->code = new InvokableCommand($this, $this(...));
        }

        $this->configure();
    }

    /**