Skip to content

Commit e48be7b

Browse files
committed
refactor to use first-class callables
Signed-off-by: Pushpak Chhajed <[email protected]>
1 parent 707c749 commit e48be7b

File tree

10 files changed

+13
-16
lines changed

10 files changed

+13
-16
lines changed

rector.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
66
use Rector\Config\RectorConfig;
77
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
8-
use Rector\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector;
98
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
109

1110
return RectorConfig::configure()
@@ -17,13 +16,11 @@
1716
ReadOnlyPropertyRector::class,
1817
EncapsedStringsToSprintfRector::class,
1918
DisallowedEmptyRuleFixerRector::class,
20-
BooleanInBooleanNotRuleFixerRector::class,
2119
])
2220
->withPreparedSets(
2321
deadCode: true,
2422
codeQuality: true,
2523
codingStyle: true,
2624
typeDeclarations: true,
2725
earlyReturn: true,
28-
strictBooleans: true,
2926
)->withPhpSets(php81: true);

src/BoostServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function boot(Router $router): void
7373

7474
if (config('boost.browser_logs_watcher', true)) {
7575
$this->registerBrowserLogger();
76-
$this->callAfterResolving('blade.compiler', fn (BladeCompiler $bladeCompiler) => $this->registerBladeDirectives($bladeCompiler));
76+
$this->callAfterResolving('blade.compiler', $this->registerBladeDirectives(...));
7777
$this->hookIntoResponses($router);
7878
}
7979
}

src/Install/CodeEnvironmentsDetector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ public function discoverProjectInstalledCodeEnvironments(string $basePath): arra
5555
public function getCodeEnvironments(): Collection
5656
{
5757
return collect($this->boostManager->getCodeEnvironments())
58-
->map(fn (string $className) => $this->container->make($className));
58+
->map($this->container->make(...)); // @phpstan-ignore argument.type
5959
}
6060
}

src/Install/Detection/DetectionStrategyFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function make(string|array $type, array $config = []): DetectionStrategy
2222
{
2323
if (is_array($type)) {
2424
return new CompositeDetectionStrategy(
25-
array_map(fn ($singleType): \Laravel\Boost\Install\Contracts\DetectionStrategy => $this->make($singleType, $config), $type)
25+
array_map(fn (string|array $singleType): \Laravel\Boost\Install\Contracts\DetectionStrategy => $this->make($singleType, $config), $type)
2626
);
2727
}
2828

src/Install/GuidelineComposer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ protected function guideline(string $path, bool $thirdParty = false): array
311311

312312
protected function processBoostSnippets(string $content): string
313313
{
314-
return preg_replace_callback('/(?<!@)@boostsnippet\(\s*(?P<nameQuote>[\'"])(?P<name>[^\1]*?)\1(?:\s*,\s*(?P<langQuote>[\'"])(?P<lang>[^\3]*?)\3)?\s*\)(?P<content>.*?)@endboostsnippet/s', function ($matches): string {
314+
return preg_replace_callback('/(?<!@)@boostsnippet\(\s*(?P<nameQuote>[\'"])(?P<name>[^\1]*?)\1(?:\s*,\s*(?P<langQuote>[\'"])(?P<lang>[^\3]*?)\3)?\s*\)(?P<content>.*?)@endboostsnippet/s', function (array $matches): string {
315315
$name = $matches['name'];
316316
$lang = empty($matches['lang']) ? 'html' : $matches['lang'];
317317
$snippetContent = $matches['content'];

src/Mcp/Tools/DatabaseSchema/MySQLSchemaDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function getFunctions(): array
4343
public function getTriggers(?string $table = null): array
4444
{
4545
try {
46-
if ($table !== null && $table !== '' && $table !== '0') {
46+
if (! in_array($table, [null, '', '0'], true)) {
4747
return DB::connection($this->connection)->select('SHOW TRIGGERS WHERE `Table` = ?', [$table]);
4848
}
4949

src/Mcp/Tools/DatabaseSchema/PostgreSQLSchemaDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function getTriggers(?string $table = null): array
6060
FROM information_schema.triggers
6161
WHERE trigger_schema = current_schema()
6262
';
63-
if ($table !== null && $table !== '' && $table !== '0') {
63+
if (! in_array($table, [null, '', '0'], true)) {
6464
$sql .= ' AND event_object_table = ?';
6565

6666
return DB::connection($this->connection)->select($sql, [$table]);

src/Mcp/Tools/DatabaseSchema/SQLiteSchemaDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function getTriggers(?string $table = null): array
3636
{
3737
try {
3838
$sql = "SELECT name, sql FROM sqlite_master WHERE type = 'trigger'";
39-
if ($table !== null && $table !== '' && $table !== '0') {
39+
if (! in_array($table, [null, '', '0'], true)) {
4040
$sql .= ' AND tbl_name = ?';
4141

4242
return DB::connection($this->connection)->select($sql, [$table]);

src/Support/Composer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static function packagesDirectories(): array
1313
base_path('vendor'),
1414
str_replace('/', DIRECTORY_SEPARATOR, $package),
1515
])])
16-
->filter(fn (string $path): bool => is_dir($path))
16+
->filter(is_dir(...))
1717
->toArray();
1818
}
1919

@@ -45,7 +45,7 @@ public static function packagesDirectoriesWithBoostGuidelines(): array
4545
'resources',
4646
'boost',
4747
'guidelines',
48-
]))->filter(fn (string $path): bool => is_dir($path))
48+
]))->filter(is_dir(...))
4949
->toArray();
5050
}
5151
}

tests/Feature/Mcp/ToolExecutorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
->shouldAllowMockingProtectedMethods();
1212
$executor->shouldReceive('buildCommand')
1313
->once()
14-
->andReturnUsing(fn ($toolClass, $arguments): array => buildSubprocessCommand($toolClass, $arguments));
14+
->andReturnUsing(buildSubprocessCommand(...));
1515

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

@@ -42,7 +42,7 @@
4242
$executor = Mockery::mock(ToolExecutor::class)->makePartial()
4343
->shouldAllowMockingProtectedMethods();
4444
$executor->shouldReceive('buildCommand')
45-
->andReturnUsing(fn ($toolClass, $arguments): array => buildSubprocessCommand($toolClass, $arguments));
45+
->andReturnUsing(buildSubprocessCommand(...));
4646

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

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

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

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

0 commit comments

Comments
 (0)