shivas / versioning-bundle

Simple way to version (semantic versioning 2.0.0) your Symfony2/3/4/5/6 application
MIT License
111 stars 30 forks source link

Symfony 6.1 command deprecations #85

Closed 0x6d6c closed 2 years ago

0x6d6c commented 2 years ago

The following commands:

rely on $defaultName property which is deprecated in Symfony 6.1:

Since symfony/console 6.1: Relying on the static property "$defaultName" for setting a command name is deprecated.

It can be replaced by the Symfony\Component\Console\Attribute\AsCommand PHP 8 attribute, also the command descriptions can be placed in the attribute, e.g.:

<?php

use Symfony\Component\Console\Attribute\AsCommand;

#[AsCommand(
    name: 'app:version:list-providers',
    description: 'List all registered version providers',
)]
final class ListProvidersCommand extends Command
{
    // To remove:
    // protected static $defaultName = 'app:version:list-providers';

    // Also to remove:
    // $this->setDescription('List all registered version providers');
    // from configure() method
    ...
}

I'd happy to prepare a PR but have no idea how to make attributes are not allowed in PHP 7 and I have no idea how to provide a solution compatible with PHP 7.

dontub commented 2 years ago

Have you already tried adding the attribute and keeping the property for backward compatibility?

0x6d6c commented 2 years ago

No, I haven't, unfortunately and I have no idea how to make it backward compatible. All commands in my projects use attribites but they run on PHP 8.1 so I haven't had to make it BC.