Skip to content

Commit

Permalink
mark final class + add infection
Browse files Browse the repository at this point in the history
  • Loading branch information
fezfez committed May 16, 2022
1 parent f6c0efb commit e262d17
Show file tree
Hide file tree
Showing 23 changed files with 61 additions and 24 deletions.
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ test:
$(BASE) ./vendor/bin/phpunit $(COMMAND_ARGS)

infection: dup
$(BASE) phpdbg -qrr -d memory_limit=-1 ./vendor/bin/infection -j=5 $(COMMAND_ARGS)
$(BASE) ./vendor/bin/infection

# Analyse

Expand All @@ -61,4 +61,10 @@ cs:
$(BASE) php -d memory_limit=-1 ./vendor/bin/phpcs $(COMMAND_ARGS)

cbf: dup
$(BASE) php -d memory_limit=-1 ./vendor/bin/phpcbf $(COMMAND_ARGS)
$(BASE) php -d memory_limit=-1 ./vendor/bin/phpcbf $(COMMAND_ARGS)

is-valid:
$(BASE) ./vendor/bin/phpunit $(COMMAND_ARGS)
$(BASE) ./vendor/bin/infection
$(BASE) ./vendor/bin/psalm --show-info=true $(COMMAND_ARGS)
$(BASE) php -d memory_limit=-1 ./vendor/bin/phpcs $(COMMAND_ARGS)
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@
"require-dev": {
"doctrine/coding-standard": "^9.0.0",
"phpunit/phpunit": "^9.5.20",
"vimeo/psalm": "^4.23.0"
"vimeo/psalm": "^4.23.0",
"infection/infection": "^0.26.10"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
"dealerdirect/phpcodesniffer-composer-installer": true,
"infection/extension-installer": true
}
},
"autoload": {
Expand Down
11 changes: 11 additions & 0 deletions infection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "vendor/infection/infection/resources/schema.json",
"source": {
"directories": [
"src"
]
},
"mutators": {
"@default": true
}
}
2 changes: 1 addition & 1 deletion src/BackupManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Once you've done that, your application can interact with the backup manager in one place only
* and the rest of the system will interact with the new Manager-like construct that you created.
*/
class BackupManager
class BackupManager implements BackupManagerContract
{
private BackupProcedure $backupProcedure;
private RestoreProcedure $restoreProcedure;
Expand Down
18 changes: 18 additions & 0 deletions src/BackupManagerContract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace Fezfez\BackupManager;

use Fezfez\BackupManager\Compressors\Compressor;
use Fezfez\BackupManager\Databases\Database;
use Fezfez\BackupManager\Filesystems\BackupManagerFilesystemAdapter;
use Fezfez\BackupManager\Filesystems\Destination;

interface BackupManagerContract
{
/** @param Destination[] $destinations */
public function backup(BackupManagerFilesystemAdapter $localFileSystem, Database $database, array $destinations, string $localTmpPath, Compressor ...$compression): void;

public function restore(BackupManagerFilesystemAdapter $localFileSystem, BackupManagerFilesystemAdapter $to, string $sourcePath, Database $databaseName, Compressor ...$compression): void;
}
2 changes: 1 addition & 1 deletion src/Compressors/GzipCompressor.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use function escapeshellarg;
use function preg_replace;

class GzipCompressor implements Compressor
final class GzipCompressor implements Compressor
{
private ShellProcessor $shellProcessor;

Expand Down
2 changes: 1 addition & 1 deletion src/Databases/MysqlDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use function sprintf;
use function trim;

class MysqlDatabase implements Database
final class MysqlDatabase implements Database
{
private string $host;
private string $port;
Expand Down
2 changes: 1 addition & 1 deletion src/Databases/PostgresqlDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use function escapeshellarg;
use function sprintf;

class PostgresqlDatabase implements Database
final class PostgresqlDatabase implements Database
{
private string $host;
private string $port;
Expand Down
2 changes: 1 addition & 1 deletion src/Filesystems/CantDeleteFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

use RuntimeException;

class CantDeleteFile extends RuntimeException
final class CantDeleteFile extends RuntimeException
{
}
2 changes: 1 addition & 1 deletion src/Filesystems/CantReadFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

use RuntimeException;

class CantReadFile extends RuntimeException
final class CantReadFile extends RuntimeException
{
}
2 changes: 1 addition & 1 deletion src/Filesystems/CantWriteFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

use RuntimeException;

class CantWriteFile extends RuntimeException
final class CantWriteFile extends RuntimeException
{
}
2 changes: 1 addition & 1 deletion src/Filesystems/NotARessource.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

use RuntimeException;

class NotARessource extends RuntimeException
final class NotARessource extends RuntimeException
{
}
2 changes: 1 addition & 1 deletion src/Procedures/Backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use function sprintf;
use function uniqid;

class Backup implements BackupProcedure
final class Backup implements BackupProcedure
{
private ShellProcessor $shellProcessor;

Expand Down
2 changes: 1 addition & 1 deletion src/Procedures/Restore.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use function sprintf;
use function uniqid;

class Restore implements RestoreProcedure
final class Restore implements RestoreProcedure
{
private ShellProcessor $shellProcessor;

Expand Down
2 changes: 1 addition & 1 deletion tests/BackupManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Fezfez\BackupManager\Procedures\RestoreProcedure;
use PHPUnit\Framework\TestCase;

class BackupManagerTest extends TestCase
final class BackupManagerTest extends TestCase
{
public function testCreateABackupProcedure(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Compressors/GzipCompressorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\Process\Process;

class GzipCompressorTest extends TestCase
final class GzipCompressorTest extends TestCase
{
/** @return iterable<int, array<string>> */
public function provideCompress(): iterable
Expand Down
4 changes: 2 additions & 2 deletions tests/Databases/MysqlDatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Fezfez\BackupManager\Databases\MysqlDatabase;
use PHPUnit\Framework\TestCase;

class MysqlDatabaseTest extends TestCase
final class MysqlDatabaseTest extends TestCase
{
public function testGenerateAValidDatabaseDumpCommand(): void
{
Expand Down Expand Up @@ -45,7 +45,7 @@ public function testGenerateAValidDatabaseDumpCommandWithSsl(): void
'test',
true,
true,
['tutu'],
['tutu', ' '],
['test']
);

Expand Down
2 changes: 1 addition & 1 deletion tests/Databases/PostgresqlDatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Fezfez\BackupManager\Databases\PostgresqlDatabase;
use PHPUnit\Framework\TestCase;

class PostgresqlDatabaseTest extends TestCase
final class PostgresqlDatabaseTest extends TestCase
{
public function testGenerateAValidDatabaseDumpCommand(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Filesystems/BackupManagerRessourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use function rewind;
use function stream_get_contents;

class BackupManagerRessourceTest extends TestCase
final class BackupManagerRessourceTest extends TestCase
{
public function testFail(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Filesystems/DestinationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Fezfez\BackupManager\Filesystems\Destination;
use PHPUnit\Framework\TestCase;

class DestinationTest extends TestCase
final class DestinationTest extends TestCase
{
public function testOk(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Procedures/BackupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\Process\Process;

class BackupTest extends TestCase
final class BackupTest extends TestCase
{
public function testOk(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Procedures/RestoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\Process\Process;

class RestoreTest extends TestCase
final class RestoreTest extends TestCase
{
public function testOk(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ShellProcessing/ShellProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\Process\Process;

class ShellProcessorTest extends TestCase
final class ShellProcessorTest extends TestCase
{
public function testExecuteACommandLineProcess(): void
{
Expand Down

0 comments on commit e262d17

Please sign in to comment.