Skip to content

Commit 13f23ac

Browse files
Merge pull request #63 from mirko-pagliai/develop
Develop
2 parents 18e657b + a087f6b commit 13f23ac

25 files changed

+74
-151
lines changed

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ language: php
33
php:
44
- 7.2
55
- 7.3
6+
- 7.4
7+
- 8.0
68

79
matrix:
810
fast_finish: true
@@ -12,6 +14,10 @@ matrix:
1214
env: dependencies=lowest
1315
- php: 7.3
1416
env: dependencies=lowest
17+
- php: 7.4
18+
env: dependencies=lowest
19+
- php: 8.0
20+
env: dependencies=lowest
1521
- php: 7.2
1622
env: PHPCS=1
1723
- php: 7.2

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# 2.x branch
22
## 2.8 branch
3+
### 2.8.5
4+
* ready for php `8.0`;
5+
* extensive improvement of function descriptions and tags.
6+
37
### 2.8.4
48
* `BackupManager::delete()` returns the full path;
59
* all methods provided by `BackupManager` can now be called statically, except

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"mirko-pagliai/php-tools": "^1.4.7"
1717
},
1818
"require-dev": {
19-
"cakephp/cakephp-codesniffer": "^4.0",
19+
"cakephp/cakephp-codesniffer": "^4.4",
2020
"mirko-pagliai/me-tools": "^2.19",
2121
"phpunit/phpunit": "^8.0|^9.0"
2222
},
@@ -52,7 +52,7 @@
5252
"@phpstan",
5353
"@psalm"
5454
],
55-
"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^0.12 psalm/phar:^3.18 && mv composer.backup composer.json",
55+
"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^0.12 psalm/phar:\"^3.18|^4\" && mv composer.backup composer.json",
5656
"update-lowest": "@composer update --prefer-lowest"
5757
}
5858
}

phpstan.neon

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,8 @@ parameters:
2121
- "#^Constant REDIRECT_TO_DEV_NULL not found\\.$#"
2222
- '#^Parameter \#1 \$callback of function array_map expects \(callable\(\): mixed\)\|null#'
2323
- "#^Static call to instance method Tools\\\\Exceptionist#"
24-
- "#^Parameter \\#2 \\$eventManager of method Cake\\\\TestSuite\\\\TestCase\\:\\:assertEventFired\\(\\) expects Cake\\\\Event\\\\EventManager\\|null, Cake\\\\Event\\\\EventManagerInterface given\\.$#"
25-
- "#^Parameter \\#1 \\$connection of method Cake\\\\Database\\\\Schema\\\\TableSchema\\:\\:dropSql\\(\\) expects Cake\\\\Database\\\\Connection, Cake\\\\Datasource\\\\ConnectionInterface given\\.$#"
26-
27-
-
28-
message: "#^Call to an undefined method Cake\\\\Datasource\\\\ConnectionInterface#"
29-
path: src/Driver/Sqlite.php
24+
- '#^Parameter \#\d \$\w+ of method Cake\\[\w\:\\]+\(\) expects#'
25+
- '#^Call to an undefined method Cake\\#'
3026

3127
-
3228
message: '#^Call to an undefined method [\w\|\\]+MockObject::\w+\(\)\.$#'

psalm.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<UndefinedInterfaceMethod>
5656
<errorLevel type="suppress">
5757
<file name="src/Driver/Sqlite.php" />
58+
<file name="src/TestSuite/DriverTestCase.php" />
5859
</errorLevel>
5960
</UndefinedInterfaceMethod>
6061
</issueHandlers>

src/BackupTrait.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Cake\Core\Configure;
1919
use Cake\Datasource\ConnectionInterface;
2020
use Cake\Datasource\ConnectionManager;
21+
use DatabaseBackup\Driver\Driver;
2122
use InvalidArgumentException;
2223
use Tools\Exceptionist;
2324
use Tools\Filesystem;
@@ -30,7 +31,7 @@ trait BackupTrait
3031
/**
3132
* Valid extensions. Names as keys and compressions as values
3233
* @since 2.4.0
33-
* @var array
34+
* @var array<string, string|bool>
3435
*/
3536
protected static $validExtensions = ['sql.bz2' => 'bzip2', 'sql.gz' => 'gzip', 'sql' => false];
3637

