Skip to content

Commit 5919b50

Browse files
committed
quality: fix phpstan issues
1 parent 40ceb5c commit 5919b50

File tree

14 files changed

+61
-7
lines changed

14 files changed

+61
-7
lines changed

src/BoostServiceProvider.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,16 @@ protected function registerCommands(): void
8787
}
8888
}
8989

90-
private function registerRoutes()
90+
private function registerRoutes(): void
9191
{
9292
Route::post('/_boost/browser-logs', function (Request $request) {
9393
$logs = $request->input('logs', []);
94+
/** @var \Illuminate\Log\Logger $logger */
95+
$logger = Log::channel('browser');
9496

95-
/** @var array{type: 'error'|'warn'|'info'|'log'|'table'|'window_error'|'uncaught_error'|'unhandled_rejection', timestamp: string, data: array, url:string, userAgent:string} $log */
97+
/** @var array{type: 'error'|'warn'|'info'|'log'|'table'|'window_error'|'uncaught_error'|'unhandled_rejection', timestamp: string, data: array<mixed>, url:string, userAgent:string} $log */
9698
foreach ($logs as $log) {
97-
Log::channel('browser')->write(
99+
$logger->write(
98100
level: $this->jsTypeToPsr3($log['type']),
99101
message: $this->buildLogMessageFromData($log['data']),
100102
context: [
@@ -112,6 +114,7 @@ private function registerRoutes()
112114
/**
113115
* Build a string message for the log based on various input types. Single dimensional, and multi:
114116
* "data":[{"message":"Unhandled Promise Rejection","reason":{"name":"TypeError","message":"NetworkError when attempting to fetch resource.","stack":""}}]
117+
* @param array<mixed> $data
115118
*/
116119
protected function buildLogMessageFromData(array $data): string
117120
{

src/Concerns/MakesHttpRequests.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public function get(string $url): Response
2929
return $this->client()->get($url);
3030
}
3131

32+
/**
33+
* @param array<string, mixed> $json
34+
*/
3235
public function json(string $url, array $json): Response
3336
{
3437
return $this->client()->asJson()->post($url, $json);

src/Console/InstallCommand.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ private function intro()
227227
$this->line(' Let\'s give '.$this->colors->bgYellow($this->colors->black($this->projectName)).' a Boost');
228228
}
229229

230-
private function outro()
230+
private function outro(): void
231231
{
232232
// TODO: Pass info to /installed on what we did so it can show specific help
233233
$text = 'Enjoy the boost 🚀 https://boost.laravel.com/installed';
@@ -270,6 +270,9 @@ protected function shouldEnforceTests(bool $ask = true): bool
270270
return $enforce;
271271
}
272272

273+
/**
274+
* @return array<int, string>
275+
*/
273276
protected function boostToInstall(): array
274277
{
275278
$defaultToInstallOptions = ['mcp_server', 'ai_guidelines'];
@@ -293,6 +296,9 @@ protected function boostToInstall(): array
293296
);
294297
}
295298

299+
/**
300+
* @return array<int, string>
301+
*/
296302
protected function boostToolsToDisable(): array
297303
{
298304
return multiselect(
@@ -303,6 +309,9 @@ protected function boostToolsToDisable(): array
303309
);
304310
}
305311

312+
/**
313+
* @return array<int, string>
314+
*/
306315
protected function detectProjectAgents(): array
307316
{
308317
$agents = [];
@@ -520,7 +529,7 @@ protected function publishAndUpdateConfig(): void
520529
// Publish config if it doesn't exist
521530
if (! file_exists($configPath)) {
522531
$this->newLine();
523-
$this->info('Publishing Boost configuration file...');
532+
$this->info(' Publishing Boost configuration file...');
524533

525534
Artisan::call('vendor:publish', [
526535
'--provider' => 'Laravel\\Boost\\BoostServiceProvider',
@@ -637,6 +646,7 @@ protected function detectLocalization(): bool
637646
{
638647
$actuallyUsing = false;
639648

649+
/** @phpstan-ignore-next-line */
640650
return is_dir(base_path('lang')) && $actuallyUsing;
641651
}
642652
}

src/Contracts/Ide.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@ interface Ide
77
{
88
// Things to note: supports relative (absolute path required)? global mcp only? Prefer local file, but if global only we have to add the project name to the server name
99

10+
/**
11+
* @param array<int, string> $args
12+
* @param array<string, string> $env
13+
*/
1014
public function installMcp(string $key, string $command, array $args = [], array $env = []): bool;
1115
}

src/Install/Agents/FileMcpIde.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ public function mcpPath(): string
1313
throw new \Exception('Override me');
1414
}
1515

16+
/**
17+
* @param array<int, string> $args
18+
* @param array<string, string> $env
19+
*/
1620
public function installMcp(string $key, string $command, array $args = [], array $env = []): bool
1721
{
1822
$path = $this->mcpPath();

src/Install/Agents/ShellMcpIde.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ abstract class ShellMcpIde implements Ide
99
{
1010
protected string $shellCommand = 'echo "{command} {args} {env}"';
1111

12+
/**
13+
* @param array<int, string> $args
14+
* @param array<string, string> $env
15+
*/
1216
public function installMcp(string $key, string $command, array $args = [], array $env = []): bool
1317
{
1418
// -e, --env <env...> Set environment variables (e.g. -e KEY=value)

src/Install/Cli/DisplayHelper.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
class DisplayHelper
66
{
7+
/**
8+
* @param array<int, array<int|string, mixed>> $data
9+
*/
710
public static function datatable(array $data, int $cols = 80): void
811
{
912
if (empty($data)) {
@@ -90,6 +93,9 @@ public static function datatable(array $data, int $cols = 80): void
9093
echo $bottomBorder.PHP_EOL;
9194
}
9295

96+
/**
97+
* @param array<int, string> $items
98+
*/
9399
public static function grid(array $items, int $cols = 80): void
94100
{
95101
if (empty($items)) {

src/Install/GuidelineComposer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class GuidelineComposer
1414

1515
protected string $userGuidelineDir = '.ai/guidelines';
1616

17+
/** @var Collection<string, string> */
1718
protected Collection $guidelines;
1819

1920
protected GuidelineConfig $config;
@@ -48,6 +49,9 @@ public function used(): array
4849
return $this->guidelines()->keys()->toArray();
4950
}
5051

52+
/**
53+
* @return Collection<string, string>
54+
*/
5155
public function guidelines(): Collection
5256
{
5357
if (! empty($this->guidelines)) {
@@ -125,7 +129,7 @@ protected function find(): Collection
125129
}
126130

127131
/**
128-
* @return \Illuminate\Support\Collection<\Symfony\Component\Finder\SplFileInfo $file>
132+
* @return Collection<string, \Symfony\Component\Finder\SplFileInfo>
129133
*/
130134
protected function guidelineFilesInDir(string $dirPath): Collection
131135
{

src/Mcp/Methods/CallToolWithExecutor.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Laravel\Mcp\Server\Contracts\Methods\Method;
1111
use Laravel\Mcp\Server\ServerContext;
1212
use Laravel\Mcp\Server\Tools\ToolResult;
13+
use Laravel\Mcp\Server\Transport\JsonRpcNotification;
1314
use Laravel\Mcp\Server\Transport\JsonRpcRequest;
1415
use Laravel\Mcp\Server\Transport\JsonRpcResponse;
1516

src/Mcp/ToolExecutor.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function __construct()
1818

1919
/**
2020
* Execute a tool with the given arguments
21+
* @param array<string, mixed> $arguments
2122
*/
2223
public function execute(string $toolClass, array $arguments = []): ToolResult
2324
{
@@ -34,6 +35,7 @@ public function execute(string $toolClass, array $arguments = []): ToolResult
3435

3536
/**
3637
* Execute tool in a separate process for isolation
38+
* @param array<string, mixed> $arguments
3739
*/
3840
protected function executeInProcess(string $toolClass, array $arguments): ToolResult
3941
{
@@ -75,6 +77,7 @@ protected function executeInProcess(string $toolClass, array $arguments): ToolRe
7577

7678
/**
7779
* Execute tool inline (current process)
80+
* @param array<string, mixed> $arguments
7881
*/
7982
protected function executeInline(string $toolClass, array $arguments): ToolResult
8083
{
@@ -110,6 +113,7 @@ protected function getTimeout(): int
110113

111114
/**
112115
* Reconstruct a ToolResult from JSON data
116+
* @param array<string, mixed> $data
113117
*/
114118
protected function reconstructToolResult(array $data): ToolResult
115119
{

0 commit comments

Comments
 (0)