Skip to content

Commit ee21994

Browse files
committed
fix: PHPStan
1 parent cec40cf commit ee21994

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Http/Resources/Post/PostNavigateResource.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@ public function toArray($request): array
2525
];
2626
}
2727

28-
/** @var array{previous?: mixed, next?: mixed} $resource */
29-
$resource = $this->resource;
28+
// Cast to proper array type for PHPStan
29+
/** @var array<string, \CSlant\Blog\Core\Models\Post|null> $navigationData */
30+
$navigationData = $this->resource;
31+
32+
$previous = array_key_exists('previous', $navigationData) ? $navigationData['previous'] : null;
33+
$next = array_key_exists('next', $navigationData) ? $navigationData['next'] : null;
3034

3135
return [
32-
'previous' => isset($resource['previous']) && $resource['previous'] ? new PostNavigationResource($resource['previous']) : null,
33-
'next' => isset($resource['next']) && $resource['next'] ? new PostNavigationResource($resource['next']) : null,
36+
'previous' => $previous ? new PostNavigationResource($previous) : null,
37+
'next' => $next ? new PostNavigationResource($next) : null,
3438
];
3539
}
3640
}

0 commit comments

Comments
 (0)