From afc58cfbb20bc108dde6148c19f338434b3f9195 Mon Sep 17 00:00:00 2001 From: "Sebastian BURGIN-FIX (ext)" Date: Sun, 2 Aug 2026 20:49:43 +0200 Subject: [PATCH] Fix Larastan errors in test files from PR #94 Add missing array shape docblocks, narrow mixed before casting to int, avoid a nullable Collection::first() access, and guard against file_get_contents() returning false. --- tests/Feature/Actions/FetchLlmUsageActionTest.php | 9 +++++++-- tests/Feature/Components/IntroTabsTest.php | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/Feature/Actions/FetchLlmUsageActionTest.php b/tests/Feature/Actions/FetchLlmUsageActionTest.php index 6ba5bbb..ed1aa83 100644 --- a/tests/Feature/Actions/FetchLlmUsageActionTest.php +++ b/tests/Feature/Actions/FetchLlmUsageActionTest.php @@ -13,6 +13,10 @@ config()->set('services.litellm.master_key', 'test-master-key'); }); +/** + * @param array> $data + * @return array + */ function llmPage(array $data, int $page, int $totalPages): array { return [ @@ -61,7 +65,8 @@ function llmPage(array $data, int $page, int $totalPages): array it('walks every page and aggregates across them without loading the whole day at once', function () { Http::fake([ 'llm.codebar.net/spend/logs/v2*' => function (Request $request) { - $page = (int) data_get($request->data(), 'page'); + $pageValue = data_get($request->data(), 'page'); + $page = is_numeric($pageValue) ? (int) $pageValue : 1; return match ($page) { 1 => Http::response(llmPage([ @@ -79,7 +84,7 @@ function llmPage(array $data, int $page, int $totalPages): array expect($rows)->toHaveCount(1); - $qwen = $rows->first(); + $qwen = $rows->firstOrFail(); expect($qwen['prompt_tokens'])->toBe(110) ->and($qwen['requests'])->toBe(2); diff --git a/tests/Feature/Components/IntroTabsTest.php b/tests/Feature/Components/IntroTabsTest.php index 60d1c5a..f0cc2a9 100644 --- a/tests/Feature/Components/IntroTabsTest.php +++ b/tests/Feature/Components/IntroTabsTest.php @@ -185,7 +185,13 @@ function introPanel(string $html, int $index): string }); it('lets the panel height follow the content on mobile and freezes it on desktop', function () { - $intro = Str::after(file_get_contents(resource_path('css/app.css')), '.intro-tabs__panels'); + $css = file_get_contents(resource_path('css/app.css')); + + if ($css === false) { + throw new RuntimeException('Unable to read resources/css/app.css'); + } + + $intro = Str::after($css, '.intro-tabs__panels'); $mobile = Str::before($intro, '@media'); $desktop = Str::after($intro, '@media (width >= 40rem)');