Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/back-end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ jobs:
uses: "ramsey/composer-install@v3"
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"
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,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]);
Expand Down
4 changes: 2 additions & 2 deletions src/Fields/Relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,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());
}

/**
Expand Down Expand Up @@ -906,7 +906,7 @@ public function parseQueryString(string $url): array
{
$query = parse_url($url, PHP_URL_QUERY);

parse_str($query, $result);
parse_str($query ?? '', $result);

return array_filter($result, fn (string $key): bool => str_starts_with($key, $this->getRequestKey()), ARRAY_FILTER_USE_KEY);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Repeater.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function buildOption(Request $request, Model $model): array
*/
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());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ public function modelUrl(Model $model): string
*/
public function modelTitle(Model $model): string
{
return $model->getKey();
return (string) $model->getKey();
}

/**
Expand Down
2 changes: 2 additions & 0 deletions tests/Http/RelationControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ protected function setUp(): void
);
}

#[\PHPUnit\Framework\Attributes\WithoutErrorHandler]
public function test_relation_controller_handles_index(): void
{
$this->actingAs($this->admin)
->withoutExceptionHandling()
->get('/root/resources/users/'.$this->admin->getKey().'/fields/uploads')
->assertOk()
->assertViewIs('root::resources.index')
Expand Down
Loading