Skip to content
Open
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
7 changes: 4 additions & 3 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
use Rector\CodingStyle\Rector\FunctionLike\FunctionLikeToFirstClassCallableRector;
use Rector\Config\RectorConfig;
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
use Rector\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector;
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;

return RectorConfig::configure()
Expand All @@ -17,13 +17,14 @@
ReadOnlyPropertyRector::class,
EncapsedStringsToSprintfRector::class,
DisallowedEmptyRuleFixerRector::class,
BooleanInBooleanNotRuleFixerRector::class,
FunctionLikeToFirstClassCallableRector::class => [
__DIR__.'src/Install/CodeEnvironmentsDetector.php',
],
])
->withPreparedSets(
deadCode: true,
codeQuality: true,
codingStyle: true,
typeDeclarations: true,
earlyReturn: true,
strictBooleans: true,
)->withPhpSets(php81: true);
2 changes: 1 addition & 1 deletion src/BoostServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function boot(Router $router): void

if (config('boost.browser_logs_watcher', true)) {
$this->registerBrowserLogger();
$this->callAfterResolving('blade.compiler', fn (BladeCompiler $bladeCompiler) => $this->registerBladeDirectives($bladeCompiler));
$this->callAfterResolving('blade.compiler', $this->registerBladeDirectives(...));
$this->hookIntoResponses($router);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Install/Cli/DisplayHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static function grid(array $items, int $maxWidth = 80): void
}

$maxWidth -= 2; // account for grid margins
$maxItemLength = max(array_map('mb_strlen', $items));
$maxItemLength = max(array_map(mb_strlen(...), $items));
$cellWidth = $maxItemLength + self::GRID_CELL_PADDING;
$cellsPerRow = max(1, (int) floor(($maxWidth - 1) / ($cellWidth + 1)));
$rows = array_chunk($items, $cellsPerRow);
Expand Down
2 changes: 1 addition & 1 deletion src/Install/Detection/DetectionStrategyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function make(string|array $type, array $config = []): DetectionStrategy
{
if (is_array($type)) {
return new CompositeDetectionStrategy(
array_map(fn ($singleType): \Laravel\Boost\Install\Contracts\DetectionStrategy => $this->make($singleType, $config), $type)
array_map(fn (string|array $singleType): \Laravel\Boost\Install\Contracts\DetectionStrategy => $this->make($singleType, $config), $type)
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Mcp/Tools/DatabaseSchema/MySQLSchemaDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getFunctions(): array
public function getTriggers(?string $table = null): array
{
try {
if ($table !== null && $table !== '' && $table !== '0') {
if (! in_array($table, [null, '', '0'], true)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this in three places, feels like there's a helper method here?

return DB::connection($this->connection)->select('SHOW TRIGGERS WHERE `Table` = ?', [$table]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Mcp/Tools/DatabaseSchema/PostgreSQLSchemaDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function getTriggers(?string $table = null): array
FROM information_schema.triggers
WHERE trigger_schema = current_schema()
';
if ($table !== null && $table !== '' && $table !== '0') {
if (! in_array($table, [null, '', '0'], true)) {
$sql .= ' AND event_object_table = ?';

return DB::connection($this->connection)->select($sql, [$table]);
Expand Down
2 changes: 1 addition & 1 deletion src/Mcp/Tools/DatabaseSchema/SQLiteSchemaDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function getTriggers(?string $table = null): array
{
try {
$sql = "SELECT name, sql FROM sqlite_master WHERE type = 'trigger'";
if ($table !== null && $table !== '' && $table !== '0') {
if (! in_array($table, [null, '', '0'], true)) {
$sql .= ' AND tbl_name = ?';

return DB::connection($this->connection)->select($sql, [$table]);
Expand Down
2 changes: 1 addition & 1 deletion src/Mcp/Tools/ListAvailableEnvVars.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function handle(Request $request): Response
return Response::error('Failed to parse .env file');
}

$envVars = array_map('trim', $matches[1]);
$envVars = array_map(trim(...), $matches[1]);

sort($envVars);

Expand Down
2 changes: 1 addition & 1 deletion src/Mcp/Tools/SearchDocs.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function handle(Request $request): Response|Generator
$packagesFilter = $request->get('packages');

$queries = array_filter(
array_map('trim', $request->get('queries')),
array_map(trim(...), $request->get('queries')),
fn (string $query): bool => $query !== '' && $query !== '*'
);

Expand Down
4 changes: 2 additions & 2 deletions src/Support/Composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static function packagesDirectories(): array
base_path('vendor'),
str_replace('/', DIRECTORY_SEPARATOR, $package),
])])
->filter(fn (string $path): bool => is_dir($path))
->filter(is_dir(...))
->toArray();
}

Expand Down Expand Up @@ -45,7 +45,7 @@ public static function packagesDirectoriesWithBoostGuidelines(): array
'resources',
'boost',
'guidelines',
]))->filter(fn (string $path): bool => is_dir($path))
]))->filter(is_dir(...))
->toArray();
}
}
8 changes: 4 additions & 4 deletions tests/Feature/Mcp/ToolExecutorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
->shouldAllowMockingProtectedMethods();
$executor->shouldReceive('buildCommand')
->once()
->andReturnUsing(fn ($toolClass, $arguments): array => buildSubprocessCommand($toolClass, $arguments));
->andReturnUsing(buildSubprocessCommand(...));

$response = $executor->execute(GetConfig::class, ['key' => 'app.name']);

Expand Down Expand Up @@ -42,7 +42,7 @@
$executor = Mockery::mock(ToolExecutor::class)->makePartial()
->shouldAllowMockingProtectedMethods();
$executor->shouldReceive('buildCommand')
->andReturnUsing(fn ($toolClass, $arguments): array => buildSubprocessCommand($toolClass, $arguments));
->andReturnUsing(buildSubprocessCommand(...));

$response1 = $executor->execute(Tinker::class, ['code' => 'return getmypid();']);
$response2 = $executor->execute(Tinker::class, ['code' => 'return getmypid();']);
Expand All @@ -62,7 +62,7 @@
$executor = Mockery::mock(ToolExecutor::class)->makePartial()
->shouldAllowMockingProtectedMethods();
$executor->shouldReceive('buildCommand')
->andReturnUsing(fn ($toolClass, $arguments): array => buildSubprocessCommand($toolClass, $arguments));
->andReturnUsing(buildSubprocessCommand(...));

// Path to the GetConfig tool that we'll temporarily modify
// TODO: Improve for parallelisation
Expand Down Expand Up @@ -136,7 +136,7 @@ function buildSubprocessCommand(string $toolClass, array $arguments): array
->shouldAllowMockingProtectedMethods();

$executor->shouldReceive('buildCommand')
->andReturnUsing(fn ($toolClass, $arguments): array => buildSubprocessCommand($toolClass, $arguments));
->andReturnUsing(buildSubprocessCommand(...));

// Test with custom timeout - should succeed with fast code
$response = $executor->execute(Tinker::class, [
Expand Down