Skip to content

[Console] BC break in 7.4.0: declaring aliases before calling parent::__construct() does not work anymore #62557

@joelwurtz

Description

@joelwurtz

Symfony version(s) affected

7.4.0

Description

Before 7.4.0 calling the setAliases function before parent::__construct on a custom Command was working, now aliases are not defined when doing this.

I'm not sure such thing is in the BC policy ? Close it if not.

How to reproduce

Having a command like this

class MyCommand extends Command 
{
    public function __construct()
    {
        $this->setAliases(['alias']);
        parent::__construct('my-command');
    }
}

Possible Solution

Alias should be declared after parent :

class MyCommand extends Command 
{
    public function __construct()
    {
        parent::__construct('my-command');
        $this->setAliases(['alias']);
    }
}

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions