Skip to content

Commit 4174898

Browse files
authored
SentryTestCommand > Define command name in config (#635)
This fixes a deprecation on Symfony 6.1: ``` Since symfony/console 6.1: Relying on the static property "$defaultName" for setting a command name is deprecated. Add the "Symfony\Component\Console\Attribute\AsCommand" attribute to the "Sentry\SentryBundle\Command\SentryTestCommand" class instead. ```
1 parent d1d2895 commit 4174898

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44

5+
- Fix compatibility issue with Symfony >= 6.1.0 (#635)
56

67
## 4.2.10 (2022-05-17)
78

src/Command/SentryTestCommand.php

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
class SentryTestCommand extends Command
1313
{
14-
protected static $defaultName = 'sentry:test';
15-
1614
protected function execute(InputInterface $input, OutputInterface $output): int
1715
{
1816
$currentHub = SentrySdk::getCurrentHub();

src/Resources/config/services.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
</service>
8989

9090
<service id="Sentry\SentryBundle\Command\SentryTestCommand" class="Sentry\SentryBundle\Command\SentryTestCommand">
91-
<tag name="console.command" />
91+
<tag name="console.command" command="sentry:test" />
9292
</service>
9393

9494
<service id="Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverConnectionFactoryInterface" alias="Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverConnectionFactory" />

tests/Command/SentryTestCommandTest.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,11 @@ public function testExecuteFailsDueToMissingClient(): void
115115

116116
private function executeCommand(): CommandTester
117117
{
118+
$command = new SentryTestCommand();
119+
$command->setName('sentry:test');
120+
118121
$application = new Application();
119-
$application->add(new SentryTestCommand());
122+
$application->add($command);
120123

121124
$command = $application->find('sentry:test');
122125
$commandTester = new CommandTester($command);

0 commit comments

Comments
 (0)