Skip to content

Commit ff14fe0

Browse files
committed
bug #107 Fix deprecation warnings in commands (jury89, chalasr)
This PR was merged into the 0.4-dev branch. Discussion ---------- Fix deprecation warnings in commands This PR a follow up of #105 and it's addressing the following deprecation warnings that I'm getting when using Symfony 6.1 and the latest version of the oauth2 server bundle. ``` 2022-10-13T07:48:25+00:00 [info] User Deprecated: 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 "League\Bundle\OAuth2ServerBundle\Command\CreateClientCommand" class instead. 2022-10-13T07:48:25+00:00 [info] User Deprecated: 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 "League\Bundle\OAuth2ServerBundle\Command\UpdateClientCommand" class instead. 2022-10-13T07:48:25+00:00 [info] User Deprecated: 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 "League\Bundle\OAuth2ServerBundle\Command\DeleteClientCommand" class instead. 2022-10-13T07:48:25+00:00 [info] User Deprecated: 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 "League\Bundle\OAuth2ServerBundle\Command\ListClientsCommand" class instead. 2022-10-13T07:48:25+00:00 [info] User Deprecated: 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 "League\Bundle\OAuth2ServerBundle\Command\ClearExpiredTokensCommand" class instead. ``` Commits ------- b9998c0 Add #[AsCommand] attribute for discovery and future-proofness d2ca305 replace static property $defaultName in commands with command attributes of tag "console.command"
2 parents 6dcf986 + b9998c0 commit ff14fe0

6 files changed

+16
-16
lines changed

src/Command/ClearExpiredTokensCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
use League\Bundle\OAuth2ServerBundle\Manager\AccessTokenManagerInterface;
88
use League\Bundle\OAuth2ServerBundle\Manager\AuthorizationCodeManagerInterface;
99
use League\Bundle\OAuth2ServerBundle\Manager\RefreshTokenManagerInterface;
10+
use Symfony\Component\Console\Attribute\AsCommand;
1011
use Symfony\Component\Console\Command\Command;
1112
use Symfony\Component\Console\Input\InputInterface;
1213
use Symfony\Component\Console\Input\InputOption;
1314
use Symfony\Component\Console\Output\OutputInterface;
1415
use Symfony\Component\Console\Style\SymfonyStyle;
1516

