From f8694a6ef0dd1329c66a845bb41e9d8054488f5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Thu, 14 Mar 2024 11:32:16 +0100 Subject: [PATCH 1/8] testing Declare strict types --- .github/workflows/back-end.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/back-end.yml b/.github/workflows/back-end.yml index 610035c4..d62804aa 100644 --- a/.github/workflows/back-end.yml +++ b/.github/workflows/back-end.yml @@ -76,6 +76,17 @@ jobs: uses: "ramsey/composer-install@v2" with: dependency-versions: "${{ matrix.dependencies }}" + - + name: "Declare strict types" + if: "${{ matrix.dependencies == 'highest' }}" + run: | + echo "::group::Install slevomat/coding-standard" + composer config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer false + composer require --no-scripts --dev slevomat/coding-standard + echo "::endgroup::" + composer exec -- phpcbf --standard=vendor/slevomat/coding-standard/SlevomatCodingStandard \ + --sniffs=SlevomatCodingStandard.TypeHints.DeclareStrictTypes src/ \ + || test "$?" = 1 && exit 0 - name: "Execute unit tests" run: "composer exec -- phpunit" From 534ea380375b9baaf4f3c3b5587f6c51a6655941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Thu, 14 Mar 2024 11:43:59 +0100 Subject: [PATCH 2/8] Update back-end.yml --- .github/workflows/back-end.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/back-end.yml b/.github/workflows/back-end.yml index d62804aa..5c260ef8 100644 --- a/.github/workflows/back-end.yml +++ b/.github/workflows/back-end.yml @@ -89,7 +89,7 @@ jobs: || test "$?" = 1 && exit 0 - name: "Execute unit tests" - run: "composer exec -- phpunit" + run: "composer exec -- phpunit --process-isolation" - name: "Tests have failed: upload logs" if: "${{ failure() }}" From 5a6a2139d5ee5f7a577beb5a345b51bda90192a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Thu, 14 Mar 2024 12:28:13 +0100 Subject: [PATCH 3/8] try WithoutErrorHandler --- tests/Http/RelationControllerTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Http/RelationControllerTest.php b/tests/Http/RelationControllerTest.php index f415e6dd..784ebcb3 100644 --- a/tests/Http/RelationControllerTest.php +++ b/tests/Http/RelationControllerTest.php @@ -35,6 +35,7 @@ public function setUp(): void ); } + #[\PHPUnit\Framework\Attributes\WithoutErrorHandler] public function test_a_relation_controller_handles_index(): void { $this->actingAs($this->admin) From 2acfae491f1b31df57ab0b010169b8d8757317d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Thu, 14 Mar 2024 12:37:02 +0100 Subject: [PATCH 4/8] Update back-end.yml --- .github/workflows/back-end.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/back-end.yml b/.github/workflows/back-end.yml index 5c260ef8..d62804aa 100644 --- a/.github/workflows/back-end.yml +++ b/.github/workflows/back-end.yml @@ -89,7 +89,7 @@ jobs: || test "$?" = 1 && exit 0 - name: "Execute unit tests" - run: "composer exec -- phpunit --process-isolation" + run: "composer exec -- phpunit" - name: "Tests have failed: upload logs" if: "${{ failure() }}" From 640170e300cda59fb0e22dabb8371e86384829a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Thu, 14 Mar 2024 12:40:39 +0100 Subject: [PATCH 5/8] Update RelationControllerTest.php --- tests/Http/RelationControllerTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Http/RelationControllerTest.php b/tests/Http/RelationControllerTest.php index 784ebcb3..ff9e25e8 100644 --- a/tests/Http/RelationControllerTest.php +++ b/tests/Http/RelationControllerTest.php @@ -39,6 +39,7 @@ public function setUp(): void public function test_a_relation_controller_handles_index(): void { $this->actingAs($this->admin) + ->withoutExceptionHandling() ->get('/root/users/'.$this->admin->getKey().'/fields/uploads') ->assertOk() ->assertViewIs('root::resources.index') From 53eba8d5bf70e4342099c31356d58fa16f4fd23c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Thu, 14 Mar 2024 12:45:23 +0100 Subject: [PATCH 6/8] Update Relation.php --- src/Fields/Relation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Fields/Relation.php b/src/Fields/Relation.php index dcefe43b..d82b0531 100644 --- a/src/Fields/Relation.php +++ b/src/Fields/Relation.php @@ -573,7 +573,7 @@ public function mapRelated(Request $request, Model $model, Model $related): arra */ public function modelUrl(Model $model): string { - return str_replace('{resourceModel}', $model->exists ? $model->getKey() : 'create', $this->getUri()); + return str_replace('{resourceModel}', $model->exists ? (string) $model->getKey() : 'create', $this->getUri()); } /** From 9eaec20bfee9333bc1deaa9fa8163d59b33091cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Thu, 14 Mar 2024 12:49:33 +0100 Subject: [PATCH 7/8] Update Field.php --- src/Fields/Field.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Fields/Field.php b/src/Fields/Field.php index 3f8ab8b5..6cada8da 100644 --- a/src/Fields/Field.php +++ b/src/Fields/Field.php @@ -445,7 +445,7 @@ public function resolveFormat(Request $request, Model $model): ?string $value = $this->resolveValue($request, $model); if (is_null($this->formatResolver)) { - return is_array($value) ? json_encode($value) : $value; + return is_array($value) ? json_encode($value) : (string) $value; } return call_user_func_array($this->formatResolver, [$request, $model, $value]); From 3a9088c66c60d9e090e64587f435ce3a8308353e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Thu, 14 Mar 2024 12:58:11 +0100 Subject: [PATCH 8/8] Update Resource.php --- src/Resources/Resource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resources/Resource.php b/src/Resources/Resource.php index 8e82811a..83db6697 100644 --- a/src/Resources/Resource.php +++ b/src/Resources/Resource.php @@ -297,7 +297,7 @@ public function modelUrl(Model $model): string */ public function modelTitle(Model $model): string { - return $model->getKey(); + return (string) $model->getKey(); } /**