From 910643f772afa39c2409f46fd7dbcaa71a1476a3 Mon Sep 17 00:00:00 2001 From: Anton Komarev Date: Sun, 10 Mar 2024 11:52:16 +0300 Subject: [PATCH] Code style fix --- src/ClickhouseServiceProvider.php | 8 ++++---- .../MakeClickhouseMigrationCommand.php | 4 +++- src/Migration/AbstractClickhouseMigration.php | 2 +- src/Migration/MigrationRepository.php | 19 ++++++++----------- src/Migration/Migrator.php | 12 ++++++------ 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/ClickhouseServiceProvider.php b/src/ClickhouseServiceProvider.php index e8ab959..3608eb2 100644 --- a/src/ClickhouseServiceProvider.php +++ b/src/ClickhouseServiceProvider.php @@ -40,7 +40,7 @@ static function (Application $app): ClickhouseClient { $clickhouseClientFactory = new ClickhouseClientFactory($connectionConfig); return $clickhouseClientFactory->create(); - } + }, ); $this->app->singleton( @@ -61,7 +61,7 @@ static function (Application $app): Migrator { $repository, $filesystem, ); - } + }, ); $this->app->singleton( @@ -71,7 +71,7 @@ static function (Application $app): MigrationCreator { $app->get(Filesystem::class), $app->basePath('stubs'), ); - } + }, ); } @@ -99,7 +99,7 @@ private function registerConsoleCommands(): void [ ClickhouseMigrateCommand::class, MakeClickhouseMigrationCommand::class, - ] + ], ); } } diff --git a/src/ConsoleCommand/MakeClickhouseMigrationCommand.php b/src/ConsoleCommand/MakeClickhouseMigrationCommand.php index 4a6afd0..650f867 100644 --- a/src/ConsoleCommand/MakeClickhouseMigrationCommand.php +++ b/src/ConsoleCommand/MakeClickhouseMigrationCommand.php @@ -24,7 +24,9 @@ final class MakeClickhouseMigrationCommand extends Command { private MigrationCreator $creator; + private Composer $composer; + private AppConfigRepositoryInterface $appConfigRepository; protected $description = 'Create a new ClickHouse migration file'; @@ -130,7 +132,7 @@ private function getMigrationPath(): string return rtrim( $this->appConfigRepository->get('clickhouse.migrations.path'), - '/' + '/', ); } diff --git a/src/Migration/AbstractClickhouseMigration.php b/src/Migration/AbstractClickhouseMigration.php index 91beed6..57e14b2 100644 --- a/src/Migration/AbstractClickhouseMigration.php +++ b/src/Migration/AbstractClickhouseMigration.php @@ -19,7 +19,7 @@ abstract class AbstractClickhouseMigration { - protected ?Client $clickhouseClient; + protected Client $clickhouseClient; protected string $databaseName; public function __construct( diff --git a/src/Migration/MigrationRepository.php b/src/Migration/MigrationRepository.php index 5b22e2f..c49fc16 100644 --- a/src/Migration/MigrationRepository.php +++ b/src/Migration/MigrationRepository.php @@ -46,7 +46,7 @@ public function createMigrationRegistryTable(): Statement SQL, [ 'table' => $this->table, - ] + ], ); } @@ -62,7 +62,7 @@ public function all(): array SQL, [ 'table' => $this->table, - ] + ], )->rows(); return collect($rows)->pluck('migration')->all(); @@ -83,7 +83,7 @@ public function latest(): array SQL, [ 'table' => $this->table, - ] + ], )->rows(); return collect($rows)->pluck('migration')->all(); @@ -104,7 +104,7 @@ public function getLastBatchNumber(): int SQL, [ 'table' => $this->table, - ] + ], ) ->fetchOne('batch'); } @@ -116,13 +116,10 @@ public function add( return $this->client->insert( $this->table, [[$migration, $batch]], - ['migration', 'batch'] + ['migration', 'batch'], ); } - /** - * @return int - */ public function total(): int { return (int)$this->client->select( @@ -132,7 +129,7 @@ public function total(): int SQL, [ 'table' => $this->table, - ] + ], )->fetchOne('count'); } @@ -144,7 +141,7 @@ public function exists(): bool SQL, [ 'table' => $this->table, - ] + ], )->fetchOne('result'); } @@ -165,7 +162,7 @@ public function find( [ 'table' => $this->table, 'migration' => $migration, - ] + ], )->fetchOne(); } } diff --git a/src/Migration/Migrator.php b/src/Migration/Migrator.php index ce564d4..3b4a33e 100644 --- a/src/Migration/Migrator.php +++ b/src/Migration/Migrator.php @@ -53,7 +53,7 @@ public function runUp( if ($migrations->valid() === false) { $output->writeln( - 'Migrations are empty.' + 'Migrations are empty.', ); return; @@ -76,7 +76,7 @@ public function runUp( $this->repository->add($migrationName, $nextBatch); $output->writeln( - "Completed in {$runTime} seconds {$migrationName}" + "Completed in {$runTime} seconds {$migrationName}", ); $migrations->next(); @@ -109,7 +109,7 @@ private function getMigrationName( } /** - * @return SplFileInfo[] + * @return list */ private function getUnAppliedMigrationFiles( string $migrationsDirectoryPath @@ -120,7 +120,7 @@ private function getUnAppliedMigrationFiles( ->reject( fn(SplFileInfo $migrationFile) => $this->isAppliedMigration( $migrationFile->getFilename(), - ) + ), )->all(); } @@ -145,7 +145,7 @@ private function generateMigrationClassName( string $migrationName ): string { return Str::studly( - implode('_', array_slice(explode('_', $migrationName), 4)) + implode('_', array_slice(explode('_', $migrationName), 4)), ); } @@ -167,7 +167,7 @@ private function isAppliedMigration( return in_array( $this->getMigrationName($fileName), $this->repository->all(), - true + true, ); } }