17+
#[AsCommand(name: 'league:oauth2-server:clear-expired-tokens', description: 'Clears all expired access and/or refresh tokens and/or auth codes')]
1618
final class ClearExpiredTokensCommand extends Command
1719
{
18-
protected static $defaultName = 'league:oauth2-server:clear-expired-tokens';
19-
2020
/**
2121
* @var AccessTokenManagerInterface
2222
*/

src/Command/CreateClientCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
use League\Bundle\OAuth2ServerBundle\ValueObject\Grant;
1010
use League\Bundle\OAuth2ServerBundle\ValueObject\RedirectUri;
1111
use League\Bundle\OAuth2ServerBundle\ValueObject\Scope;
12+
use Symfony\Component\Console\Attribute\AsCommand;
1213
use Symfony\Component\Console\Command\Command;
1314
use Symfony\Component\Console\Input\InputArgument;
1415
use Symfony\Component\Console\Input\InputInterface;
1516
use Symfony\Component\Console\Input\InputOption;
1617
use Symfony\Component\Console\Output\OutputInterface;
1718
use Symfony\Component\Console\Style\SymfonyStyle;
1819

20+
#[AsCommand(name: 'league:oauth2-server:create-client', description: 'Creates a new OAuth2 client')]
1921
final class CreateClientCommand extends Command
2022
{
21-
protected static $defaultName = 'league:oauth2-server:create-client';
22-
2323
/**
2424
* @var ClientManagerInterface
2525
*/

src/Command/DeleteClientCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
namespace League\Bundle\OAuth2ServerBundle\Command;
66

77
use League\Bundle\OAuth2ServerBundle\Manager\ClientManagerInterface;
8+
use Symfony\Component\Console\Attribute\AsCommand;
89
use Symfony\Component\Console\Command\Command;
910
use Symfony\Component\Console\Input\InputArgument;
1011
use Symfony\Component\Console\Input\InputInterface;
1112
use Symfony\Component\Console\Output\OutputInterface;
1213
use Symfony\Component\Console\Style\SymfonyStyle;
1314

15+
#[AsCommand(name: 'league:oauth2-server:delete-client', description: 'Deletes an OAuth2 client')]
1416
final class DeleteClientCommand extends Command
1517
{
16-
protected static $defaultName = 'league:oauth2-server:delete-client';
17-
1818
/**
1919
* @var ClientManagerInterface
2020
*/

src/Command/ListClientsCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@
1010
use League\Bundle\OAuth2ServerBundle\ValueObject\Grant;
1111
use League\Bundle\OAuth2ServerBundle\ValueObject\RedirectUri;
1212
use League\Bundle\OAuth2ServerBundle\ValueObject\Scope;
13+
use Symfony\Component\Console\Attribute\AsCommand;
1314
use Symfony\Component\Console\Command\Command;
1415
use Symfony\Component\Console\Input\InputInterface;
1516
use Symfony\Component\Console\Input\InputOption;
1617
use Symfony\Component\Console\Output\OutputInterface;
1718
use Symfony\Component\Console\Style\SymfonyStyle;
1819

20+
#[AsCommand(name: 'league:oauth2-server:list-clients', description: 'Lists existing OAuth2 clients')]
1921
final class ListClientsCommand extends Command
2022
{
2123
private const ALLOWED_COLUMNS = ['name', 'identifier', 'secret', 'scope', 'redirect uri', 'grant type'];
2224

23-
protected static $defaultName = 'league:oauth2-server:list-clients';
24-
2525
/**
2626
* @var ClientManagerInterface
2727
*/
@@ -37,7 +37,7 @@ public function __construct(ClientManagerInterface $clientManager)
3737
protected function configure(): void
3838
{
3939
$this
40-
->setDescription('Lists existing oAuth2 clients')
40+
->setDescription('Lists existing OAuth2 clients')
4141
->addOption(
4242
'columns',
4343
null,

src/Command/UpdateClientCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
use League\Bundle\OAuth2ServerBundle\ValueObject\Grant;
99
use League\Bundle\OAuth2ServerBundle\ValueObject\RedirectUri;
1010
use League\Bundle\OAuth2ServerBundle\ValueObject\Scope;
11+
use Symfony\Component\Console\Attribute\AsCommand;
1112
use Symfony\Component\Console\Command\Command;
1213
use Symfony\Component\Console\Input\InputArgument;
1314
use Symfony\Component\Console\Input\InputInterface;
1415
use Symfony\Component\Console\Input\InputOption;
1516
use Symfony\Component\Console\Output\OutputInterface;
1617
use Symfony\Component\Console\Style\SymfonyStyle;
1718

19+
#[AsCommand(name: 'league:oauth2-server:update-client', description: 'Updates an OAuth2 client')]
1820
final class UpdateClientCommand extends Command
1921
{
20-
protected static $defaultName = 'league:oauth2-server:update-client';
21-
2222
/**
2323
* @var ClientManagerInterface
2424
*/

src/Resources/config/services.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,28 +235,28 @@
235235
service(ClientManagerInterface::class),
236236
null,
237237
])
238-
->tag('console.command')
238+
->tag('console.command', ['command' => 'league:oauth2-server:create-client'])
239239
->alias(CreateClientCommand::class, 'league.oauth2_server.command.create_client')
240240

241241
->set('league.oauth2_server.command.update_client', UpdateClientCommand::class)
242242
->args([
243243
service(ClientManagerInterface::class),
244244
])
245-
->tag('console.command')
245+
->tag('console.command', ['command' => 'league:oauth2-server:update-client'])
246246
->alias(UpdateClientCommand::class, 'league.oauth2_server.command.update_client')
247247

248248
->set('league.oauth2_server.command.delete_client', DeleteClientCommand::class)
249249
->args([
250250
service(ClientManagerInterface::class),
251251
])
252-
->tag('console.command')
252+
->tag('console.command', ['command' => 'league:oauth2-server:delete-client'])
253253
->alias(DeleteClientCommand::class, 'league.oauth2_server.command.delete_client')
254254

255255
->set('league.oauth2_server.command.list_clients', ListClientsCommand::class)
256256
->args([
257257
service(ClientManagerInterface::class),
258258
])
259-
->tag('console.command')
259+
->tag('console.command', ['command' => 'league:oauth2-server:list-clients'])
260260
->alias(ListClientsCommand::class, 'league.oauth2_server.command.list_clients')
261261

262262
->set('league.oauth2_server.command.clear_expired_tokens', ClearExpiredTokensCommand::class)
@@ -265,7 +265,7 @@
265265
service(RefreshTokenManagerInterface::class),
266266
service(AuthorizationCodeManagerInterface::class),
267267
])
268-
->tag('console.command')
268+
->tag('console.command', ['command' => 'league:oauth2-server:clear-expired-tokens'])
269269
->alias(ClearExpiredTokensCommand::class, 'league.oauth2_server.command.clear_expired_tokens')
270270

271271
// Utility services

0 commit comments

Comments
 (0)