From 0e89f57588b4004160a5869d67fb2a0ae6875cfb Mon Sep 17 00:00:00 2001 From: Andrey Helldar Date: Sat, 6 Sep 2025 17:35:11 +0300 Subject: [PATCH] Updated access modifiers from `private` to `protected` across multiple files --- src/BoostServiceProvider.php | 14 +++---- src/Concerns/ReadsLogs.php | 12 +++--- src/Console/InstallCommand.php | 42 +++++++++---------- .../Detection/DetectionStrategyFactory.php | 2 +- .../Detection/DirectoryDetectionStrategy.php | 4 +- src/Install/GuidelineAssist.php | 2 +- src/Install/GuidelineComposer.php | 2 +- src/Install/GuidelineWriter.php | 2 +- src/Mcp/Tools/ListAvailableConfigKeys.php | 2 +- src/Mcp/Tools/ListRoutes.php | 2 +- src/Middleware/InjectBoost.php | 4 +- 11 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/BoostServiceProvider.php b/src/BoostServiceProvider.php index a0d53219..16e5f250 100644 --- a/src/BoostServiceProvider.php +++ b/src/BoostServiceProvider.php @@ -76,7 +76,7 @@ public function boot(Router $router): void } } - private function registerPublishing(): void + protected function registerPublishing(): void { if ($this->app->runningInConsole()) { $this->publishes([ @@ -85,7 +85,7 @@ private function registerPublishing(): void } } - private function registerCommands(): void + protected function registerCommands(): void { if ($this->app->runningInConsole()) { $this->commands([ @@ -96,7 +96,7 @@ private function registerCommands(): void } } - private function registerRoutes(): void + protected function registerRoutes(): void { Route::post('/_boost/browser-logs', function (Request $request) { $logs = $request->input('logs', []); @@ -151,7 +151,7 @@ private static function buildLogMessageFromData(array $data): string return implode(' ', $messages); } - private function registerBrowserLogger(): void + protected function registerBrowserLogger(): void { config([ 'logging.channels.browser' => [ @@ -163,7 +163,7 @@ private function registerBrowserLogger(): void ]); } - private function registerBladeDirectives(BladeCompiler $bladeCompiler): void + protected function registerBladeDirectives(BladeCompiler $bladeCompiler): void { $bladeCompiler->directive('boostJs', fn () => ''); } @@ -178,14 +178,14 @@ private static function mapJsTypeToPsr3Level(string $type): string }; } - private function hookIntoResponses(Router $router): void + protected function hookIntoResponses(Router $router): void { $this->app->booted(function () use ($router) { $router->pushMiddlewareToGroup('web', InjectBoost::class); }); } - private function shouldRun(): bool + protected function shouldRun(): bool { if (! config('boost.enabled', true)) { return false; diff --git a/src/Concerns/ReadsLogs.php b/src/Concerns/ReadsLogs.php index b14cf9dd..137f4173 100644 --- a/src/Concerns/ReadsLogs.php +++ b/src/Concerns/ReadsLogs.php @@ -12,27 +12,27 @@ trait ReadsLogs * Regular expression fragments and default chunk-window sizes used when * scanning log files. Declaring them once keeps every consumer in sync. */ - private function getTimestampRegex(): string + protected function getTimestampRegex(): string { return '\\[\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\]'; } - private function getEntrySplitRegex(): string + protected function getEntrySplitRegex(): string { return '/(?='.$this->getTimestampRegex().')/'; } - private function getErrorEntryRegex(): string + protected function getErrorEntryRegex(): string { return '/^'.$this->getTimestampRegex().'.*\\.ERROR:/'; } - private function getChunkSizeStart(): int + protected function getChunkSizeStart(): int { return 64 * 1024; // 64 kB } - private function getChunkSizeMax(): int + protected function getChunkSizeMax(): int { return 1 * 1024 * 1024; // 1 MB } @@ -114,7 +114,7 @@ protected function readLastErrorEntry(string $logFile): ?string * * @return string[] */ - private function scanLogChunkForEntries(string $logFile, int $chunkSize): array + protected function scanLogChunkForEntries(string $logFile, int $chunkSize): array { $fileSize = filesize($logFile); if ($fileSize === false) { diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index c84aa572..78f73f56 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -76,7 +76,7 @@ public function handle(CodeEnvironmentsDetector $codeEnvironmentsDetector, Herd $this->outro(); } - private function bootstrap(CodeEnvironmentsDetector $codeEnvironmentsDetector, Herd $herd, Terminal $terminal): void + protected function bootstrap(CodeEnvironmentsDetector $codeEnvironmentsDetector, Herd $herd, Terminal $terminal): void { $this->codeEnvironmentsDetector = $codeEnvironmentsDetector; $this->herd = $herd; @@ -92,14 +92,14 @@ private function bootstrap(CodeEnvironmentsDetector $codeEnvironmentsDetector, H $this->projectName = config('app.name'); } - private function displayBoostHeader(): void + protected function displayBoostHeader(): void { note($this->boostLogo()); intro('✦ Laravel Boost :: Install :: We Must Ship ✦'); note("Let's give {$this->bgYellow($this->black($this->bold($this->projectName)))} a Boost"); } - private function boostLogo(): string + protected function boostLogo(): string { return <<<'HEADER' @@ -112,13 +112,13 @@ private function boostLogo(): string HEADER; } - private function discoverEnvironment(): void + protected function discoverEnvironment(): void { $this->systemInstalledCodeEnvironments = $this->codeEnvironmentsDetector->discoverSystemInstalledCodeEnvironments(); $this->projectInstalledCodeEnvironments = $this->codeEnvironmentsDetector->discoverProjectInstalledCodeEnvironments(base_path()); } - private function collectInstallationPreferences(): void + protected function collectInstallationPreferences(): void { $this->selectedBoostFeatures = $this->selectBoostFeatures(); $this->selectedTargetMcpClient = $this->selectTargetMcpClients(); @@ -126,7 +126,7 @@ private function collectInstallationPreferences(): void $this->enforceTests = $this->determineTestEnforcement(ask: false); } - private function performInstallation(): void + protected function performInstallation(): void { $this->installGuidelines(); @@ -137,7 +137,7 @@ private function performInstallation(): void } } - private function discoverTools(): array + protected function discoverTools(): array { $tools = []; $toolDir = implode(DIRECTORY_SEPARATOR, [__DIR__, '..', 'Mcp', 'Tools']); @@ -158,7 +158,7 @@ private function discoverTools(): array return $tools; } - private function outro(): void + protected function outro(): void { $label = 'https://boost.laravel.com/installed'; @@ -188,7 +188,7 @@ private function outro(): void echo $this->black($this->bold($text.$link)).$this->reset(PHP_EOL).$this->reset(PHP_EOL); } - private function hyperlink(string $label, string $url): string + protected function hyperlink(string $label, string $url): string { return "\033]8;;{$url}\007{$label}\033]8;;\033\\"; } @@ -229,7 +229,7 @@ protected function determineTestEnforcement(bool $ask = true): bool /** * @return Collection */ - private function selectBoostFeatures(): Collection + protected function selectBoostFeatures(): Collection { $defaultInstallOptions = ['mcp_server', 'ai_guidelines']; $installOptions = [ @@ -271,7 +271,7 @@ protected function boostToolsToDisable(): array /** * @return Collection */ - private function selectTargetMcpClients(): Collection + protected function selectTargetMcpClients(): Collection { if (! $this->shouldInstallMcp() && ! $this->shouldInstallHerdMcp()) { return collect(); @@ -286,7 +286,7 @@ private function selectTargetMcpClients(): Collection /** * @return Collection */ - private function selectTargetAgents(): Collection + protected function selectTargetAgents(): Collection { if (! $this->shouldInstallAiGuidelines()) { return collect(); @@ -303,7 +303,7 @@ private function selectTargetAgents(): Collection * * @return array{scroll: int, required: bool, displayMethod: string} */ - private function getSelectionConfig(string $contractClass): array + protected function getSelectionConfig(string $contractClass): array { return match ($contractClass) { Agent::class => ['scroll' => 4, 'required' => false, 'displayMethod' => 'agentName'], @@ -315,7 +315,7 @@ private function getSelectionConfig(string $contractClass): array /** * @return Collection */ - private function selectCodeEnvironments(string $contractClass, string $label): Collection + protected function selectCodeEnvironments(string $contractClass, string $label): Collection { $allEnvironments = $this->codeEnvironmentsDetector->getCodeEnvironments(); $config = $this->getSelectionConfig($contractClass); @@ -367,7 +367,7 @@ private function selectCodeEnvironments(string $contractClass, string $label): C return $selectedClasses->map(fn ($className) => $availableEnvironments->first(fn ($env) => get_class($env) === $className)); } - private function installGuidelines(): void + protected function installGuidelines(): void { if (! $this->shouldInstallAiGuidelines()) { return; @@ -435,27 +435,27 @@ private function installGuidelines(): void } } - private function shouldInstallAiGuidelines(): bool + protected function shouldInstallAiGuidelines(): bool { return $this->selectedBoostFeatures->contains('ai_guidelines'); } - private function shouldInstallStyleGuidelines(): bool + protected function shouldInstallStyleGuidelines(): bool { return false; } - private function shouldInstallMcp(): bool + protected function shouldInstallMcp(): bool { return $this->selectedBoostFeatures->contains('mcp_server'); } - private function shouldInstallHerdMcp(): bool + protected function shouldInstallHerdMcp(): bool { return $this->selectedBoostFeatures->contains('herd_mcp'); } - private function installMcpServerConfig(): void + protected function installMcpServerConfig(): void { if (! $this->shouldInstallMcp() && ! $this->shouldInstallHerdMcp()) { return; @@ -545,7 +545,7 @@ private function installMcpServerConfig(): void /** * Is the project actually using localization for their new features? */ - private function detectLocalization(): bool + protected function detectLocalization(): bool { $actuallyUsing = false; diff --git a/src/Install/Detection/DetectionStrategyFactory.php b/src/Install/Detection/DetectionStrategyFactory.php index 09f5a305..93ed260d 100644 --- a/src/Install/Detection/DetectionStrategyFactory.php +++ b/src/Install/Detection/DetectionStrategyFactory.php @@ -41,7 +41,7 @@ public function makeFromConfig(array $config): DetectionStrategy return $this->make($type, $config); } - private function inferTypeFromConfig(array $config): string|array + protected function inferTypeFromConfig(array $config): string|array { $typeMap = [ 'files' => self::TYPE_FILE, diff --git a/src/Install/Detection/DirectoryDetectionStrategy.php b/src/Install/Detection/DirectoryDetectionStrategy.php index 6c8ec184..65e89c86 100644 --- a/src/Install/Detection/DirectoryDetectionStrategy.php +++ b/src/Install/Detection/DirectoryDetectionStrategy.php @@ -38,7 +38,7 @@ public function detect(array $config, ?Platform $platform = null): bool return false; } - private function expandPath(string $path, ?Platform $platform = null): string + protected function expandPath(string $path, ?Platform $platform = null): string { if ($platform === Platform::Windows) { return preg_replace_callback('/%([^%]+)%/', function ($matches) { @@ -56,7 +56,7 @@ private function expandPath(string $path, ?Platform $platform = null): string return $path; } - private function isAbsolutePath(string $path): bool + protected function isAbsolutePath(string $path): bool { return str_starts_with($path, '/') || str_starts_with($path, '\\') || diff --git a/src/Install/GuidelineAssist.php b/src/Install/GuidelineAssist.php index 193a9897..eee24d4f 100644 --- a/src/Install/GuidelineAssist.php +++ b/src/Install/GuidelineAssist.php @@ -59,7 +59,7 @@ public function enums(): array * * @return array */ - private function discover(callable $cb): array + protected function discover(callable $cb): array { $classes = []; $appPath = app_path(); diff --git a/src/Install/GuidelineComposer.php b/src/Install/GuidelineComposer.php index 85a06e30..c4f60724 100644 --- a/src/Install/GuidelineComposer.php +++ b/src/Install/GuidelineComposer.php @@ -247,7 +247,7 @@ protected function guideline(string $path): array private array $storedSnippets = []; - private function processBoostSnippets(string $content): string + protected function processBoostSnippets(string $content): string { return preg_replace_callback('/(?[\'"])(?P[^\1]*?)\1(?:\s*,\s*(?P[\'"])(?P[^\3]*?)\3)?\s*\)(?P.*?)@endboostsnippet/s', function ($matches) { $name = $matches['name']; diff --git a/src/Install/GuidelineWriter.php b/src/Install/GuidelineWriter.php index 13f828fb..371bd154 100644 --- a/src/Install/GuidelineWriter.php +++ b/src/Install/GuidelineWriter.php @@ -88,7 +88,7 @@ public function write(string $guidelines): int return $replaced ? self::REPLACED : self::NEW; } - private function acquireLockWithRetry(mixed $handle, string $filePath, int $maxRetries = 3): void + protected function acquireLockWithRetry(mixed $handle, string $filePath, int $maxRetries = 3): void { $attempts = 0; $delay = 100000; // Start with 100ms in microseconds diff --git a/src/Mcp/Tools/ListAvailableConfigKeys.php b/src/Mcp/Tools/ListAvailableConfigKeys.php index 8e8bc3f7..2b42f2bf 100644 --- a/src/Mcp/Tools/ListAvailableConfigKeys.php +++ b/src/Mcp/Tools/ListAvailableConfigKeys.php @@ -41,7 +41,7 @@ public function handle(array $arguments): ToolResult * @param array> $array * @return array */ - private function flattenToDotNotation(array $array, string $prefix = ''): array + protected function flattenToDotNotation(array $array, string $prefix = ''): array { $results = []; diff --git a/src/Mcp/Tools/ListRoutes.php b/src/Mcp/Tools/ListRoutes.php index a1baf04c..12cd5339 100644 --- a/src/Mcp/Tools/ListRoutes.php +++ b/src/Mcp/Tools/ListRoutes.php @@ -84,7 +84,7 @@ public function handle(array $arguments): ToolResult /** * @param array $options */ - private function artisan(string $command, array $options = []): string + protected function artisan(string $command, array $options = []): string { $output = new BufferedOutput; $result = Artisan::call($command, $options, $output); diff --git a/src/Middleware/InjectBoost.php b/src/Middleware/InjectBoost.php index 5e8201d9..58ed1e28 100644 --- a/src/Middleware/InjectBoost.php +++ b/src/Middleware/InjectBoost.php @@ -34,7 +34,7 @@ public function handle(Request $request, Closure $next): Response return $response; } - private function shouldInject(Response $response): bool + protected function shouldInject(Response $response): bool { $responseTypes = [ StreamedResponse::class, @@ -66,7 +66,7 @@ private function shouldInject(Response $response): bool return true; } - private function injectScript(string $content): string + protected function injectScript(string $content): string { $script = BrowserLogger::getScript();