From d75fa4a99c66af53a9132579b61fcd0afef8fe35 Mon Sep 17 00:00:00 2001 From: tiagof Date: Wed, 11 Sep 2024 11:41:25 +0000 Subject: [PATCH] Fix styling --- src/Traits/HasVolition.php | 6 +++--- src/Volition.php | 6 +++--- tests/Feature/PayloadCastTest.php | 9 +++------ tests/Unit/VolitionTest.php | 4 ++-- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/Traits/HasVolition.php b/src/Traits/HasVolition.php index ae59506..17ad65f 100644 --- a/src/Traits/HasVolition.php +++ b/src/Traits/HasVolition.php @@ -44,7 +44,7 @@ public function rule(string|Rule $rule): ?Rule * * @return Collection<\Squarebit\Volition\Contracts\IsAction> */ - public function actions(string|Rule $forRule = null): Collection + public function actions(string|Rule|null $forRule = null): Collection { $actions = $forRule ? $this->rule($forRule)?->actions @@ -62,7 +62,7 @@ public function actions(string|Rule $forRule = null): Collection * @param class-string $ofClass * @return TActionClass|null */ - public function action(string $ofClass, string $forRule = null, bool $throw = false): ?IsAction + public function action(string $ofClass, ?string $forRule = null, bool $throw = false): ?IsAction { $action = $this->actions($forRule)->firstWhere(fn (IsAction $action) => $action instanceof $ofClass); @@ -78,7 +78,7 @@ public function action(string $ofClass, string $forRule = null, bool $throw = fa /** * @param class-string<\Squarebit\Volition\Contracts\IsAction> $actionClass */ - public function executeAction(string $actionClass, string $forRule = null, bool $throw = false): mixed + public function executeAction(string $actionClass, ?string $forRule = null, bool $throw = false): mixed { return $this->action($actionClass, $forRule, $throw)?->execute($this); } diff --git a/src/Volition.php b/src/Volition.php index 2e7391a..52231fe 100644 --- a/src/Volition.php +++ b/src/Volition.php @@ -17,7 +17,7 @@ class Volition protected array $actions = []; /** - * @return class-string|null + * @return class-string|null */ public function getElement(string $elementType, bool $throw = false): ?string { @@ -33,7 +33,7 @@ public function getElement(string $elementType, bool $throw = false): ?string } /** - * @return array> + * @return array> */ public function getConditions(): array { @@ -41,7 +41,7 @@ public function getConditions(): array } /** - * @return array> + * @return array> */ public function getActions(): array { diff --git a/tests/Feature/PayloadCastTest.php b/tests/Feature/PayloadCastTest.php index 7f75e42..f342e57 100644 --- a/tests/Feature/PayloadCastTest.php +++ b/tests/Feature/PayloadCastTest.php @@ -1,16 +1,13 @@ $rule->id, 'enabled' => 1, - 'payload' => serialize(new ObjectPropertyCondition('some_property', 'some_value')) + 'payload' => serialize(new ObjectPropertyCondition('some_property', 'some_value')), ]); Action::insert([ 'rule_id' => $rule->id, 'enabled' => 1, - 'payload' => serialize(new PrefixAction('some_value')) + 'payload' => serialize(new PrefixAction('some_value')), ]); }); diff --git a/tests/Unit/VolitionTest.php b/tests/Unit/VolitionTest.php index 05c68aa..f9d0713 100644 --- a/tests/Unit/VolitionTest.php +++ b/tests/Unit/VolitionTest.php @@ -25,12 +25,12 @@ }); test('fails to registers Actions as Conditions or vice-versa', function () { - expect(fn() => Volition::registerConditions([ + expect(fn () => Volition::registerConditions([ PrefixAction::class, SuffixAction::class, ]))->toThrow(Exception::class); - expect(fn() => Volition::registerActions([ + expect(fn () => Volition::registerActions([ ObjectPropertyCondition::class, ]))->toThrow(Exception::class); });