Skip to content

Commit d194fdc

Browse files
committed
Migrate commands to the new format
Ref: #190
1 parent 8c29f72 commit d194fdc

7 files changed

Lines changed: 36 additions & 77 deletions
Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?php
22

33
/**
4-
* Clean Old Notifications Shell.
5-
*
64
* phpMyAdmin Error reporting server
75
* Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/)
86
*
@@ -16,7 +14,7 @@
1614
* @see https://www.phpmyadmin.net/
1715
*/
1816

19-
namespace App\Shell;
17+
namespace App\Command;
2018

2119
use App\Model\Table\NotificationsTable;
2220
use Cake\Command\Command;
@@ -28,23 +26,18 @@
2826
use function date;
2927
use function time;
3028

31-
/**
32-
* Clean old Notifications shell.
33-
*/
34-
class CleanOldNotifsShell extends Command
29+
class CleanOldNotifsCommand extends Command
3530
{
36-
protected const NAME = 'clean_old_notifs';
37-
38-
/**
39-
* The name of this command.
40-
*/
41-
protected string $name = self::NAME;
42-
4331
protected NotificationsTable $Notifications;
4432

4533
public static function defaultName(): string
4634
{
47-
return self::NAME;
35+
return 'clean_old_notifs';
36+
}
37+
38+
public static function getDescription(): string
39+
{
40+
return 'Clean old Notifications';
4841
}
4942

5043
protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser
Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* @since 3.0.0
1616
*/
1717

18-
namespace App\Shell;
18+
namespace App\Command;
1919

2020
use Cake\Command\Command;
2121
use Cake\Console\Arguments;
@@ -28,21 +28,16 @@
2828
use function restore_error_handler;
2929
use function restore_exception_handler;
3030

31-
/**
32-
* Simple console wrapper around Psy\Shell.
33-
*/
34-
class ConsoleShell extends Command
31+
class ConsoleCommand extends Command
3532
{
36-
protected const NAME = 'console';
37-
38-
/**
39-
* The name of this command.
40-
*/
41-
protected string $name = self::NAME;
42-
4333
public static function defaultName(): string
4434
{
45-
return self::NAME;
35+
return 'console';
36+
}
37+
38+
public static function getDescription(): string
39+
{
40+
return 'Simple console wrapper around Psy\Shell';
4641
}
4742

4843
protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser
@@ -70,7 +65,7 @@ public function execute(Arguments $args, ConsoleIo $io)
7065
$io->err('<info>$ php composer.phar require --dev psy/psysh</info>');
7166
$io->err('');
7267

73-
return 1;
68+
return self::CODE_SUCCESS;
7469
}
7570

7671
$io->out('You can exit with <info>`CTRL-C`</info> or <info>`exit`</info>');
Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?php
22

33
/**
4-
* Stats Shell.
5-
*
64
* phpMyAdmin Error reporting server
75
* Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/)
86
*
@@ -16,7 +14,7 @@
1614
* @see https://www.phpmyadmin.net/
1715
*/
1816

19-
namespace App\Shell;
17+
namespace App\Command;
2018

2119
use App\Model\Table\IncidentsTable;
2220
use App\Model\Table\ReportsTable;
@@ -29,23 +27,21 @@
2927
use function json_encode;
3028

3129
/**
32-
* Stats shell.
30+
* Stats command.
3331
*/
34-
class StatsShell extends Command
32+
class StatsCommand extends Command
3533
{
3634
protected IncidentsTable $Incidents;
3735
protected ReportsTable $Reports;
3836

39-
protected const NAME = 'stats';
40-
41-
/**
42-
* The name of this command.
43-
*/
44-
protected string $name = self::NAME;
45-
4637
public static function defaultName(): string
4738
{
48-
return self::NAME;
39+
return 'stats';
40+
}
41+
42+
public static function getDescription(): string
43+
{
44+
return 'Build statistics';
4945
}
5046

5147
protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser

src/Shell/SyncGithubIssueStatesShell.php renamed to src/Command/SyncGithubIssueStatesCommand.php

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?php
22

33
/**
4-
* Sync Github issue states Shell.
5-
*
64
* phpMyAdmin Error reporting server
75
* Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/)
86
*
@@ -16,7 +14,7 @@
1614
* @see https://www.phpmyadmin.net/
1715
*/
1816

19-
namespace App\Shell;
17+
namespace App\Command;
2018

2119
use App\Application;
2220
use Cake\Command\Command;
@@ -32,21 +30,16 @@
3230

3331
use const PHP_SAPI;
3432

35-
/**
36-
* Sync Github issue states Shell.
37-
*/
38-
class SyncGithubIssueStatesShell extends Command
33+
class SyncGithubIssueStatesCommand extends Command
3934
{
40-
protected const NAME = 'sync_github_issue_states';
41-
42-
/**
43-
* The name of this command.
44-
*/
45-
protected string $name = self::NAME;
46-
4735
public static function defaultName(): string
4836
{
49-
return self::NAME;
37+
return 'sync_github_issue_states';
38+
}
39+
40+
public static function getDescription(): string
41+
{
42+
return 'Sync Github issue states';
5043
}
5144

5245
protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser
@@ -96,7 +89,7 @@ public function execute(Arguments $args, ConsoleIo $io)
9689
['scope' => 'cron_jobs']
9790
);
9891

99-
return 0;
92+
return self::CODE_ERROR;
10093
}
10194

10295
Log::error(
@@ -108,6 +101,6 @@ public function execute(Arguments $args, ConsoleIo $io)
108101
['scope' => 'cron_jobs']
109102
);
110103

111-
return 1;
104+
return self::CODE_SUCCESS;
112105
}
113106
}

tests/TestCase/Shell/CleanOldNotifsShellTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ public function getFixtures(): array
3939
];
4040
}
4141

42-
public function setUp(): void
43-
{
44-
parent::setUp();
45-
$this->useCommandRunner();
46-
}
47-
4842
/**
4943
* Test execute method
5044
*/

tests/TestCase/Shell/StatsShellTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ class StatsShellTest extends TestCase
3030
{
3131
use ConsoleIntegrationTestTrait;
3232

33-
public function setUp(): void
34-
{
35-
parent::setUp();
36-
$this->useCommandRunner();
37-
}
38-
3933
/**
4034
* Test execute method
4135
*/

tests/TestCase/Shell/SyncGithubIssueStatesShellTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ public function getFixtures(): array
3333
];
3434
}
3535

36-
public function setUp(): void
37-
{
38-
parent::setUp();
39-
$this->useCommandRunner();
40-
}
41-
4236
/**
4337
* Test execute method
4438
*/

0 commit comments

Comments
 (0)