From f05a919b9c2d127b6aa1f0849ac33fa6fd47a26c Mon Sep 17 00:00:00 2001 From: philipp lang Date: Wed, 24 Apr 2024 15:39:07 +0200 Subject: [PATCH] Lint --- app/Form/Actions/IsDirtyAction.php | 3 +++ app/Form/Editor/FormConditionResolver.php | 6 ++---- app/Form/Fields/Field.php | 7 +++++++ app/Lib/Editor/ConditionResolver.php | 2 +- database/factories/Traits/FakesMedia.php | 3 +++ phpstan.neon | 5 ----- tests/RequestFactories/EditorRequestFactory.php | 4 ++++ 7 files changed, 20 insertions(+), 10 deletions(-) diff --git a/app/Form/Actions/IsDirtyAction.php b/app/Form/Actions/IsDirtyAction.php index 68df1a6b..d9e9a68b 100644 --- a/app/Form/Actions/IsDirtyAction.php +++ b/app/Form/Actions/IsDirtyAction.php @@ -11,6 +11,9 @@ class IsDirtyAction { use AsAction; + /** + * @return array + */ public function rules(): array { return [ diff --git a/app/Form/Editor/FormConditionResolver.php b/app/Form/Editor/FormConditionResolver.php index b87dc110..7178b557 100644 --- a/app/Form/Editor/FormConditionResolver.php +++ b/app/Form/Editor/FormConditionResolver.php @@ -20,7 +20,7 @@ class FormConditionResolver extends ConditionResolver /** * @inheritdoc */ - public function filterCondition($mode, $ifs): bool + public function filterCondition(string $mode, array $ifs): bool { if (count($ifs) === 0) { return true; @@ -41,8 +41,6 @@ class FormConditionResolver extends ConditionResolver return false; } - if ($mode === 'all') { - return true; - } + return true; } } diff --git a/app/Form/Fields/Field.php b/app/Form/Fields/Field.php index 3da10efe..36f43f39 100644 --- a/app/Form/Fields/Field.php +++ b/app/Form/Fields/Field.php @@ -5,6 +5,8 @@ namespace App\Form\Fields; use App\Form\Data\ColumnData; use App\Form\Enums\NamiType; use App\Form\Enums\SpecialType; +use App\Form\Matchers\Matcher; +use App\Form\Matchers\SingleValueMatcher; use App\Form\Models\Form; use App\Form\Models\Participant; use App\Form\Presenters\DefaultPresenter; @@ -170,4 +172,9 @@ abstract class Field extends Data { return $this->getMatcher()->setValue($this->value)->matches($comparator, $value); } + + public function getMatcher(): Matcher + { + return app(SingleValueMatcher::class); + } } diff --git a/app/Lib/Editor/ConditionResolver.php b/app/Lib/Editor/ConditionResolver.php index b80bd981..bc671a1e 100644 --- a/app/Lib/Editor/ConditionResolver.php +++ b/app/Lib/Editor/ConditionResolver.php @@ -20,7 +20,7 @@ abstract class ConditionResolver } /** - * @inheritdoc + * @param array $block */ public function filterBlock(array $block): bool { diff --git a/database/factories/Traits/FakesMedia.php b/database/factories/Traits/FakesMedia.php index 50a1e5f2..3cda08e0 100644 --- a/database/factories/Traits/FakesMedia.php +++ b/database/factories/Traits/FakesMedia.php @@ -22,6 +22,9 @@ trait FakesMedia }); } + /** + * @param array $properties + */ public function withDocument(string $collection, string $filename, string $content = '', array $properties = []): self { return $this->afterCreating(function (HasMedia $model) use ($filename, $collection, $content, $properties) { diff --git a/phpstan.neon b/phpstan.neon index 271e24a8..c38e80f6 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -533,11 +533,6 @@ parameters: count: 1 path: app/Member/FilterScope.php - - - message: "#^Call to function is_null\\(\\) with array will always evaluate to false\\.$#" - count: 1 - path: app/Form/Models/Form.php - - message: "#^Unable to resolve the template type TKey in call to function collect$#" count: 1 diff --git a/tests/RequestFactories/EditorRequestFactory.php b/tests/RequestFactories/EditorRequestFactory.php index da9c10bf..209a4c11 100644 --- a/tests/RequestFactories/EditorRequestFactory.php +++ b/tests/RequestFactories/EditorRequestFactory.php @@ -20,12 +20,16 @@ class EditorRequestFactory extends RequestFactory ]; } + /** + * @param array $conditions + */ public function text(int $id, string $text, array $conditions = ['mode' => 'all', 'ifs' => []]): self { return $this->state($this->paragraphBlock($id, $text, $conditions)); } /** + * @param array $conditions * @return array */ public function paragraphBlock(int $id, string $text, array $conditions = ['mode' => 'all', 'ifs' => []]): array