rector-symfony
rector-symfony copied to clipboard
[CommandPropertyToAttributeRector] is not setting all attributes
Bug Report
CommandPropertyToAttributeRector is not setting aliases and hidden in AsCommand attribute
| Subject | Details |
|---|---|
| Rector version | last dev-main |
| Installed as | composer dependency |
Minimal PHP Code Causing Issue
See https://getrector.org/demo/69d11564-5a50-458b-b185-de0c343b416b
<?php
class SunshineCommand extends \Symfony\Component\Console\Command\Command
{
/** @var string|null */
public static $defaultName = 'sunshine';
/** @var string|null */
public static $defaultDescription = 'Let the sun shine!';
/**
* {@inheritdoc}
*/
protected function configure(): void
{
$this
->setAliases(['sun', 'shine'])
;
}
}
Responsible rules
CommandPropertyToAttributeRector
Expected Behavior
<?php
#[\Symfony\Component\Console\Attribute\AsCommand('sunshine', 'Let the sun shine!', ['sun', 'shine'], false)
class SunshineCommand extends \Symfony\Component\Console\Command\Command
{
/**
* {@inheritdoc}
*/
protected function configure(): void
{
}
}
Maybe a new rule is more appropriate as the aliases and hidden are not set with properties but set with configure but they are properties in \Symfony\Component\Console\Command\Command
@JohJohan have a look
Also, the MakeCommandLazyRector is not migrating the description to $defaultDescription (probably because it is a lot newer than the $defaultName) and so it misses it in most cases too.
@stof this is done with https://github.com/rectorphp/rector-symfony/pull/257 as discussed here https://github.com/rectorphp/rector-symfony/issues/229
the rector present in that PR is not documented, which is why I missed it
@stof good point, i created a pull request to add it to the docs: https://github.com/rectorphp/rector-symfony/pull/260
Wip: https://github.com/rectorphp/rector-symfony/pull/259
Fixed with https://github.com/rectorphp/rector-symfony/pull/259