@@ -47,9 +48,7 @@ public static function getAbsolutePath(string $path): string
4748
/**
4849
* Returns the compression type from a filename
4950
* @param string $filename Filename
50-
* @return string|null Compression type as string or `null`
51-
* @uses getExtension()
52-
* @uses getValidCompressions()
51+
* @return string|null Compression type or `null`
5352
*/
5453
public static function getCompression(string $filename): ?string
5554
{
@@ -77,7 +76,7 @@ public function getConnection(?string $name = null): ConnectionInterface
7776
* @throws \InvalidArgumentException
7877
* @uses getConnection()
7978
*/
80-
public function getDriver(?ConnectionInterface $connection = null): object
79+
public function getDriver(?ConnectionInterface $connection = null): Driver
8180
{
8281
$connection = $connection ?: $this->getConnection();
8382
$className = get_class_short_name($connection->getDriver());
@@ -103,7 +102,7 @@ public static function getExtension(string $filename): ?string
103102

104103
/**
105104
* Returns all valid compressions
106-
* @return array<string, string>
105+
* @return array
107106
* @since 2.4.0
108107
* @uses $validExtensions
109108
*/

src/Command/DeleteAllCommand.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Cake\Console\ConsoleOptionParser;
2121
use DatabaseBackup\Console\Command;
2222
use DatabaseBackup\Utility\BackupManager;
23+
use Tools\Filesystem;
2324

2425
/**
2526
* Deletes all backup files
@@ -40,28 +41,25 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption
4041
* Deletes all backup files
4142
* @param \Cake\Console\Arguments $args The command arguments
4243
* @param \Cake\Console\ConsoleIo $io The console io
43-
* @return int|null The exit code or null for success
44+
* @return void
4445
* @see https://github.com/mirko-pagliai/cakephp-database-backup/wiki/How-to-use-the-BackupShell#delete_all
4546
* @uses \DatabaseBackup\Utility\BackupManager::deleteAll()
4647
*/
47-
public function execute(Arguments $args, ConsoleIo $io): ?int
48+
public function execute(Arguments $args, ConsoleIo $io): void
4849
{
4950
parent::execute($args, $io);
5051

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

56-
return null;
56+
return;
5757
}
5858

5959
foreach ($files as $file) {
60-
$io->verbose(__d('database_backup', 'Backup `{0}` has been deleted', $this->Filesystem->rtr($file)));
60+
$io->verbose(__d('database_backup', 'Backup `{0}` has been deleted', Filesystem::instance()->rtr($file)));
6161
}
6262

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

src/Command/ExportCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use DatabaseBackup\Console\Command;
2424
use DatabaseBackup\Utility\BackupExport;
2525
use Exception;
26+
use Tools\Filesystem;
2627

2728
/**
2829
* Exports a database backup
@@ -68,15 +69,16 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption
6869
* This command uses `RotateCommand` and `SendCommand`.
6970
* @param \Cake\Console\Arguments $args The command arguments
7071
* @param \Cake\Console\ConsoleIo $io The console io
71-
* @return int|null The exit code or null for success
72+
* @return void
7273
* @see https://github.com/mirko-pagliai/cakephp-database-backup/wiki/How-to-use-the-BackupShell#export
74+
* @throws \Cake\Console\Exception\StopException
7375
* @uses \DatabaseBackup\Command\RotateCommand::execute()
7476
* @uses \DatabaseBackup\Command\SendCommand::execute()
7577
* @uses \DatabaseBackup\Utility\BackupExport::compression()
7678
* @uses \DatabaseBackup\Utility\BackupExport::export()
7779
* @uses \DatabaseBackup\Utility\BackupExport::filename()
7880
*/
79-
public function execute(Arguments $args, ConsoleIo $io): ?int
81+
public function execute(Arguments $args, ConsoleIo $io): void
8082
{
8183
parent::execute($args, $io);
8284

@@ -93,7 +95,7 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
9395

9496
//Exports
9597
$file = $instance->export();
96-
$io->success(__d('database_backup', 'Backup `{0}` has been exported', $this->Filesystem->rtr($file)));
98+
$io->success(__d('database_backup', 'Backup `{0}` has been exported', Filesystem::instance()->rtr($file)));
9799
$verbose = $args->getOption('verbose');
98100
$quiet = $args->getOption('quiet');
99101

@@ -120,7 +122,5 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
120122
$io->error($e->getMessage());
121123
$this->abort();
122124
}
123-
124-
return null;
125125
}
126126
}

src/Command/ImportCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use DatabaseBackup\Console\Command;
2222
use DatabaseBackup\Utility\BackupImport;
2323
use Exception;
24+
use Tools\Filesystem;
2425

2526
/**
2627
* Imports a database backup
@@ -45,23 +46,22 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption
4546
* Imports a database backup
4647
* @param \Cake\Console\Arguments $args The command arguments
4748
* @param \Cake\Console\ConsoleIo $io The console io
48-
* @return int|null The exit code or null for success
49+
* @return void
4950
* @see https://github.com/mirko-pagliai/cakephp-database-backup/wiki/How-to-use-the-BackupShell#import
51+
* @throws \Cake\Console\Exception\StopException
5052
* @uses \DatabaseBackup\Utility\BackupImport::filename()
5153
* @uses \DatabaseBackup\Utility\BackupImport::import()
5254
*/
53-
public function execute(Arguments $args, ConsoleIo $io): ?int
55+
public function execute(Arguments $args, ConsoleIo $io): void
5456
{
5557
parent::execute($args, $io);
5658

5759
try {
5860
$file = (new BackupImport())->filename($args->getArgument('filename'))->import();
59-
$io->success(__d('database_backup', 'Backup `{0}` has been imported', $this->Filesystem->rtr($file)));
61+
$io->success(__d('database_backup', 'Backup `{0}` has been imported', Filesystem::instance()->rtr($file)));
6062
} catch (Exception $e) {
6163
$io->error($e->getMessage());
6264
$this->abort();
6365
}
64-
65-
return null;
6666
}
6767
}

src/Command/IndexCommand.php

Lines changed: 5 additions & 8 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 = [
@@ -65,14 +64,12 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
6564
__d('database_backup', 'Size'),
6665
__d('database_backup', 'Datetime'),
6766
];
68-
$cells = $backups->map(function (Entity $backup) {
67+
$cells = $backups->map(function (Entity $backup): array {
6968
return $backup->set('compression', $backup->get('compression') ?: '')
7069
->set('datetime', $backup->get('datetime')->nice())
7170
->set('size', Number::toReadableSize($backup->get('size')))
7271
->toArray();
7372
});
7473
$io->helper('table')->output(array_merge([$headers], $cells->toList()));
75-
76-
return null;
7774
}
7875
}

0 commit comments

Comments
 (0)