Skip to content

Commit

Permalink
Fix 6.1 deprecation: public and protected properties are final
Browse files Browse the repository at this point in the history
> The "Symfony\Component\Console\Command\Command::$defaultName" property
 is considered final. You should not override it in "Stenope\Bundle\Command\BuildCommand"
  • Loading branch information
ogizanagi committed May 20, 2022
1 parent 7fb8d59 commit f82b502
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
4 changes: 2 additions & 2 deletions config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
'$stopwatch' => service('stenope.build.stopwatch'),
'$registeredTypes' => 'The known content types, defined by the extension',
])
->tag('console.command', ['command' => DebugCommand::getDefaultName()])
->tag('console.command', ['command' => 'debug:stenope:content'])

// Expression Language
->set(ExpressionLanguage::class)->args([
Expand All @@ -96,7 +96,7 @@
'$builder' => service(Builder::class),
'$stopwatch' => service('stenope.build.stopwatch'),
])
->tag('console.command', ['command' => BuildCommand::getDefaultName()])
->tag('console.command', ['command' => 'stenope:build'])

->set(Builder::class)->args([
'$router' => service('router'),
Expand Down
5 changes: 1 addition & 4 deletions src/Command/BuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace Stenope\Bundle\Command;

use Stenope\Bundle\Builder;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -20,13 +19,10 @@
use Symfony\Component\Console\Terminal;
use Symfony\Component\Stopwatch\Stopwatch;

#[AsCommand('stenope:build')]
class BuildCommand extends Command
{
use StopwatchHelperTrait;

protected static $defaultName = 'stenope:build';

private Builder $builder;
private Stopwatch $stopwatch;

Expand All @@ -44,6 +40,7 @@ public function __construct(Builder $builder, Stopwatch $stopwatch)
protected function configure(): void
{
$this
->setName('stenope:build')
->setDescription('Build static website')
->addArgument(
'buildDir',
Expand Down
5 changes: 1 addition & 4 deletions src/Command/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Stenope\Bundle\ExpressionLanguage\Expression;
use Stenope\Bundle\TableOfContent\Headline;
use Stenope\Bundle\TableOfContent\TableOfContent;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Dumper;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -27,13 +26,10 @@
use Symfony\Component\VarDumper\Cloner\Stub;
use Symfony\Component\VarDumper\Cloner\VarCloner;

#[AsCommand('debug:stenope:content')]
class DebugCommand extends Command
{
use StopwatchHelperTrait;

protected static $defaultName = 'debug:stenope:content';

private ContentManagerInterface $manager;
private Stopwatch $stopwatch;
private array $registeredTypes;
Expand All @@ -53,6 +49,7 @@ public function __construct(ContentManagerInterface $manager, Stopwatch $stopwat
protected function configure(): void
{
$this
->setName('debug:stenope:content')
->setDescription('Debug Stenope managed contents')
->addArgument('class', InputArgument::REQUIRED, 'Content FQCN')
->addArgument('id', InputArgument::OPTIONAL, 'Content identifier')
Expand Down
6 changes: 3 additions & 3 deletions tests/Integration/Command/DebugCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testList(string $class, string $expected, array $filters = [], a
$kernel = static::createKernel();
$application = new Application($kernel);

$command = $application->find(DebugCommand::getDefaultName());
$command = $application->find('debug:stenope:content');
$tester = new CommandTester($command);
$tester->execute([
'class' => $class,
Expand Down Expand Up @@ -153,7 +153,7 @@ public function testShow(): void
$kernel = static::createKernel();
$application = new Application($kernel);

$command = $application->find(DebugCommand::getDefaultName());
$command = $application->find('debug:stenope:content');
$tester = new CommandTester($command);
$tester->execute([
'class' => Author::class,
Expand Down Expand Up @@ -194,7 +194,7 @@ public function testUnavailableExpressionLanguageHint(): void
$kernel = static::createKernel();
$application = new Application($kernel);

$command = $application->find(DebugCommand::getDefaultName());
$command = $application->find('debug:stenope:content');
$tester = new CommandTester($command);

try {
Expand Down

0 comments on commit f82b502

Please sign in to comment.