From 2861bd349a42bfd365123fed2dac6b7904847a50 Mon Sep 17 00:00:00 2001 From: Alexander Dmitryuk Date: Thu, 10 Nov 2022 15:29:50 +0600 Subject: [PATCH] Fix some deprecations (#125) * Method "Doctrine\DBAL\Driver::connect()" might add "DriverConnection" as a native return type declaration in the future. Do the same in implementation "DH\Auditor\Provider\Doctrine\Auditing\Logger\Middleware\DHDriver" now to avoid errors or add an explicit @return annotation to suppress this message. * The "Symfony\Component\Console\Command\Command::$defaultName" property is considered final. You should not override it in "DH\Auditor\Provider\Doctrine\Persistence\Command\CleanAuditLogsCommand". * alphabet * remove AsCommand * csfixer Co-authored-by: a.dmitryuk --- src/Provider/Doctrine/Auditing/Logger/Middleware/DHDriver.php | 2 +- .../Doctrine/Persistence/Command/CleanAuditLogsCommand.php | 4 +--- .../Doctrine/Persistence/Command/UpdateSchemaCommand.php | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Provider/Doctrine/Auditing/Logger/Middleware/DHDriver.php b/src/Provider/Doctrine/Auditing/Logger/Middleware/DHDriver.php index 68f7fca8..ab486b2a 100644 --- a/src/Provider/Doctrine/Auditing/Logger/Middleware/DHDriver.php +++ b/src/Provider/Doctrine/Auditing/Logger/Middleware/DHDriver.php @@ -26,7 +26,7 @@ public function __construct(DriverInterface $driver) /** * {@inheritDoc} */ - public function connect(array $params) + public function connect(array $params): DHConnection { return new DHConnection( $this->driver->connect($params), diff --git a/src/Provider/Doctrine/Persistence/Command/CleanAuditLogsCommand.php b/src/Provider/Doctrine/Persistence/Command/CleanAuditLogsCommand.php index 38f28770..65d26b14 100644 --- a/src/Provider/Doctrine/Persistence/Command/CleanAuditLogsCommand.php +++ b/src/Provider/Doctrine/Persistence/Command/CleanAuditLogsCommand.php @@ -33,8 +33,6 @@ class CleanAuditLogsCommand extends Command private const UNTIL_DATE_FORMAT = 'Y-m-d H:i:s'; - protected static $defaultName = 'audit:clean'; - private Auditor $auditor; public function unlock(): void @@ -53,7 +51,7 @@ protected function configure(): void { $this ->setDescription('Cleans audit tables') - ->setName(self::$defaultName) // @phpstan-ignore-line + ->setName('audit:clean') ->addOption('no-confirm', null, InputOption::VALUE_NONE, 'No interaction mode') ->addOption('dry-run', null, InputOption::VALUE_NONE, 'Do not execute SQL queries.') ->addOption('dump-sql', null, InputOption::VALUE_NONE, 'Prints SQL related queries.') diff --git a/src/Provider/Doctrine/Persistence/Command/UpdateSchemaCommand.php b/src/Provider/Doctrine/Persistence/Command/UpdateSchemaCommand.php index ecafa614..1918d15c 100644 --- a/src/Provider/Doctrine/Persistence/Command/UpdateSchemaCommand.php +++ b/src/Provider/Doctrine/Persistence/Command/UpdateSchemaCommand.php @@ -22,8 +22,6 @@ class UpdateSchemaCommand extends Command { use LockableTrait; - protected static $defaultName = 'audit:schema:update'; - private Auditor $auditor; public function unlock(): void @@ -42,9 +40,9 @@ protected function configure(): void { $this ->setDescription('Update audit tables structure') + ->setName('audit:schema:update') ->addOption('dump-sql', null, InputOption::VALUE_NONE, 'Dumps the generated SQL statements to the screen (does not execute them).') ->addOption('force', 'f', InputOption::VALUE_NONE, 'Causes the generated SQL statements to be physically executed against your database.') - ->setName(self::$defaultName) // @phpstan-ignore-line ; }