Skip to content

Commit a54651b

Browse files
committed
Fix deprecation for Command classes
Uses the AsCommand attribute instead of $defaultName. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent 0369a55 commit a54651b

7 files changed

Lines changed: 15 additions & 31 deletions

File tree

.github/workflows/test-selenium.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ jobs:
139139
TESTSUITE_DATABASE_PREFIX: "selenium"
140140
TESTSUITE_SELENIUM_HOST: "127.0.0.1"
141141
TESTSUITE_SELENIUM_PORT: "4444"
142-
run: ./vendor/bin/phpunit --testsuite selenium --no-logging --no-coverage --stop-on-skipped test/selenium/${{ matrix.test-name }}Test.php
142+
run: ./vendor/bin/phpunit --testsuite selenium --no-logging --no-coverage --stop-on-skipped --testdox test/selenium/${{ matrix.test-name }}Test.php
143143

144144
- name: Output logs and stop server
145145
env:

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
composer-options: ${{ matrix.composer-options }}
104104

105105
- name: Run PHP tests
106-
run: composer run phpunit -- --testsuite unit
106+
run: composer run phpunit -- --testsuite unit --display-deprecations --display-notices --display-warnings --display-errors
107107

108108
- name: Send coverage
109109
uses: codecov/codecov-action@v3

libraries/classes/Command/CacheWarmupCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use RecursiveDirectoryIterator;
1313
use RecursiveIteratorIterator;
1414
use SplFileInfo;
15+
use Symfony\Component\Console\Attribute\AsCommand;
1516
use Symfony\Component\Console\Command\Command;
1617
use Symfony\Component\Console\Input\InputArgument;
1718
use Symfony\Component\Console\Input\InputInterface;
@@ -28,14 +29,11 @@
2829
use const CACHE_DIR;
2930
use const CONFIG_FILE;
3031

32+
#[AsCommand(name: 'cache:warmup', description: 'Warms up the Twig templates cache.')]
3133
final class CacheWarmupCommand extends Command
3234
{
33-
/** @var string|null */
34-
protected static $defaultName = 'cache:warmup';
35-
3635
protected function configure(): void
3736
{
38-
$this->setDescription('Warms up the Twig templates cache');
3937
$this->addOption('twig', null, null, 'Warm up twig templates cache.');
4038
$this->addOption('routing', null, null, 'Warm up routing cache.');
4139
$this->addOption('twig-po', null, null, 'Warm up twig templates and write file mappings.');

libraries/classes/Command/FixPoTwigCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace PhpMyAdmin\Command;
66

7+
use Symfony\Component\Console\Attribute\AsCommand;
78
use Symfony\Component\Console\Command\Command;
89
use Symfony\Component\Console\Input\InputInterface;
910
use Symfony\Component\Console\Output\OutputInterface;
@@ -17,17 +18,14 @@
1718

1819
use const ROOT_PATH;
1920

21+
#[AsCommand(name: 'fix-po-twig', description: 'Fixes POT file for Twig templates.')]
2022
final class FixPoTwigCommand extends Command
2123
{
22-
/** @var string|null */
23-
protected static $defaultName = 'fix-po-twig';
24-
2524
private const POT_FILE = ROOT_PATH . 'po/phpmyadmin.pot';
2625
private const REPLACE_FILE = ROOT_PATH . 'twig-templates/replace.json';
2726

2827
protected function configure(): void
2928
{
30-
$this->setDescription('Fixes POT file for Twig templates');
3129
$this->setHelp(
3230
'The <info>%command.name%</info> command fixes the Twig file name and line number in the'
3331
. ' POT file to match the Twig template and not the compiled Twig file.',

libraries/classes/Command/SetVersionCommand.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace PhpMyAdmin\Command;
66

77
use RangeException;
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;
@@ -14,13 +15,10 @@
1415
use function preg_match;
1516
use function sprintf;
1617

18+
#[AsCommand(name: 'set-version', description: 'Sets the version number.')]
1719
final class SetVersionCommand extends Command
1820
{
19-
/** @var string|null */
20-
protected static $defaultName = 'set-version';
21-
22-
/** @var string */
23-
private static $generatedClassTemplate = <<<'PHP'
21+
private static string $generatedClassTemplate = <<<'PHP'
2422
<?php
2523
2624
declare(strict_types=1);
@@ -51,7 +49,6 @@ final class Version
5149

5250
protected function configure(): void
5351
{
54-
$this->setDescription('Sets the version number');
5552
$this->setHelp('This command generates the PhpMyAdmin\Version class based on the version number provided.');
5653
$this->addArgument('version', InputArgument::REQUIRED, 'The version number');
5754
}

libraries/classes/Command/TwigLintCommand.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace PhpMyAdmin\Command;
66

77
use PhpMyAdmin\Template;
8+
use Symfony\Component\Console\Attribute\AsCommand;
89
use Symfony\Component\Console\Command\Command;
910
use Symfony\Component\Console\Input\InputInterface;
1011
use Symfony\Component\Console\Input\InputOption;
@@ -58,19 +59,12 @@
5859
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
5960
* THE SOFTWARE.
6061
*/
62+
#[AsCommand(name: 'lint:twig', description: 'Lint a Twig template and outputs encountered errors.')]
6163
class TwigLintCommand extends Command
6264
{
63-
/** @var string|null */
64-
protected static $defaultName = 'lint:twig';
65-
66-
/** @var string|null */
67-
protected static $defaultDescription = 'Lint a Twig template and outputs encountered errors';
68-
6965
protected function configure(): void
7066
{
71-
$this
72-
->setDescription((string) self::$defaultDescription)
73-
->addOption('show-deprecations', null, InputOption::VALUE_NONE, 'Show deprecations as errors');
67+
$this->addOption('show-deprecations', null, InputOption::VALUE_NONE, 'Show deprecations as errors');
7468
}
7569

7670
protected function findFiles(string $baseFolder): array

libraries/classes/Command/WriteGitRevisionCommand.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace PhpMyAdmin\Command;
66

7+
use Symfony\Component\Console\Attribute\AsCommand;
78
use Symfony\Component\Console\Command\Command;
89
use Symfony\Component\Console\Input\InputInterface;
910
use Symfony\Component\Console\Input\InputOption;
@@ -16,13 +17,10 @@
1617
use function str_replace;
1718
use function trim;
1819

20+
#[AsCommand(name: 'write-revision-info', description: 'Write Git revision.')]
1921
class WriteGitRevisionCommand extends Command
2022
{
21-
/** @var string|null */
22-
protected static $defaultName = 'write-revision-info';
23-
24-
/** @var string */
25-
private static $generatedClassTemplate = <<<'PHP'
23+
private static string $generatedClassTemplate = <<<'PHP'
2624
<?php
2725
2826
declare(strict_types=1);
@@ -43,7 +41,6 @@ class WriteGitRevisionCommand extends Command
4341

4442
protected function configure(): void
4543
{
46-
$this->setDescription('Write Git revision');
4744
$this->addOption(
4845
'remote-commit-url',
4946
null,

0 commit comments

Comments
 (0)