Skip to content

Commit 9627c42

Browse files
committed
all commands return void
1 parent 0dfd1bc commit 9627c42

File tree

7 files changed

+23
-35
lines changed

7 files changed

+23
-35
lines changed

src/Command/DeleteAllCommand.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,25 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption
4040
* Deletes all backup files
4141
* @param \Cake\Console\Arguments $args The command arguments
4242
* @param \Cake\Console\ConsoleIo $io The console io
43-
* @return int|null The exit code or null for success
43+
* @return void
4444
* @see https://github.com/mirko-pagliai/cakephp-database-backup/wiki/How-to-use-the-BackupShell#delete_all
4545
* @uses \DatabaseBackup\Utility\BackupManager::deleteAll()
4646
*/
47-
public function execute(Arguments $args, ConsoleIo $io): ?int
47+
public function execute(Arguments $args, ConsoleIo $io): void
4848
{
4949
parent::execute($args, $io);
5050

51-
$files = (new BackupManager())->deleteAll();
52-
51+
$files = BackupManager::deleteAll();
5352
if (!$files) {
5453
$io->verbose(__d('database_backup', 'No backup has been deleted'));
5554

56-
return null;
55+
return;
5756
}
5857

5958
foreach ($files as $file) {
6059
$io->verbose(__d('database_backup', 'Backup `{0}` has been deleted', $this->Filesystem->rtr($file)));
6160
}
6261

6362
$io->success(__d('database_backup', 'Deleted backup files: {0}', count($files)));
64-
65-
return null;
6663
}
6764
}

src/Command/ExportCommand.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,16 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption
6868
* This command uses `RotateCommand` and `SendCommand`.
6969
* @param \Cake\Console\Arguments $args The command arguments
7070
* @param \Cake\Console\ConsoleIo $io The console io
71-
* @return int|null The exit code or null for success
71+
* @return void
7272
* @see https://github.com/mirko-pagliai/cakephp-database-backup/wiki/How-to-use-the-BackupShell#export
73+
* @throws \Cake\Console\Exception\StopException
7374
* @uses \DatabaseBackup\Command\RotateCommand::execute()
7475
* @uses \DatabaseBackup\Command\SendCommand::execute()
7576
* @uses \DatabaseBackup\Utility\BackupExport::compression()
7677
* @uses \DatabaseBackup\Utility\BackupExport::export()
7778
* @uses \DatabaseBackup\Utility\BackupExport::filename()
7879
*/
79-
public function execute(Arguments $args, ConsoleIo $io): ?int
80+
public function execute(Arguments $args, ConsoleIo $io): void
8081
{
8182
parent::execute($args, $io);
8283

@@ -120,7 +121,5 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
120121
$io->error($e->getMessage());
121122
$this->abort();
122123
}
123-
124-
return null;
125124
}
126125
}

src/Command/ImportCommand.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption
4545
* Imports a database backup
4646
* @param \Cake\Console\Arguments $args The command arguments
4747
* @param \Cake\Console\ConsoleIo $io The console io
48-
* @return int|null The exit code or null for success
48+
* @return void
4949
* @see https://github.com/mirko-pagliai/cakephp-database-backup/wiki/How-to-use-the-BackupShell#import
50+
* @throws \Cake\Console\Exception\StopException
5051
* @uses \DatabaseBackup\Utility\BackupImport::filename()
5152
* @uses \DatabaseBackup\Utility\BackupImport::import()
5253
*/
53-
public function execute(Arguments $args, ConsoleIo $io): ?int
54+
public function execute(Arguments $args, ConsoleIo $io): void
5455
{
5556
parent::execute($args, $io);
5657

@@ -61,7 +62,5 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
6162
$io->error($e->getMessage());
6263
$this->abort();
6364
}
64-
65-
return null;
6665
}
6766
}

