From 68e458e0ee95e495a4ca1a4e379bbf24659cd2f5 Mon Sep 17 00:00:00 2001 From: Owen Voke Date: Fri, 18 Oct 2024 12:28:17 +0100 Subject: [PATCH] style: apply fixes from ECS --- src/FoggyCommand.php | 1 + src/Rules/FakerRule.php | 2 +- src/Rules/PhpRule.php | 2 +- src/Settings/Rule.php | 6 +++--- src/Settings/Table.php | 2 +- tests/Rules/FakerRuleTest.php | 2 +- tests/Rules/PhpRuleTest.php | 6 +++--- tests/Rules/ReplaceRuleTest.php | 2 +- 8 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/FoggyCommand.php b/src/FoggyCommand.php index 9a4c386..5fffd72 100644 --- a/src/FoggyCommand.php +++ b/src/FoggyCommand.php @@ -41,6 +41,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $process = new DumpProcess($dsn, $configFile, $output); $process->run(); + return 0; } } diff --git a/src/Rules/FakerRule.php b/src/Rules/FakerRule.php index f331d29..5ad975b 100644 --- a/src/Rules/FakerRule.php +++ b/src/Rules/FakerRule.php @@ -9,7 +9,7 @@ class FakerRule implements Rule { - protected static ?FakerGenerator $faker = null; + protected static FakerGenerator|null $faker = null; public static function faker(): FakerGenerator { diff --git a/src/Rules/PhpRule.php b/src/Rules/PhpRule.php index d47726d..c5e824a 100644 --- a/src/Rules/PhpRule.php +++ b/src/Rules/PhpRule.php @@ -18,7 +18,7 @@ public static function handle(SettingsRule $rule, Connection $db, array $row, st $result = eval("return {$rule->getValue()};"); if ($result === null) { - return "NULL"; + return 'NULL'; } return $db->quote($result); diff --git a/src/Settings/Rule.php b/src/Settings/Rule.php index 6fd2d88..9272f33 100644 --- a/src/Settings/Rule.php +++ b/src/Settings/Rule.php @@ -34,7 +34,7 @@ public function hasCondition(): bool return $this->getCondition() !== null || $this->getTimes() !== null; } - public function getCondition(): ?string + public function getCondition(): string|null { return $this->settings->condition ?? null; } @@ -44,12 +44,12 @@ public function getColumn(): string return $this->settings->column; } - public function getValue(): ?string + public function getValue(): string|null { return $this->settings->value ?? null; } - public function getTimes(): ?int + public function getTimes(): int|null { return $this->settings->times ?? null; } diff --git a/src/Settings/Table.php b/src/Settings/Table.php index a05c01c..75256ed 100644 --- a/src/Settings/Table.php +++ b/src/Settings/Table.php @@ -29,7 +29,7 @@ public function withData(): bool return $this->settings->withData ?? true; } - public function getWhere(): ?string + public function getWhere(): string|null { if (isset($this->settings->where)) { return " WHERE {$this->settings->where}"; diff --git a/tests/Rules/FakerRuleTest.php b/tests/Rules/FakerRuleTest.php index 8a60b83..4767e0a 100644 --- a/tests/Rules/FakerRuleTest.php +++ b/tests/Rules/FakerRuleTest.php @@ -28,6 +28,6 @@ $fakeRule, $fakeConnection, [], - "" + '' ); }); diff --git a/tests/Rules/PhpRuleTest.php b/tests/Rules/PhpRuleTest.php index 92a401c..8806aa2 100644 --- a/tests/Rules/PhpRuleTest.php +++ b/tests/Rules/PhpRuleTest.php @@ -8,9 +8,9 @@ use Worksome\Foggy\Settings\Rule; it('can evaluate php string', function () { - $value = "column value"; + $value = 'column value'; $phpString = '"appended " . $value'; - $generatedValue = "appended column value"; + $generatedValue = 'appended column value'; $fakerRule = new PhpRule(); @@ -31,7 +31,7 @@ }); it('can cast null to SQL NULL', function () { - $value = "column value"; + $value = 'column value'; $phpString = 'null'; $fakerRule = new PhpRule(); diff --git a/tests/Rules/ReplaceRuleTest.php b/tests/Rules/ReplaceRuleTest.php index bd0a3eb..4a61cb4 100644 --- a/tests/Rules/ReplaceRuleTest.php +++ b/tests/Rules/ReplaceRuleTest.php @@ -24,6 +24,6 @@ $fakeRule, $fakeConnection, [], - "" + '' ); });