From 0486abcd9ac1821baf9587d17aff263ff5657d46 Mon Sep 17 00:00:00 2001 From: Anatoliy Melnikov <5785276@gmail.com> Date: Tue, 21 May 2024 23:22:42 +0300 Subject: [PATCH] Fix code style --- functions/base.php | 6 +++--- src/Model/BaselineContent.php | 2 +- src/Model/BaselineFile.php | 2 +- src/Model/FileHash.php | 2 +- src/Service/Builder.php | 3 +-- src/Service/ConfigHashCalculator.php | 5 ++--- src/Service/FileCacheCalculator.php | 2 +- src/Service/FileComparator.php | 2 +- src/Service/FilterFactory.php | 2 +- src/Service/Reader.php | 4 ++-- src/Service/Saver.php | 4 ++-- tests/Unit/Model/FileHashTest.php | 2 +- 12 files changed, 17 insertions(+), 19 deletions(-) diff --git a/functions/base.php b/functions/base.php index 1d1102d..d3cd433 100644 --- a/functions/base.php +++ b/functions/base.php @@ -20,7 +20,7 @@ function cs_fixer_get_baseline(): array $path = cs_fixer_get_baseline_file_path(); return file_exists($path) - ? json_decode(file_get_contents($path), true, 512, JSON_THROW_ON_ERROR) + ? json_decode(file_get_contents($path), true, 512, \JSON_THROW_ON_ERROR) : []; } @@ -50,7 +50,7 @@ function cs_fixer_get_config_hash(PhpCsFixer\Config $config): int ksort($data); - return crc32(json_encode($data, JSON_THROW_ON_ERROR)); + return crc32(json_encode($data, \JSON_THROW_ON_ERROR)); } /** @@ -65,5 +65,5 @@ function cs_fixer_put_baseline(array $hashes, PhpCsFixer\Config $config): void 'hashes' => $hashes, ]; $path = cs_fixer_get_baseline_file_path(); - file_put_contents($path, json_encode($baseline, JSON_THROW_ON_ERROR | \JSON_PRETTY_PRINT)); + file_put_contents($path, json_encode($baseline, \JSON_THROW_ON_ERROR | \JSON_PRETTY_PRINT)); } diff --git a/src/Model/BaselineContent.php b/src/Model/BaselineContent.php index 204bda5..50e57a6 100644 --- a/src/Model/BaselineContent.php +++ b/src/Model/BaselineContent.php @@ -51,4 +51,4 @@ public function jsonSerialize(): array return $baseline; } -} \ No newline at end of file +} diff --git a/src/Model/BaselineFile.php b/src/Model/BaselineFile.php index cfa77e8..14282e2 100644 --- a/src/Model/BaselineFile.php +++ b/src/Model/BaselineFile.php @@ -24,4 +24,4 @@ public function getLockedFilesCount(): int { return $this->content->getHashesCount(); } -} \ No newline at end of file +} diff --git a/src/Model/FileHash.php b/src/Model/FileHash.php index ad5a64f..f756641 100644 --- a/src/Model/FileHash.php +++ b/src/Model/FileHash.php @@ -27,4 +27,4 @@ public function jsonSerialize(): array { return ['hash' => $this->hash]; } -} \ No newline at end of file +} diff --git a/src/Service/Builder.php b/src/Service/Builder.php index 305cdb0..c9ebc43 100644 --- a/src/Service/Builder.php +++ b/src/Service/Builder.php @@ -10,7 +10,6 @@ final class Builder { - private ConfigHashCalculator $configHashCalculator; private FileCacheCalculator $fileCacheCalculator; @@ -32,4 +31,4 @@ public function create(string $path, Config $config, Finder $finder): BaselineFi return new BaselineFile($path, $content); } -} \ No newline at end of file +} diff --git a/src/Service/ConfigHashCalculator.php b/src/Service/ConfigHashCalculator.php index b060f9f..e4ed4ad 100644 --- a/src/Service/ConfigHashCalculator.php +++ b/src/Service/ConfigHashCalculator.php @@ -8,7 +8,6 @@ final class ConfigHashCalculator { public function calculate(Config $config): int { - $rules = $config->getRules(); sort($rules); @@ -19,6 +18,6 @@ public function calculate(Config $config): int ksort($data); - return crc32(json_encode($data, JSON_THROW_ON_ERROR)); + return crc32(json_encode($data, \JSON_THROW_ON_ERROR)); } -} \ No newline at end of file +} diff --git a/src/Service/FileCacheCalculator.php b/src/Service/FileCacheCalculator.php index 6c54eb5..00aa4d9 100644 --- a/src/Service/FileCacheCalculator.php +++ b/src/Service/FileCacheCalculator.php @@ -8,4 +8,4 @@ public function calculate(\SplFileInfo $file): string { return crc32(file_get_contents($file->getPathname())); } -} \ No newline at end of file +} diff --git a/src/Service/FileComparator.php b/src/Service/FileComparator.php index c27868c..c88f194 100644 --- a/src/Service/FileComparator.php +++ b/src/Service/FileComparator.php @@ -17,4 +17,4 @@ public function isInBaseLine(BaselineContent $content, \SplFileInfo $file): bool return $hash && $hash === $this->fileCacheCalculator->calculate($file); } -} \ No newline at end of file +} diff --git a/src/Service/FilterFactory.php b/src/Service/FilterFactory.php index be6a247..2b9491f 100644 --- a/src/Service/FilterFactory.php +++ b/src/Service/FilterFactory.php @@ -16,4 +16,4 @@ public function createFilter(string $path, Config $config): \Closure return !$isSameConfig || $comparator->isInBaseLine($baseline, $file); }; } -} \ No newline at end of file +} diff --git a/src/Service/Reader.php b/src/Service/Reader.php index 075de2f..0d7694f 100644 --- a/src/Service/Reader.php +++ b/src/Service/Reader.php @@ -11,7 +11,7 @@ final class Reader public function read(string $path): BaselineFile { $json = file_exists($path) - ? json_decode(file_get_contents($path), true, 512, JSON_THROW_ON_ERROR) + ? json_decode(file_get_contents($path), true, 512, \JSON_THROW_ON_ERROR) : []; $content = new BaselineContent(); @@ -25,4 +25,4 @@ public function read(string $path): BaselineFile return new BaselineFile($path, $content); } -} \ No newline at end of file +} diff --git a/src/Service/Saver.php b/src/Service/Saver.php index 09f3440..2cdfd3c 100644 --- a/src/Service/Saver.php +++ b/src/Service/Saver.php @@ -8,6 +8,6 @@ final class Saver { public function save(BaselineFile $baseline): void { - file_put_contents($baseline->getPath(), json_encode($baseline, JSON_THROW_ON_ERROR | \JSON_PRETTY_PRINT)); + file_put_contents($baseline->getPath(), json_encode($baseline, \JSON_THROW_ON_ERROR | \JSON_PRETTY_PRINT)); } -} \ No newline at end of file +} diff --git a/tests/Unit/Model/FileHashTest.php b/tests/Unit/Model/FileHashTest.php index 48cf015..02f883c 100644 --- a/tests/Unit/Model/FileHashTest.php +++ b/tests/Unit/Model/FileHashTest.php @@ -19,4 +19,4 @@ public function testGetters(): void self::assertSame($path, $fileHash->getPath()); self::assertSame(['hash' => $hash], $fileHash->jsonSerialize()); } -} \ No newline at end of file +}