src/Command/IndexCommand.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,19 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption
4242
* Lists database backups
4343
* @param \Cake\Console\Arguments $args The command arguments
4444
* @param \Cake\Console\ConsoleIo $io The console io
45-
* @return int|null The exit code or null for success
45+
* @return void
4646
* @see https://github.com/mirko-pagliai/cakephp-database-backup/wiki/How-to-use-the-BackupShell#index
4747
* @uses \DatabaseBackup\Utility\BackupManager::index()
4848
*/
49-
public function execute(Arguments $args, ConsoleIo $io): ?int
49+
public function execute(Arguments $args, ConsoleIo $io): void
5050
{
5151
parent::execute($args, $io);
5252

5353
//Gets all backups
54-
$backups = (new BackupManager())->index();
54+
$backups = BackupManager::index();
5555
$io->out(__d('database_backup', 'Backup files found: {0}', $backups->count()));
56-
5756
if ($backups->isEmpty()) {
58-
return null;
57+
return;
5958
}
6059

6160
$headers = [
@@ -72,7 +71,5 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
7271
->toArray();
7372
});
7473
$io->helper('table')->output(array_merge([$headers], $cells->toList()));
75-
76-
return null;
7774
}
7875
}

src/Command/RotateCommand.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption
4848
* delete all backups that are older. By default, no backup will be deleted
4949
* @param \Cake\Console\Arguments $args The command arguments
5050
* @param \Cake\Console\ConsoleIo $io The console io
51-
* @return int|null The exit code or null for success
51+
* @return void
5252
* @see https://github.com/mirko-pagliai/cakephp-database-backup/wiki/How-to-use-the-BackupShell#rotate
53+
* @throws \Cake\Console\Exception\StopException
5354
* @uses \DatabaseBackup\Utility\BackupManager::rotate()
5455
*/
55-
public function execute(Arguments $args, ConsoleIo $io): ?int
56+
public function execute(Arguments $args, ConsoleIo $io): void
5657
{
5758
parent::execute($args, $io);
5859

@@ -63,7 +64,7 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
6364
if (!$files) {
6465
$io->verbose(__d('database_backup', 'No backup has been deleted'));
6566

66-
return null;
67+
return;
6768
}
6869

6970
foreach ($files as $file) {
@@ -75,7 +76,5 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
7576
$io->error($e->getMessage());
7677
$this->abort();
7778
}
78-
79-
return null;
8079
}
8180
}

src/Command/SendCommand.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption
5151
* Sends a backup file via email
5252
* @param \Cake\Console\Arguments $args The command arguments
5353
* @param \Cake\Console\ConsoleIo $io The console io
54-
* @return int|null The exit code or null for success
54+
* @return void
5555
* @see https://github.com/mirko-pagliai/cakephp-database-backup/wiki/How-to-use-the-BackupShell#send
56+
* @throws \Cake\Console\Exception\StopException
5657
* @uses \DatabaseBackup\Utility\BackupManager::send()
5758
*/
58-
public function execute(Arguments $args, ConsoleIo $io): ?int
59+
public function execute(Arguments $args, ConsoleIo $io): void
5960
{
6061
parent::execute($args, $io);
6162

@@ -66,7 +67,5 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
6667
$io->error($e->getMessage());
6768
$this->abort();
6869
}
69-
70-
return null;
7170
}
7271
}

src/Console/Command.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,14 @@ public function __construct()
4545
* Implement this method with your command's logic
4646
* @param \Cake\Console\Arguments $args The command arguments
4747
* @param \Cake\Console\ConsoleIo $io The console io
48-
* @return int|null The exit code or null for success
48+
* @return void
4949
*/
50-
public function execute(Arguments $args, ConsoleIo $io): ?int
50+
public function execute(Arguments $args, ConsoleIo $io): void
5151
{
5252
$config = $this->getConnection()->config();
5353

5454
$io->out(__d('database_backup', 'Connection: {0}', $config['name']));
5555
$io->out(__d('database_backup', 'Driver: {0}', get_class_short_name($this->getConnection()->getDriver())));
5656
$io->hr();
57-
58-
return null;
5957
}
6058
}

0 commit comments

Comments
 (0)