From e8c3a78b4ddf1345f27c85903c1f1cd09a37d76a Mon Sep 17 00:00:00 2001 From: QWp6t Date: Sun, 25 Jun 2023 12:12:27 -0700 Subject: [PATCH 01/48] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Laravel=20v10?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 36 +- src/Illuminate/Foundation/Application.php | 137 ++++- .../Auth/EmailVerificationRequest.php | 3 +- .../Foundation/Bootstrap/HandleExceptions.php | 22 +- .../Foundation/Bus/Dispatchable.php | 12 - .../Foundation/Bus/DispatchesJobs.php | 19 +- .../Concerns/ResolvesDumpSource.php | 4 +- .../Foundation/Console/AboutCommand.php | 11 - .../Foundation/Console/CastMakeCommand.php | 11 - .../Foundation/Console/ChannelListCommand.php | 151 +++++ .../Foundation/Console/ChannelMakeCommand.php | 11 - .../Console/ClearCompiledCommand.php | 11 - .../Console/ComponentMakeCommand.php | 11 - .../Foundation/Console/ConfigCacheCommand.php | 13 +- .../Foundation/Console/ConfigClearCommand.php | 11 - .../Foundation/Console/ConsoleMakeCommand.php | 18 +- .../Foundation/Console/DocsCommand.php | 15 +- .../Foundation/Console/DownCommand.php | 13 +- .../Foundation/Console/EnvironmentCommand.php | 11 - .../Console/EnvironmentDecryptCommand.php | 11 - .../Console/EnvironmentEncryptCommand.php | 11 - .../Foundation/Console/EventCacheCommand.php | 11 - .../Foundation/Console/EventClearCommand.php | 11 - .../Console/EventGenerateCommand.php | 11 - .../Foundation/Console/EventListCommand.php | 13 +- .../Foundation/Console/EventMakeCommand.php | 11 - .../Console/ExceptionMakeCommand.php | 11 - .../Foundation/Console/JobMakeCommand.php | 11 - src/Illuminate/Foundation/Console/Kernel.php | 51 +- .../Foundation/Console/KeyGenerateCommand.php | 11 - .../Foundation/Console/LangPublishCommand.php | 57 ++ .../Console/ListenerMakeCommand.php | 11 - .../Foundation/Console/MailMakeCommand.php | 11 - .../Foundation/Console/ModelMakeCommand.php | 11 - .../Console/NotificationMakeCommand.php | 11 - .../Console/ObserverMakeCommand.php | 11 - .../Console/OptimizeClearCommand.php | 11 - .../Foundation/Console/OptimizeCommand.php | 11 - .../Console/PackageDiscoverCommand.php | 11 - .../Foundation/Console/PolicyMakeCommand.php | 11 - .../Console/ProviderMakeCommand.php | 11 - .../Foundation/Console/RequestMakeCommand.php | 11 - .../Console/ResourceMakeCommand.php | 11 - .../Foundation/Console/RouteCacheCommand.php | 13 +- .../Foundation/Console/RouteClearCommand.php | 11 - .../Foundation/Console/RouteListCommand.php | 11 - .../Foundation/Console/RuleMakeCommand.php | 24 +- .../Foundation/Console/ScopeMakeCommand.php | 11 - .../Foundation/Console/ServeCommand.php | 19 +- .../Foundation/Console/ShowModelCommand.php | 547 ------------------ .../Foundation/Console/StorageLinkCommand.php | 11 - .../Foundation/Console/StubPublishCommand.php | 11 - .../Foundation/Console/TestMakeCommand.php | 11 - .../Foundation/Console/UpCommand.php | 11 - .../Console/VendorPublishCommand.php | 11 - .../Foundation/Console/ViewCacheCommand.php | 11 - .../Foundation/Console/ViewClearCommand.php | 11 - .../Console/stubs/cast.inbound.stub | 9 +- .../Foundation/Console/stubs/cast.stub | 17 +- .../Foundation/Console/stubs/channel.stub | 7 +- .../Foundation/Console/stubs/console.stub | 4 +- .../Foundation/Console/stubs/event.stub | 10 +- .../stubs/exception-render-report.stub | 11 +- .../Console/stubs/exception-render.stub | 7 +- .../Console/stubs/exception-report.stub | 4 +- .../Foundation/Console/stubs/job.queued.stub | 6 +- .../Foundation/Console/stubs/job.stub | 6 +- .../Console/stubs/listener-duck.stub | 7 +- .../Console/stubs/listener-queued-duck.stub | 7 +- .../Console/stubs/listener-queued.stub | 7 +- .../Foundation/Console/stubs/listener.stub | 7 +- .../Foundation/Console/stubs/mail.stub | 14 +- .../Console/stubs/markdown-mail.stub | 14 +- .../Console/stubs/markdown-notification.stub | 17 +- .../Console/stubs/notification.stub | 17 +- .../Foundation/Console/stubs/observer.stub | 25 +- .../Console/stubs/policy.plain.stub | 5 - .../Foundation/Console/stubs/policy.stub | 44 +- .../Foundation/Console/stubs/provider.stub | 8 +- .../Foundation/Console/stubs/request.stub | 8 +- .../Console/stubs/resource-collection.stub | 6 +- .../Foundation/Console/stubs/resource.stub | 6 +- ...kable.implicit.stub => rule.implicit.stub} | 10 +- .../Console/stubs/rule.invokable.stub | 21 - .../Foundation/Console/stubs/rule.stub | 33 +- .../Foundation/Console/stubs/scope.stub | 6 +- .../Foundation/Console/stubs/test.stub | 4 +- .../Foundation/Console/stubs/test.unit.stub | 4 +- .../Console/stubs/view-component.stub | 8 +- .../Foundation/Events/DiscoverEvents.php | 2 +- .../Foundation/Exceptions/Handler.php | 31 +- .../Exceptions/MaintenanceModeException.php | 58 -- .../Foundation/Http/FormRequest.php | 7 + src/Illuminate/Foundation/Http/Kernel.php | 28 +- .../Middleware/HandlePrecognitiveRequests.php | 1 - .../Http/Middleware/VerifyCsrfToken.php | 2 +- src/Illuminate/Foundation/Precognition.php | 2 +- .../Providers/ArtisanServiceProvider.php | 8 +- .../PrecognitionCallableDispatcher.php | 2 +- .../PrecognitionControllerDispatcher.php | 2 +- .../Support/Providers/AuthServiceProvider.php | 12 + .../Providers/EventServiceProvider.php | 2 +- .../Concerns/InteractsWithContainer.php | 3 + .../Concerns/InteractsWithDatabase.php | 2 +- .../Testing/Concerns/InteractsWithRedis.php | 8 +- .../Testing/Concerns/MakesHttpRequests.php | 35 +- .../Concerns/MocksApplicationServices.php | 289 --------- .../Foundation/Testing/TestCase.php | 56 +- .../Foundation/Testing/WithConsoleEvents.php | 18 + .../Validation/ValidatesRequests.php | 12 +- src/Illuminate/Foundation/helpers.php | 36 +- src/Illuminate/Foundation/stubs/facade.stub | 4 +- src/Roots/Acorn/Application.php | 111 +--- src/Roots/Acorn/Bootloader.php | 2 +- 114 files changed, 697 insertions(+), 1980 deletions(-) create mode 100644 src/Illuminate/Foundation/Console/ChannelListCommand.php create mode 100644 src/Illuminate/Foundation/Console/LangPublishCommand.php delete mode 100644 src/Illuminate/Foundation/Console/ShowModelCommand.php rename src/Illuminate/Foundation/Console/stubs/{rule.invokable.implicit.stub => rule.implicit.stub} (58%) delete mode 100644 src/Illuminate/Foundation/Console/stubs/rule.invokable.stub delete mode 100644 src/Illuminate/Foundation/Http/Exceptions/MaintenanceModeException.php delete mode 100644 src/Illuminate/Foundation/Testing/Concerns/MocksApplicationServices.php create mode 100644 src/Illuminate/Foundation/Testing/WithConsoleEvents.php diff --git a/composer.json b/composer.json index 748e201d..d389539e 100644 --- a/composer.json +++ b/composer.json @@ -43,24 +43,24 @@ "php": "^8.0", "ext-json": "*", "ext-mbstring": "*", - "illuminate/cache": "^9.52", - "illuminate/config": "^9.52", - "illuminate/console": "^9.52", - "illuminate/container": "^9.52", - "illuminate/contracts": "^9.52", - "illuminate/database": "^9.52", - "illuminate/events": "^9.52", - "illuminate/filesystem": "^9.52", - "illuminate/http": "^9.52", - "illuminate/log": "^9.52", - "illuminate/routing": "^9.52", - "illuminate/support": "^9.52", - "illuminate/view": "^9.52", - "league/flysystem": "^3.0", - "ramsey/uuid": "^4.2.2", + "illuminate/cache": "^10.13", + "illuminate/config": "^10.13", + "illuminate/console": "^10.13", + "illuminate/container": "^10.13", + "illuminate/contracts": "^10.13", + "illuminate/database": "^10.13", + "illuminate/events": "^10.13", + "illuminate/filesystem": "^10.13", + "illuminate/http": "^10.13", + "illuminate/log": "^10.13", + "illuminate/routing": "^10.13", + "illuminate/support": "^10.13", + "illuminate/view": "^10.13", + "league/flysystem": "^3.8", + "ramsey/uuid": "^4.7", "roots/support": "^1.0", - "symfony/error-handler": "^6.0", - "symfony/var-dumper": "^6.0", + "symfony/error-handler": "^6.2", + "symfony/var-dumper": "^6.2", "vlucas/phpdotenv": "^5.4.1" }, "require-dev": { @@ -69,7 +69,7 @@ "pestphp/pest-plugin-mock": "^1.0", "phpcompatibility/php-compatibility": "^9.3", "roave/security-advisories": "dev-master", - "spatie/laravel-ignition": "^1.6", + "spatie/laravel-ignition": "^2.1", "spatie/pest-plugin-snapshots": "^1.0", "spatie/temporary-directory": "^2.0", "squizlabs/php_codesniffer": "^3.5", diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index 2d582cd8..09b3387d 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -38,7 +38,7 @@ class Application extends Container implements ApplicationContract, CachesConfig * * @var string */ - const VERSION = '9.52.7'; + const VERSION = '10.13.5'; /** * The base path for the Laravel installation. @@ -103,6 +103,13 @@ class Application extends Container implements ApplicationContract, CachesConfig */ protected $deferredServices = []; + /** + * The custom bootstrap path defined by the developer. + * + * @var string + */ + protected $bootstrapPath; + /** * The custom application path defined by the developer. * @@ -110,6 +117,13 @@ class Application extends Container implements ApplicationContract, CachesConfig */ protected $appPath; + /** + * The custom configuration path defined by the developer. + * + * @var string + */ + protected $configPath; + /** * The custom database path defined by the developer. * @@ -124,6 +138,13 @@ class Application extends Container implements ApplicationContract, CachesConfig */ protected $langPath; + /** + * The custom public / web path defined by the developer. + * + * @var string + */ + protected $publicPath; + /** * The custom storage path defined by the developer. * @@ -207,11 +228,9 @@ protected function registerBaseBindings() $this->instance(Container::class, $this); $this->singleton(Mix::class); - $this->singleton(PackageManifest::class, function () { - return new PackageManifest( - new Filesystem, $this->basePath(), $this->getCachedPackagesPath() - ); - }); + $this->singleton(PackageManifest::class, fn () => new PackageManifest( + new Filesystem, $this->basePath(), $this->getCachedPackagesPath() + )); } /** @@ -317,18 +336,21 @@ protected function bindPathsInContainer() $this->instance('path', $this->path()); $this->instance('path.base', $this->basePath()); $this->instance('path.config', $this->configPath()); - $this->instance('path.public', $this->publicPath()); - $this->instance('path.storage', $this->storagePath()); $this->instance('path.database', $this->databasePath()); + $this->instance('path.public', $this->publicPath()); $this->instance('path.resources', $this->resourcePath()); - $this->instance('path.bootstrap', $this->bootstrapPath()); + $this->instance('path.storage', $this->storagePath()); - $this->useLangPath(value(function () { - if (is_dir($directory = $this->resourcePath('lang'))) { - return $directory; - } + $this->useBootstrapPath(value(function () { + return is_dir($directory = $this->basePath('.laravel')) + ? $directory + : $this->basePath('bootstrap'); + })); - return $this->basePath('lang'); + $this->useLangPath(value(function () { + return is_dir($directory = $this->resourcePath('lang')) + ? $directory + : $this->basePath('lang'); })); } @@ -340,9 +362,7 @@ protected function bindPathsInContainer() */ public function path($path = '') { - $appPath = $this->appPath ?: $this->basePath.DIRECTORY_SEPARATOR.'app'; - - return $appPath.($path != '' ? DIRECTORY_SEPARATOR.$path : ''); + return $this->joinPaths($this->appPath ?: $this->basePath('app'), $path); } /** @@ -368,7 +388,7 @@ public function useAppPath($path) */ public function basePath($path = '') { - return $this->basePath.($path != '' ? DIRECTORY_SEPARATOR.$path : ''); + return $this->joinPaths($this->basePath, $path); } /** @@ -379,7 +399,22 @@ public function basePath($path = '') */ public function bootstrapPath($path = '') { - return $this->basePath.DIRECTORY_SEPARATOR.'bootstrap'.($path != '' ? DIRECTORY_SEPARATOR.$path : ''); + return $this->joinPaths($this->bootstrapPath, $path); + } + + /** + * Set the bootstrap file directory. + * + * @param string $path + * @return $this + */ + public function useBootstrapPath($path) + { + $this->bootstrapPath = $path; + + $this->instance('path.bootstrap', $path); + + return $this; } /** @@ -390,7 +425,22 @@ public function bootstrapPath($path = '') */ public function configPath($path = '') { - return $this->basePath.DIRECTORY_SEPARATOR.'config'.($path != '' ? DIRECTORY_SEPARATOR.$path : ''); + return $this->joinPaths($this->configPath ?: $this->basePath('config'), $path); + } + + /** + * Set the configuration directory. + * + * @param string $path + * @return $this + */ + public function useConfigPath($path) + { + $this->configPath = $path; + + $this->instance('path.config', $path); + + return $this; } /** @@ -401,7 +451,7 @@ public function configPath($path = '') */ public function databasePath($path = '') { - return ($this->databasePath ?: $this->basePath.DIRECTORY_SEPARATOR.'database').($path != '' ? DIRECTORY_SEPARATOR.$path : ''); + return $this->joinPaths($this->databasePath ?: $this->basePath('database'), $path); } /** @@ -427,7 +477,7 @@ public function useDatabasePath($path) */ public function langPath($path = '') { - return $this->langPath.($path != '' ? DIRECTORY_SEPARATOR.$path : ''); + return $this->joinPaths($this->langPath, $path); } /** @@ -448,11 +498,27 @@ public function useLangPath($path) /** * Get the path to the public / web directory. * + * @param string $path * @return string */ - public function publicPath() + public function publicPath($path = '') + { + return $this->joinPaths($this->publicPath ?: $this->basePath('public'), $path); + } + + /** + * Set the public / web directory. + * + * @param string $path + * @return $this + */ + public function usePublicPath($path) { - return $this->basePath.DIRECTORY_SEPARATOR.'public'; + $this->publicPath = $path; + + $this->instance('path.public', $path); + + return $this; } /** @@ -463,8 +529,7 @@ public function publicPath() */ public function storagePath($path = '') { - return ($this->storagePath ?: $this->basePath.DIRECTORY_SEPARATOR.'storage') - .($path != '' ? DIRECTORY_SEPARATOR.$path : ''); + return $this->joinPaths($this->storagePath ?: $this->basePath('storage'), $path); } /** @@ -490,7 +555,7 @@ public function useStoragePath($path) */ public function resourcePath($path = '') { - return $this->basePath.DIRECTORY_SEPARATOR.'resources'.($path != '' ? DIRECTORY_SEPARATOR.$path : ''); + return $this->joinPaths($this->basePath('resources'), $path); } /** @@ -503,9 +568,21 @@ public function resourcePath($path = '') */ public function viewPath($path = '') { - $basePath = $this['config']->get('view.paths')[0]; + $viewPath = rtrim($this['config']->get('view.paths')[0], DIRECTORY_SEPARATOR); - return rtrim($basePath, DIRECTORY_SEPARATOR).($path != '' ? DIRECTORY_SEPARATOR.$path : ''); + return $this->joinPaths($viewPath, $path); + } + + /** + * Join the given paths together. + * + * @param string $basePath + * @param string $path + * @return string + */ + public function joinPaths($basePath, $path = '') + { + return $basePath.($path != '' ? DIRECTORY_SEPARATOR.ltrim($path, DIRECTORY_SEPARATOR) : ''); } /** @@ -1141,7 +1218,7 @@ public function isDownForMaintenance() public function abort($code, $message = '', array $headers = []) { if ($code == 404) { - throw new NotFoundHttpException($message); + throw new NotFoundHttpException($message, null, 0, $headers); } throw new HttpException($code, $message, null, $headers); diff --git a/src/Illuminate/Foundation/Auth/EmailVerificationRequest.php b/src/Illuminate/Foundation/Auth/EmailVerificationRequest.php index 9cbe9b51..ab5fa56c 100644 --- a/src/Illuminate/Foundation/Auth/EmailVerificationRequest.php +++ b/src/Illuminate/Foundation/Auth/EmailVerificationRequest.php @@ -4,6 +4,7 @@ use Illuminate\Auth\Events\Verified; use Illuminate\Foundation\Http\FormRequest; +use Illuminate\Validation\Validator; class EmailVerificationRequest extends FormRequest { @@ -57,7 +58,7 @@ public function fulfill() * @param \Illuminate\Validation\Validator $validator * @return void */ - public function withValidator($validator) + public function withValidator(Validator $validator) { return $validator; } diff --git a/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php b/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php index 393be5c1..ee890cff 100644 --- a/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php +++ b/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php @@ -60,12 +60,11 @@ public function bootstrap(Application $app) * @param string $message * @param string $file * @param int $line - * @param array $context * @return void * * @throws \ErrorException */ - public function handleError($level, $message, $file = '', $line = 0, $context = []) + public function handleError($level, $message, $file = '', $line = 0) { if ($this->isDeprecation($level)) { $this->handleDeprecationError($message, $file, $line, $level); @@ -74,21 +73,6 @@ public function handleError($level, $message, $file = '', $line = 0, $context = } } - /** - * Reports a deprecation to the "deprecations" logger. - * - * @param string $message - * @param string $file - * @param int $line - * @return void - * - * @deprecated Use handleDeprecationError instead. - */ - public function handleDeprecation($message, $file, $line) - { - $this->handleDeprecationError($message, $file, $line); - } - /** * Reports a deprecation to the "deprecations" logger. * @@ -106,7 +90,7 @@ public function handleDeprecationError($message, $file, $line, $level = E_DEPREC try { $logger = static::$app->make(LogManager::class); - } catch (Exception $e) { + } catch (Exception) { return; } @@ -196,7 +180,7 @@ public function handleException(Throwable $e) try { $this->getExceptionHandler()->report($e); - } catch (Exception $e) { + } catch (Exception) { $exceptionHandlerFailed = true; } diff --git a/src/Illuminate/Foundation/Bus/Dispatchable.php b/src/Illuminate/Foundation/Bus/Dispatchable.php index ad471bf8..46b50055 100644 --- a/src/Illuminate/Foundation/Bus/Dispatchable.php +++ b/src/Illuminate/Foundation/Bus/Dispatchable.php @@ -76,18 +76,6 @@ public static function dispatchSync(...$arguments) return app(Dispatcher::class)->dispatchSync(new static(...$arguments)); } - /** - * Dispatch a command to its appropriate handler in the current process. - * - * @return mixed - * - * @deprecated Will be removed in a future Laravel version. - */ - public static function dispatchNow(...$arguments) - { - return app(Dispatcher::class)->dispatchNow(new static(...$arguments)); - } - /** * Dispatch a command to its appropriate handler after the current process. * diff --git a/src/Illuminate/Foundation/Bus/DispatchesJobs.php b/src/Illuminate/Foundation/Bus/DispatchesJobs.php index d5211585..b01ae041 100644 --- a/src/Illuminate/Foundation/Bus/DispatchesJobs.php +++ b/src/Illuminate/Foundation/Bus/DispatchesJobs.php @@ -2,8 +2,6 @@ namespace Illuminate\Foundation\Bus; -use Illuminate\Contracts\Bus\Dispatcher; - trait DispatchesJobs { /** @@ -14,20 +12,7 @@ trait DispatchesJobs */ protected function dispatch($job) { - return app(Dispatcher::class)->dispatch($job); - } - - /** - * Dispatch a job to its appropriate handler in the current process. - * - * @param mixed $job - * @return mixed - * - * @deprecated Will be removed in a future Laravel version. - */ - public function dispatchNow($job) - { - return app(Dispatcher::class)->dispatchNow($job); + return dispatch($job); } /** @@ -40,6 +25,6 @@ public function dispatchNow($job) */ public function dispatchSync($job) { - return app(Dispatcher::class)->dispatchSync($job); + return dispatch_sync($job); } } diff --git a/src/Illuminate/Foundation/Concerns/ResolvesDumpSource.php b/src/Illuminate/Foundation/Concerns/ResolvesDumpSource.php index 7e0dfffa..099a1336 100644 --- a/src/Illuminate/Foundation/Concerns/ResolvesDumpSource.php +++ b/src/Illuminate/Foundation/Concerns/ResolvesDumpSource.php @@ -118,7 +118,7 @@ public function resolveDumpSource() */ protected function isCompiledViewFile($file) { - return str_starts_with($file, $this->compiledViewPath); + return str_starts_with($file, $this->compiledViewPath) && str_ends_with($file, '.php'); } /** @@ -149,7 +149,7 @@ protected function resolveSourceHref($file, $line) { try { $editor = config('app.editor'); - } catch (Throwable $e) { + } catch (Throwable) { // .. } diff --git a/src/Illuminate/Foundation/Console/AboutCommand.php b/src/Illuminate/Foundation/Console/AboutCommand.php index c6a38ce9..1d1b47e9 100644 --- a/src/Illuminate/Foundation/Console/AboutCommand.php +++ b/src/Illuminate/Foundation/Console/AboutCommand.php @@ -18,17 +18,6 @@ class AboutCommand extends Command protected $signature = 'about {--only= : The section to display} {--json : Output the information as JSON}'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'about'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/CastMakeCommand.php b/src/Illuminate/Foundation/Console/CastMakeCommand.php index 27043606..9552472a 100644 --- a/src/Illuminate/Foundation/Console/CastMakeCommand.php +++ b/src/Illuminate/Foundation/Console/CastMakeCommand.php @@ -16,17 +16,6 @@ class CastMakeCommand extends GeneratorCommand */ protected $name = 'make:cast'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'make:cast'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/ChannelListCommand.php b/src/Illuminate/Foundation/Console/ChannelListCommand.php new file mode 100644 index 00000000..dda760a4 --- /dev/null +++ b/src/Illuminate/Foundation/Console/ChannelListCommand.php @@ -0,0 +1,151 @@ +getChannels(); + + if (! $this->laravel->providerIsLoaded('App\Providers\BroadcastServiceProvider') && + file_exists($this->laravel->path('Providers/BroadcastServiceProvider.php'))) { + $this->components->warn('The [App\Providers\BroadcastServiceProvider] has not been loaded. Your private channels may not be loaded.'); + } + + if (! $channels->count()) { + return $this->components->error("Your application doesn't have any private broadcasting channels."); + } + + $this->displayChannels($channels); + } + + /** + * Display the channel information on the console. + * + * @param Collection $channels + * @return void + */ + protected function displayChannels($channels) + { + $this->output->writeln($this->forCli($channels)); + } + + /** + * Convert the given channels to regular CLI output. + * + * @param \Illuminate\Support\Collection $channels + * @return array + */ + protected function forCli($channels) + { + $maxChannelName = $channels->keys()->max(function ($channelName) { + return mb_strlen($channelName); + }); + + $terminalWidth = $this->getTerminalWidth(); + + $channelCount = $this->determineChannelCountOutput($channels, $terminalWidth); + + return $channels->map(function ($channel, $channelName) use ($maxChannelName, $terminalWidth) { + $resolver = $channel instanceof Closure ? 'Closure' : $channel; + + $spaces = str_repeat(' ', max($maxChannelName + 6 - mb_strlen($channelName), 0)); + + $dots = str_repeat('.', max( + $terminalWidth - mb_strlen($channelName.$spaces.$resolver) - 6, 0 + )); + + $dots = empty($dots) ? $dots : " $dots"; + + return sprintf( + ' %s %s%s%s', + $channelName, + $spaces, + $resolver, + $dots, + ); + }) + ->filter() + ->sort() + ->prepend('') + ->push('')->push($channelCount)->push('') + ->toArray(); + } + + /** + * Determine and return the output for displaying the number of registered chanels in the CLI output. + * + * @param \Illuminate\Support\Collection $channels + * @param int $terminalWidth + * @return string + */ + protected function determineChannelCountOutput($channels, $terminalWidth) + { + $channelCountText = 'Showing ['.$channels->count().'] private channels'; + + $offset = $terminalWidth - mb_strlen($channelCountText) - 2; + + $spaces = str_repeat(' ', $offset); + + return $spaces.'Showing ['.$channels->count().'] private channels'; + } + + /** + * Get the terminal width. + * + * @return int + */ + public static function getTerminalWidth() + { + return is_null(static::$terminalWidthResolver) + ? (new Terminal)->getWidth() + : call_user_func(static::$terminalWidthResolver); + } + + /** + * Set a callback that should be used when resolving the terminal width. + * + * @param \Closure|null $resolver + * @return void + */ + public static function resolveTerminalWidthUsing($resolver) + { + static::$terminalWidthResolver = $resolver; + } +} diff --git a/src/Illuminate/Foundation/Console/ChannelMakeCommand.php b/src/Illuminate/Foundation/Console/ChannelMakeCommand.php index 1bc26e85..f5c4e555 100644 --- a/src/Illuminate/Foundation/Console/ChannelMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ChannelMakeCommand.php @@ -16,17 +16,6 @@ class ChannelMakeCommand extends GeneratorCommand */ protected $name = 'make:channel'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'make:channel'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/ClearCompiledCommand.php b/src/Illuminate/Foundation/Console/ClearCompiledCommand.php index 20375ded..d1bd30ef 100644 --- a/src/Illuminate/Foundation/Console/ClearCompiledCommand.php +++ b/src/Illuminate/Foundation/Console/ClearCompiledCommand.php @@ -15,17 +15,6 @@ class ClearCompiledCommand extends Command */ protected $name = 'clear-compiled'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'clear-compiled'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/ComponentMakeCommand.php b/src/Illuminate/Foundation/Console/ComponentMakeCommand.php index e11838c2..c1c095e3 100644 --- a/src/Illuminate/Foundation/Console/ComponentMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ComponentMakeCommand.php @@ -18,17 +18,6 @@ class ComponentMakeCommand extends GeneratorCommand */ protected $name = 'make:component'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'make:component'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/ConfigCacheCommand.php b/src/Illuminate/Foundation/Console/ConfigCacheCommand.php index 18eec46c..1de90e95 100644 --- a/src/Illuminate/Foundation/Console/ConfigCacheCommand.php +++ b/src/Illuminate/Foundation/Console/ConfigCacheCommand.php @@ -19,17 +19,6 @@ class ConfigCacheCommand extends Command */ protected $name = 'config:cache'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'config:cache'; - /** * The console command description. * @@ -94,7 +83,7 @@ public function handle() */ protected function getFreshConfiguration() { - $app = require $this->laravel->bootstrapPath().'/app.php'; + $app = require $this->laravel->bootstrapPath('app.php'); $app->useStoragePath($this->laravel->storagePath()); diff --git a/src/Illuminate/Foundation/Console/ConfigClearCommand.php b/src/Illuminate/Foundation/Console/ConfigClearCommand.php index 3e07e9be..47a97824 100644 --- a/src/Illuminate/Foundation/Console/ConfigClearCommand.php +++ b/src/Illuminate/Foundation/Console/ConfigClearCommand.php @@ -16,17 +16,6 @@ class ConfigClearCommand extends Command */ protected $name = 'config:clear'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'config:clear'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php b/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php index 18f6dd1b..d4e28645 100644 --- a/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php @@ -4,6 +4,7 @@ use Illuminate\Console\Concerns\CreatesMatchingTest; use Illuminate\Console\GeneratorCommand; +use Illuminate\Support\Str; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; @@ -20,17 +21,6 @@ class ConsoleMakeCommand extends GeneratorCommand */ protected $name = 'make:command'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'make:command'; - /** * The console command description. * @@ -56,7 +46,9 @@ protected function replaceClass($stub, $name) { $stub = parent::replaceClass($stub, $name); - return str_replace(['dummy:command', '{{ command }}'], $this->option('command'), $stub); + $command = $this->option('command') ?: 'app:'.Str::of($name)->classBasename()->kebab()->value(); + + return str_replace(['dummy:command', '{{ command }}'], $command, $stub); } /** @@ -105,7 +97,7 @@ protected function getOptions() { return [ ['force', 'f', InputOption::VALUE_NONE, 'Create the class even if the console command already exists'], - ['command', null, InputOption::VALUE_OPTIONAL, 'The terminal command that should be assigned', 'command:name'], + ['command', null, InputOption::VALUE_OPTIONAL, 'The terminal command that will be used to invoke the class'], ]; } } diff --git a/src/Illuminate/Foundation/Console/DocsCommand.php b/src/Illuminate/Foundation/Console/DocsCommand.php index c9651acd..b8f67862 100644 --- a/src/Illuminate/Foundation/Console/DocsCommand.php +++ b/src/Illuminate/Foundation/Console/DocsCommand.php @@ -26,17 +26,6 @@ class DocsCommand extends Command */ protected $signature = 'docs {page? : The documentation page to open} {section? : The section of the page to open}'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'docs'; - /** * The console command description. * @@ -222,7 +211,7 @@ protected function askForPageViaCustomStrategy() { try { $strategy = require Env::get('ARTISAN_DOCS_ASK_STRATEGY'); - } catch (Throwable $e) { + } catch (Throwable) { return null; } @@ -357,7 +346,7 @@ protected function openViaCustomStrategy($url) { try { $command = require Env::get('ARTISAN_DOCS_OPEN_STRATEGY'); - } catch (Throwable $e) { + } catch (Throwable) { $command = null; } diff --git a/src/Illuminate/Foundation/Console/DownCommand.php b/src/Illuminate/Foundation/Console/DownCommand.php index 42aa6b64..25cbce86 100644 --- a/src/Illuminate/Foundation/Console/DownCommand.php +++ b/src/Illuminate/Foundation/Console/DownCommand.php @@ -25,17 +25,6 @@ class DownCommand extends Command {--secret= : The secret phrase that may be used to bypass maintenance mode} {--status=503 : The status code that should be used when returning the maintenance mode response}'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'down'; - /** * The console command description. * @@ -104,7 +93,7 @@ protected function excludedPaths() { try { return $this->laravel->make(PreventRequestsDuringMaintenance::class)->getExcludedPaths(); - } catch (Throwable $e) { + } catch (Throwable) { return []; } } diff --git a/src/Illuminate/Foundation/Console/EnvironmentCommand.php b/src/Illuminate/Foundation/Console/EnvironmentCommand.php index ba74ed98..234d930d 100644 --- a/src/Illuminate/Foundation/Console/EnvironmentCommand.php +++ b/src/Illuminate/Foundation/Console/EnvironmentCommand.php @@ -15,17 +15,6 @@ class EnvironmentCommand extends Command */ protected $name = 'env'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'env'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/EnvironmentDecryptCommand.php b/src/Illuminate/Foundation/Console/EnvironmentDecryptCommand.php index 1e11e110..f3c3fa2c 100644 --- a/src/Illuminate/Foundation/Console/EnvironmentDecryptCommand.php +++ b/src/Illuminate/Foundation/Console/EnvironmentDecryptCommand.php @@ -26,17 +26,6 @@ class EnvironmentDecryptCommand extends Command {--path= : Path to write the decrypted file} {--filename= : Filename of the decrypted file}'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'env:decrypt'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/EnvironmentEncryptCommand.php b/src/Illuminate/Foundation/Console/EnvironmentEncryptCommand.php index e0e9f128..7c7b1113 100644 --- a/src/Illuminate/Foundation/Console/EnvironmentEncryptCommand.php +++ b/src/Illuminate/Foundation/Console/EnvironmentEncryptCommand.php @@ -23,17 +23,6 @@ class EnvironmentEncryptCommand extends Command {--env= : The environment to be encrypted} {--force : Overwrite the existing encrypted environment file}'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'env:encrypt'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/EventCacheCommand.php b/src/Illuminate/Foundation/Console/EventCacheCommand.php index df42fbfd..9039d4c2 100644 --- a/src/Illuminate/Foundation/Console/EventCacheCommand.php +++ b/src/Illuminate/Foundation/Console/EventCacheCommand.php @@ -16,17 +16,6 @@ class EventCacheCommand extends Command */ protected $signature = 'event:cache'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'event:cache'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/EventClearCommand.php b/src/Illuminate/Foundation/Console/EventClearCommand.php index a5c8ed19..966a18bc 100644 --- a/src/Illuminate/Foundation/Console/EventClearCommand.php +++ b/src/Illuminate/Foundation/Console/EventClearCommand.php @@ -16,17 +16,6 @@ class EventClearCommand extends Command */ protected $name = 'event:clear'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'event:clear'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/EventGenerateCommand.php b/src/Illuminate/Foundation/Console/EventGenerateCommand.php index b27e9dbb..5b0857a3 100644 --- a/src/Illuminate/Foundation/Console/EventGenerateCommand.php +++ b/src/Illuminate/Foundation/Console/EventGenerateCommand.php @@ -16,17 +16,6 @@ class EventGenerateCommand extends Command */ protected $name = 'event:generate'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'event:generate'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/EventListCommand.php b/src/Illuminate/Foundation/Console/EventListCommand.php index 1e0e11b8..f97a1c16 100644 --- a/src/Illuminate/Foundation/Console/EventListCommand.php +++ b/src/Illuminate/Foundation/Console/EventListCommand.php @@ -19,17 +19,6 @@ class EventListCommand extends Command */ protected $signature = 'event:list {--event= : Filter the events by name}'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'event:list'; - /** * The console command description. * @@ -210,7 +199,7 @@ protected function getRawListeners() /** * Get the event dispatcher. * - * @return Illuminate\Events\Dispatcher + * @return \Illuminate\Events\Dispatcher */ public function getEventsDispatcher() { diff --git a/src/Illuminate/Foundation/Console/EventMakeCommand.php b/src/Illuminate/Foundation/Console/EventMakeCommand.php index 94f96b5e..cdecc89f 100644 --- a/src/Illuminate/Foundation/Console/EventMakeCommand.php +++ b/src/Illuminate/Foundation/Console/EventMakeCommand.php @@ -16,17 +16,6 @@ class EventMakeCommand extends GeneratorCommand */ protected $name = 'make:event'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'make:event'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/ExceptionMakeCommand.php b/src/Illuminate/Foundation/Console/ExceptionMakeCommand.php index 54b24d6f..7cf7faaf 100644 --- a/src/Illuminate/Foundation/Console/ExceptionMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ExceptionMakeCommand.php @@ -16,17 +16,6 @@ class ExceptionMakeCommand extends GeneratorCommand */ protected $name = 'make:exception'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'make:exception'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/JobMakeCommand.php b/src/Illuminate/Foundation/Console/JobMakeCommand.php index 901fff21..39236c8e 100644 --- a/src/Illuminate/Foundation/Console/JobMakeCommand.php +++ b/src/Illuminate/Foundation/Console/JobMakeCommand.php @@ -19,17 +19,6 @@ class JobMakeCommand extends GeneratorCommand */ protected $name = 'make:job'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'make:job'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/Kernel.php b/src/Illuminate/Foundation/Console/Kernel.php index e9c12616..334b3a40 100644 --- a/src/Illuminate/Foundation/Console/Kernel.php +++ b/src/Illuminate/Foundation/Console/Kernel.php @@ -7,6 +7,8 @@ use DateTimeInterface; use Illuminate\Console\Application as Artisan; use Illuminate\Console\Command; +use Illuminate\Console\Events\CommandFinished; +use Illuminate\Console\Events\CommandStarting; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Contracts\Console\Kernel as KernelContract; use Illuminate\Contracts\Debug\ExceptionHandler; @@ -18,6 +20,10 @@ use Illuminate\Support\InteractsWithTime; use Illuminate\Support\Str; use ReflectionClass; +use Symfony\Component\Console\ConsoleEvents; +use Symfony\Component\Console\Event\ConsoleCommandEvent; +use Symfony\Component\Console\Event\ConsoleTerminateEvent; +use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Finder\Finder; use Throwable; @@ -39,6 +45,13 @@ class Kernel implements KernelContract */ protected $events; + /** + * The Symfony event dispatcher implementation. + * + * @var \Symfony\Contracts\EventDispatcher\EventDispatcherInterface|null + */ + protected $symfonyDispatcher; + /** * The Artisan application instance. * @@ -106,10 +119,42 @@ public function __construct(Application $app, Dispatcher $events) $this->events = $events; $this->app->booted(function () { + if (! $this->app->runningUnitTests()) { + $this->rerouteSymfonyCommandEvents(); + } + $this->defineConsoleSchedule(); }); } + /** + * Re-route the Symfony command events to their Laravel counterparts. + * + * @internal + * + * @return $this + */ + public function rerouteSymfonyCommandEvents() + { + if (is_null($this->symfonyDispatcher)) { + $this->symfonyDispatcher = new EventDispatcher; + + $this->symfonyDispatcher->addListener(ConsoleEvents::COMMAND, function (ConsoleCommandEvent $event) { + $this->events->dispatch( + new CommandStarting($event->getCommand()->getName(), $event->getInput(), $event->getOutput()) + ); + }); + + $this->symfonyDispatcher->addListener(ConsoleEvents::TERMINATE, function (ConsoleTerminateEvent $event) { + $this->events->dispatch( + new CommandFinished($event->getCommand()->getName(), $event->getInput(), $event->getOutput(), $event->getExitCode()) + ); + }); + } + + return $this; + } + /** * Define the application's command schedule. * @@ -417,6 +462,10 @@ protected function getArtisan() $this->artisan = (new Artisan($this->app, $this->events, $this->app->version())) ->resolveCommands($this->commands) ->setContainerCommandLoader(); + + if ($this->symfonyDispatcher instanceof EventDispatcher) { + $this->artisan->setDispatcher($this->symfonyDispatcher); + } } return $this->artisan; @@ -425,7 +474,7 @@ protected function getArtisan() /** * Set the Artisan application instance. * - * @param \Illuminate\Console\Application $artisan + * @param \Illuminate\Console\Application|null $artisan * @return void */ public function setArtisan($artisan) diff --git a/src/Illuminate/Foundation/Console/KeyGenerateCommand.php b/src/Illuminate/Foundation/Console/KeyGenerateCommand.php index f047bc39..d51fce79 100644 --- a/src/Illuminate/Foundation/Console/KeyGenerateCommand.php +++ b/src/Illuminate/Foundation/Console/KeyGenerateCommand.php @@ -21,17 +21,6 @@ class KeyGenerateCommand extends Command {--show : Display the key instead of modifying files} {--force : Force the operation to run when in production}'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'key:generate'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/LangPublishCommand.php b/src/Illuminate/Foundation/Console/LangPublishCommand.php new file mode 100644 index 00000000..83a1ca55 --- /dev/null +++ b/src/Illuminate/Foundation/Console/LangPublishCommand.php @@ -0,0 +1,57 @@ +laravel->basePath('lang/en'))) { + (new Filesystem)->makeDirectory($langPath, recursive: true); + } + + $stubs = [ + realpath(__DIR__.'/../../Translation/lang/en/auth.php') => 'auth.php', + realpath(__DIR__.'/../../Translation/lang/en/pagination.php') => 'pagination.php', + realpath(__DIR__.'/../../Translation/lang/en/passwords.php') => 'passwords.php', + realpath(__DIR__.'/../../Translation/lang/en/validation.php') => 'validation.php', + ]; + + foreach ($stubs as $from => $to) { + $to = $langPath.DIRECTORY_SEPARATOR.ltrim($to, DIRECTORY_SEPARATOR); + + if ((! $this->option('existing') && (! file_exists($to) || $this->option('force'))) + || ($this->option('existing') && file_exists($to))) { + file_put_contents($to, file_get_contents($from)); + } + } + + $this->components->info('Language files published successfully.'); + } +} diff --git a/src/Illuminate/Foundation/Console/ListenerMakeCommand.php b/src/Illuminate/Foundation/Console/ListenerMakeCommand.php index 62e82ccd..6d815bbd 100644 --- a/src/Illuminate/Foundation/Console/ListenerMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ListenerMakeCommand.php @@ -22,17 +22,6 @@ class ListenerMakeCommand extends GeneratorCommand */ protected $name = 'make:listener'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'make:listener'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/MailMakeCommand.php b/src/Illuminate/Foundation/Console/MailMakeCommand.php index e998da51..af02001c 100644 --- a/src/Illuminate/Foundation/Console/MailMakeCommand.php +++ b/src/Illuminate/Foundation/Console/MailMakeCommand.php @@ -20,17 +20,6 @@ class MailMakeCommand extends GeneratorCommand */ protected $name = 'make:mail'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'make:mail'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/ModelMakeCommand.php b/src/Illuminate/Foundation/Console/ModelMakeCommand.php index dbc32855..4a4412a0 100644 --- a/src/Illuminate/Foundation/Console/ModelMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ModelMakeCommand.php @@ -22,17 +22,6 @@ class ModelMakeCommand extends GeneratorCommand */ protected $name = 'make:model'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'make:model'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/NotificationMakeCommand.php b/src/Illuminate/Foundation/Console/NotificationMakeCommand.php index 4bcf5c84..83b9663d 100644 --- a/src/Illuminate/Foundation/Console/NotificationMakeCommand.php +++ b/src/Illuminate/Foundation/Console/NotificationMakeCommand.php @@ -19,17 +19,6 @@ class NotificationMakeCommand extends GeneratorCommand */ protected $name = 'make:notification'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'make:notification'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/ObserverMakeCommand.php b/src/Illuminate/Foundation/Console/ObserverMakeCommand.php index 039cb4e2..1a6988d7 100644 --- a/src/Illuminate/Foundation/Console/ObserverMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ObserverMakeCommand.php @@ -19,17 +19,6 @@ class ObserverMakeCommand extends GeneratorCommand */ protected $name = 'make:observer'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'make:observer'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/OptimizeClearCommand.php b/src/Illuminate/Foundation/Console/OptimizeClearCommand.php index d3b039eb..7e932d79 100644 --- a/src/Illuminate/Foundation/Console/OptimizeClearCommand.php +++ b/src/Illuminate/Foundation/Console/OptimizeClearCommand.php @@ -15,17 +15,6 @@ class OptimizeClearCommand extends Command */ protected $name = 'optimize:clear'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'optimize:clear'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/OptimizeCommand.php b/src/Illuminate/Foundation/Console/OptimizeCommand.php index b487928d..10f26462 100644 --- a/src/Illuminate/Foundation/Console/OptimizeCommand.php +++ b/src/Illuminate/Foundation/Console/OptimizeCommand.php @@ -15,17 +15,6 @@ class OptimizeCommand extends Command */ protected $name = 'optimize'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'optimize'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php b/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php index d9b928f4..86f069b8 100644 --- a/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php +++ b/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php @@ -16,17 +16,6 @@ class PackageDiscoverCommand extends Command */ protected $signature = 'package:discover'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'package:discover'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/PolicyMakeCommand.php b/src/Illuminate/Foundation/Console/PolicyMakeCommand.php index 7bc95b0e..97672b68 100644 --- a/src/Illuminate/Foundation/Console/PolicyMakeCommand.php +++ b/src/Illuminate/Foundation/Console/PolicyMakeCommand.php @@ -20,17 +20,6 @@ class PolicyMakeCommand extends GeneratorCommand */ protected $name = 'make:policy'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'make:policy'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/ProviderMakeCommand.php b/src/Illuminate/Foundation/Console/ProviderMakeCommand.php index a3b99d97..54d7e4c0 100644 --- a/src/Illuminate/Foundation/Console/ProviderMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ProviderMakeCommand.php @@ -16,17 +16,6 @@ class ProviderMakeCommand extends GeneratorCommand */ protected $name = 'make:provider'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'make:provider'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/RequestMakeCommand.php b/src/Illuminate/Foundation/Console/RequestMakeCommand.php index f181ff0c..ad02e29f 100644 --- a/src/Illuminate/Foundation/Console/RequestMakeCommand.php +++ b/src/Illuminate/Foundation/Console/RequestMakeCommand.php @@ -16,17 +16,6 @@ class RequestMakeCommand extends GeneratorCommand */ protected $name = 'make:request'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'make:request'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/ResourceMakeCommand.php b/src/Illuminate/Foundation/Console/ResourceMakeCommand.php index 9fe4fddb..e8fd0225 100644 --- a/src/Illuminate/Foundation/Console/ResourceMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ResourceMakeCommand.php @@ -16,17 +16,6 @@ class ResourceMakeCommand extends GeneratorCommand */ protected $name = 'make:resource'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'make:resource'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/RouteCacheCommand.php b/src/Illuminate/Foundation/Console/RouteCacheCommand.php index 00f4050c..0aa21941 100644 --- a/src/Illuminate/Foundation/Console/RouteCacheCommand.php +++ b/src/Illuminate/Foundation/Console/RouteCacheCommand.php @@ -18,17 +18,6 @@ class RouteCacheCommand extends Command */ protected $name = 'route:cache'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'route:cache'; - /** * The console command description. * @@ -102,7 +91,7 @@ protected function getFreshApplicationRoutes() */ protected function getFreshApplication() { - return tap(require $this->laravel->bootstrapPath().'/app.php', function ($app) { + return tap(require $this->laravel->bootstrapPath('app.php'), function ($app) { $app->make(ConsoleKernelContract::class)->bootstrap(); }); } diff --git a/src/Illuminate/Foundation/Console/RouteClearCommand.php b/src/Illuminate/Foundation/Console/RouteClearCommand.php index da45e6d8..c496b10e 100644 --- a/src/Illuminate/Foundation/Console/RouteClearCommand.php +++ b/src/Illuminate/Foundation/Console/RouteClearCommand.php @@ -16,17 +16,6 @@ class RouteClearCommand extends Command */ protected $name = 'route:clear'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'route:clear'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/RouteListCommand.php b/src/Illuminate/Foundation/Console/RouteListCommand.php index caa81652..7cd48f5d 100644 --- a/src/Illuminate/Foundation/Console/RouteListCommand.php +++ b/src/Illuminate/Foundation/Console/RouteListCommand.php @@ -26,17 +26,6 @@ class RouteListCommand extends Command */ protected $name = 'route:list'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'route:list'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/RuleMakeCommand.php b/src/Illuminate/Foundation/Console/RuleMakeCommand.php index 5cefd1fa..02d4b540 100644 --- a/src/Illuminate/Foundation/Console/RuleMakeCommand.php +++ b/src/Illuminate/Foundation/Console/RuleMakeCommand.php @@ -16,17 +16,6 @@ class RuleMakeCommand extends GeneratorCommand */ protected $name = 'make:rule'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'make:rule'; - /** * The console command description. * @@ -65,15 +54,9 @@ protected function buildClass($name) */ protected function getStub() { - $stub = '/stubs/rule.stub'; - - if ($this->option('invokable')) { - $stub = '/stubs/rule.invokable.stub'; - } - - if ($this->option('implicit') && $this->option('invokable')) { - $stub = str_replace('.stub', '.implicit.stub', $stub); - } + $stub = $this->option('implicit') + ? '/stubs/rule.implicit.stub' + : '/stubs/rule.stub'; return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) ? $customPath @@ -101,7 +84,6 @@ protected function getOptions() return [ ['force', 'f', InputOption::VALUE_NONE, 'Create the class even if the rule already exists'], ['implicit', 'i', InputOption::VALUE_NONE, 'Generate an implicit rule'], - ['invokable', null, InputOption::VALUE_NONE, 'Generate a single method, invokable rule class'], ]; } } diff --git a/src/Illuminate/Foundation/Console/ScopeMakeCommand.php b/src/Illuminate/Foundation/Console/ScopeMakeCommand.php index d36742c8..c7db649e 100644 --- a/src/Illuminate/Foundation/Console/ScopeMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ScopeMakeCommand.php @@ -16,17 +16,6 @@ class ScopeMakeCommand extends GeneratorCommand */ protected $name = 'make:scope'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'make:scope'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/ServeCommand.php b/src/Illuminate/Foundation/Console/ServeCommand.php index 43c590ba..84bcb053 100644 --- a/src/Illuminate/Foundation/Console/ServeCommand.php +++ b/src/Illuminate/Foundation/Console/ServeCommand.php @@ -22,17 +22,6 @@ class ServeCommand extends Command */ protected $name = 'serve'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'serve'; - /** * The console command description. * @@ -68,6 +57,7 @@ class ServeCommand extends Command */ public static $passthroughVariables = [ 'APP_ENV', + 'IGNITION_LOCAL_SITES_PATH', 'LARAVEL_SAIL', 'PATH', 'PHP_CLI_SERVER_WORKERS', @@ -262,9 +252,12 @@ protected function handleProcessOutput() $this->requestsPool[$requestPort][1] = trim(explode('[200]: GET', $line)[1]); } elseif (str($line)->contains(' Closing')) { $requestPort = $this->getRequestPortFromLine($line); - $request = $this->requestsPool[$requestPort]; - [$startDate, $file] = $request; + if (empty($this->requestsPool[$requestPort])) { + return; + } + + [$startDate, $file] = $this->requestsPool[$requestPort]; $formattedStartedAt = $startDate->format('Y-m-d H:i:s'); diff --git a/src/Illuminate/Foundation/Console/ShowModelCommand.php b/src/Illuminate/Foundation/Console/ShowModelCommand.php deleted file mode 100644 index 5b15aafc..00000000 --- a/src/Illuminate/Foundation/Console/ShowModelCommand.php +++ /dev/null @@ -1,547 +0,0 @@ -ensureDependenciesExist()) { - return 1; - } - - $class = $this->qualifyModel($this->argument('model')); - - try { - $model = $this->laravel->make($class); - - $class = get_class($model); - } catch (BindingResolutionException $e) { - return $this->components->error($e->getMessage()); - } - - if ($this->option('database')) { - $model->setConnection($this->option('database')); - } - - $this->display( - $class, - $model->getConnection()->getName(), - $model->getConnection()->getTablePrefix().$model->getTable(), - $this->getPolicy($model), - $this->getAttributes($model), - $this->getRelations($model), - $this->getObservers($model), - ); - } - - /** - * Get the first policy associated with this model. - * - * @param \Illuminate\Database\Eloquent\Model $model - * @return Illuminate\Support\Collection - */ - protected function getPolicy($model) - { - return collect(Gate::policies()) - ->filter(fn ($policy, $modelClass) => $modelClass === get_class($model)) - ->values() - ->first(); - } - - /** - * Get the column attributes for the given model. - * - * @param \Illuminate\Database\Eloquent\Model $model - * @return \Illuminate\Support\Collection - */ - protected function getAttributes($model) - { - $schema = $model->getConnection()->getDoctrineSchemaManager(); - $this->registerTypeMappings($schema->getDatabasePlatform()); - $table = $model->getConnection()->getTablePrefix().$model->getTable(); - $columns = $schema->listTableColumns($table); - $indexes = $schema->listTableIndexes($table); - - return collect($columns) - ->values() - ->map(fn (Column $column) => [ - 'name' => $column->getName(), - 'type' => $this->getColumnType($column), - 'increments' => $column->getAutoincrement(), - 'nullable' => ! $column->getNotnull(), - 'default' => $this->getColumnDefault($column, $model), - 'unique' => $this->columnIsUnique($column->getName(), $indexes), - 'fillable' => $model->isFillable($column->getName()), - 'hidden' => $this->attributeIsHidden($column->getName(), $model), - 'appended' => null, - 'cast' => $this->getCastType($column->getName(), $model), - ]) - ->merge($this->getVirtualAttributes($model, $columns)); - } - - /** - * Get the virtual (non-column) attributes for the given model. - * - * @param \Illuminate\Database\Eloquent\Model $model - * @param \Doctrine\DBAL\Schema\Column[] $columns - * @return \Illuminate\Support\Collection - */ - protected function getVirtualAttributes($model, $columns) - { - $class = new ReflectionClass($model); - - return collect($class->getMethods()) - ->reject( - fn (ReflectionMethod $method) => $method->isStatic() - || $method->isAbstract() - || $method->getDeclaringClass()->getName() !== get_class($model) - ) - ->mapWithKeys(function (ReflectionMethod $method) use ($model) { - if (preg_match('/^get(.+)Attribute$/', $method->getName(), $matches) === 1) { - return [Str::snake($matches[1]) => 'accessor']; - } elseif ($model->hasAttributeMutator($method->getName())) { - return [Str::snake($method->getName()) => 'attribute']; - } else { - return []; - } - }) - ->reject(fn ($cast, $name) => collect($columns)->has($name)) - ->map(fn ($cast, $name) => [ - 'name' => $name, - 'type' => null, - 'increments' => false, - 'nullable' => null, - 'default' => null, - 'unique' => null, - 'fillable' => $model->isFillable($name), - 'hidden' => $this->attributeIsHidden($name, $model), - 'appended' => $model->hasAppended($name), - 'cast' => $cast, - ]) - ->values(); - } - - /** - * Get the relations from the given model. - * - * @param \Illuminate\Database\Eloquent\Model $model - * @return \Illuminate\Support\Collection - */ - protected function getRelations($model) - { - return collect(get_class_methods($model)) - ->map(fn ($method) => new ReflectionMethod($model, $method)) - ->reject( - fn (ReflectionMethod $method) => $method->isStatic() - || $method->isAbstract() - || $method->getDeclaringClass()->getName() !== get_class($model) - ) - ->filter(function (ReflectionMethod $method) { - $file = new SplFileObject($method->getFileName()); - $file->seek($method->getStartLine() - 1); - $code = ''; - while ($file->key() < $method->getEndLine()) { - $code .= trim($file->current()); - $file->next(); - } - - return collect($this->relationMethods) - ->contains(fn ($relationMethod) => str_contains($code, '$this->'.$relationMethod.'(')); - }) - ->map(function (ReflectionMethod $method) use ($model) { - $relation = $method->invoke($model); - - if (! $relation instanceof Relation) { - return null; - } - - return [ - 'name' => $method->getName(), - 'type' => Str::afterLast(get_class($relation), '\\'), - 'related' => get_class($relation->getRelated()), - ]; - }) - ->filter() - ->values(); - } - - /** - * Get the Observers watching this model. - * - * @param \Illuminate\Database\Eloquent\Model $model - * @return Illuminate\Support\Collection - */ - protected function getObservers($model) - { - $listeners = $this->getLaravel()->make('events')->getRawListeners(); - - // Get the Eloquent observers for this model... - $listeners = array_filter($listeners, function ($v, $key) use ($model) { - return Str::startsWith($key, 'eloquent.') && Str::endsWith($key, $model::class); - }, ARRAY_FILTER_USE_BOTH); - - // Format listeners Eloquent verb => Observer methods... - $extractVerb = function ($key) { - preg_match('/eloquent.([a-zA-Z]+)\: /', $key, $matches); - - return $matches[1] ?? '?'; - }; - - $formatted = []; - - foreach ($listeners as $key => $observerMethods) { - $formatted[] = [ - 'event' => $extractVerb($key), - 'observer' => array_map(fn ($obs) => is_string($obs) ? $obs : 'Closure', $observerMethods), - ]; - } - - return collect($formatted); - } - - /** - * Render the model information. - * - * @param string $class - * @param string $database - * @param string $table - * @param string $policy - * @param \Illuminate\Support\Collection $attributes - * @param \Illuminate\Support\Collection $relations - * @param \Illuminate\Support\Collection $observers - * @return void - */ - protected function display($class, $database, $table, $policy, $attributes, $relations, $observers) - { - $this->option('json') - ? $this->displayJson($class, $database, $table, $policy, $attributes, $relations, $observers) - : $this->displayCli($class, $database, $table, $policy, $attributes, $relations, $observers); - } - - /** - * Render the model information as JSON. - * - * @param string $class - * @param string $database - * @param string $table - * @param string $policy - * @param \Illuminate\Support\Collection $attributes - * @param \Illuminate\Support\Collection $relations - * @param \Illuminate\Support\Collection $observers - * @return void - */ - protected function displayJson($class, $database, $table, $policy, $attributes, $relations, $observers) - { - $this->output->writeln( - collect([ - 'class' => $class, - 'database' => $database, - 'table' => $table, - 'policy' => $policy, - 'attributes' => $attributes, - 'relations' => $relations, - 'observers' => $observers, - ])->toJson() - ); - } - - /** - * Render the model information for the CLI. - * - * @param string $class - * @param string $database - * @param string $table - * @param string $policy - * @param \Illuminate\Support\Collection $attributes - * @param \Illuminate\Support\Collection $relations - * @param \Illuminate\Support\Collection $observers - * @return void - */ - protected function displayCli($class, $database, $table, $policy, $attributes, $relations, $observers) - { - $this->newLine(); - - $this->components->twoColumnDetail(''.$class.''); - $this->components->twoColumnDetail('Database', $database); - $this->components->twoColumnDetail('Table', $table); - - if ($policy) { - $this->components->twoColumnDetail('Policy', $policy); - } - - $this->newLine(); - - $this->components->twoColumnDetail( - 'Attributes', - 'type / cast', - ); - - foreach ($attributes as $attribute) { - $first = trim(sprintf( - '%s %s', - $attribute['name'], - collect(['increments', 'unique', 'nullable', 'fillable', 'hidden', 'appended']) - ->filter(fn ($property) => $attribute[$property]) - ->map(fn ($property) => sprintf('%s', $property)) - ->implode(', ') - )); - - $second = collect([ - $attribute['type'], - $attribute['cast'] ? ''.$attribute['cast'].'' : null, - ])->filter()->implode(' / '); - - $this->components->twoColumnDetail($first, $second); - - if ($attribute['default'] !== null) { - $this->components->bulletList( - [sprintf('default: %s', $attribute['default'])], - OutputInterface::VERBOSITY_VERBOSE - ); - } - } - - $this->newLine(); - - $this->components->twoColumnDetail('Relations'); - - foreach ($relations as $relation) { - $this->components->twoColumnDetail( - sprintf('%s %s', $relation['name'], $relation['type']), - $relation['related'] - ); - } - - $this->newLine(); - - $this->components->twoColumnDetail('Observers'); - - if ($observers->count()) { - foreach ($observers as $observer) { - $this->components->twoColumnDetail( - sprintf('%s', $observer['event']), - implode(', ', $observer['observer']) - ); - } - } - - $this->newLine(); - } - - /** - * Get the cast type for the given column. - * - * @param string $column - * @param \Illuminate\Database\Eloquent\Model $model - * @return string|null - */ - protected function getCastType($column, $model) - { - if ($model->hasGetMutator($column) || $model->hasSetMutator($column)) { - return 'accessor'; - } - - if ($model->hasAttributeMutator($column)) { - return 'attribute'; - } - - return $this->getCastsWithDates($model)->get($column) ?? null; - } - - /** - * Get the model casts, including any date casts. - * - * @param \Illuminate\Database\Eloquent\Model $model - * @return \Illuminate\Support\Collection - */ - protected function getCastsWithDates($model) - { - return collect($model->getDates()) - ->filter() - ->flip() - ->map(fn () => 'datetime') - ->merge($model->getCasts()); - } - - /** - * Get the type of the given column. - * - * @param \Doctrine\DBAL\Schema\Column $column - * @return string - */ - protected function getColumnType($column) - { - $name = $column->getType()->getName(); - - $unsigned = $column->getUnsigned() ? ' unsigned' : ''; - - $details = match (get_class($column->getType())) { - DecimalType::class => $column->getPrecision().','.$column->getScale(), - default => $column->getLength(), - }; - - if ($details) { - return sprintf('%s(%s)%s', $name, $details, $unsigned); - } - - return sprintf('%s%s', $name, $unsigned); - } - - /** - * Get the default value for the given column. - * - * @param \Doctrine\DBAL\Schema\Column $column - * @param \Illuminate\Database\Eloquent\Model $model - * @return mixed|null - */ - protected function getColumnDefault($column, $model) - { - $attributeDefault = $model->getAttributes()[$column->getName()] ?? null; - - return match (true) { - $attributeDefault instanceof BackedEnum => $attributeDefault->value, - $attributeDefault instanceof UnitEnum => $attributeDefault->name, - default => $attributeDefault ?? $column->getDefault(), - }; - } - - /** - * Determine if the given attribute is hidden. - * - * @param string $attribute - * @param \Illuminate\Database\Eloquent\Model $model - * @return bool - */ - protected function attributeIsHidden($attribute, $model) - { - if (count($model->getHidden()) > 0) { - return in_array($attribute, $model->getHidden()); - } - - if (count($model->getVisible()) > 0) { - return ! in_array($attribute, $model->getVisible()); - } - - return false; - } - - /** - * Determine if the given attribute is unique. - * - * @param string $column - * @param \Doctrine\DBAL\Schema\Index[] $indexes - * @return bool - */ - protected function columnIsUnique($column, $indexes) - { - return collect($indexes) - ->filter(fn (Index $index) => count($index->getColumns()) === 1 && $index->getColumns()[0] === $column) - ->contains(fn (Index $index) => $index->isUnique()); - } - - /** - * Qualify the given model class base name. - * - * @param string $model - * @return string - * - * @see \Illuminate\Console\GeneratorCommand - */ - protected function qualifyModel(string $model) - { - if (str_contains($model, '\\') && class_exists($model)) { - return $model; - } - - $model = ltrim($model, '\\/'); - - $model = str_replace('/', '\\', $model); - - $rootNamespace = $this->laravel->getNamespace(); - - if (Str::startsWith($model, $rootNamespace)) { - return $model; - } - - return is_dir(app_path('Models')) - ? $rootNamespace.'Models\\'.$model - : $rootNamespace.$model; - } -} diff --git a/src/Illuminate/Foundation/Console/StorageLinkCommand.php b/src/Illuminate/Foundation/Console/StorageLinkCommand.php index 10427557..2a216ebe 100644 --- a/src/Illuminate/Foundation/Console/StorageLinkCommand.php +++ b/src/Illuminate/Foundation/Console/StorageLinkCommand.php @@ -17,17 +17,6 @@ class StorageLinkCommand extends Command {--relative : Create the symbolic link using relative paths} {--force : Recreate existing symbolic links}'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'storage:link'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/StubPublishCommand.php b/src/Illuminate/Foundation/Console/StubPublishCommand.php index 58bf2040..e2a293d4 100644 --- a/src/Illuminate/Foundation/Console/StubPublishCommand.php +++ b/src/Illuminate/Foundation/Console/StubPublishCommand.php @@ -19,17 +19,6 @@ class StubPublishCommand extends Command {--existing : Publish and overwrite only the files that have already been published} {--force : Overwrite any existing files}'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'stub:publish'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/TestMakeCommand.php b/src/Illuminate/Foundation/Console/TestMakeCommand.php index f3dd30a0..7ee08a16 100644 --- a/src/Illuminate/Foundation/Console/TestMakeCommand.php +++ b/src/Illuminate/Foundation/Console/TestMakeCommand.php @@ -19,17 +19,6 @@ class TestMakeCommand extends GeneratorCommand */ protected $name = 'make:test'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'make:test'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/UpCommand.php b/src/Illuminate/Foundation/Console/UpCommand.php index 000d3c62..c1b0e55c 100644 --- a/src/Illuminate/Foundation/Console/UpCommand.php +++ b/src/Illuminate/Foundation/Console/UpCommand.php @@ -17,17 +17,6 @@ class UpCommand extends Command */ protected $name = 'up'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'up'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index ad41fa77..7ca5c4fb 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -51,17 +51,6 @@ class VendorPublishCommand extends Command {--provider= : The service provider that has assets you want to publish} {--tag=* : One or many tags that have assets you want to publish}'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'vendor:publish'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/ViewCacheCommand.php b/src/Illuminate/Foundation/Console/ViewCacheCommand.php index 03f8d75d..1fda88e1 100644 --- a/src/Illuminate/Foundation/Console/ViewCacheCommand.php +++ b/src/Illuminate/Foundation/Console/ViewCacheCommand.php @@ -19,17 +19,6 @@ class ViewCacheCommand extends Command */ protected $signature = 'view:cache'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'view:cache'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/ViewClearCommand.php b/src/Illuminate/Foundation/Console/ViewClearCommand.php index 2480f965..9cb58e23 100644 --- a/src/Illuminate/Foundation/Console/ViewClearCommand.php +++ b/src/Illuminate/Foundation/Console/ViewClearCommand.php @@ -17,17 +17,6 @@ class ViewClearCommand extends Command */ protected $name = 'view:clear'; - /** - * The name of the console command. - * - * This name is used to identify the command during lazy loading. - * - * @var string|null - * - * @deprecated - */ - protected static $defaultName = 'view:clear'; - /** * The console command description. * diff --git a/src/Illuminate/Foundation/Console/stubs/cast.inbound.stub b/src/Illuminate/Foundation/Console/stubs/cast.inbound.stub index c456e3c5..e74edf84 100644 --- a/src/Illuminate/Foundation/Console/stubs/cast.inbound.stub +++ b/src/Illuminate/Foundation/Console/stubs/cast.inbound.stub @@ -2,6 +2,7 @@ namespace {{ namespace }}; +use Illuminate\Database\Eloquent\Model; use Illuminate\Contracts\Database\Eloquent\CastsInboundAttributes; class {{ class }} implements CastsInboundAttributes @@ -9,13 +10,9 @@ class {{ class }} implements CastsInboundAttributes /** * Prepare the given value for storage. * - * @param \Illuminate\Database\Eloquent\Model $model - * @param string $key - * @param mixed $value - * @param array $attributes - * @return mixed + * @param array $attributes */ - public function set($model, string $key, $value, array $attributes) + public function set(Model $model, string $key, mixed $value, array $attributes): mixed { return $value; } diff --git a/src/Illuminate/Foundation/Console/stubs/cast.stub b/src/Illuminate/Foundation/Console/stubs/cast.stub index 25d35b68..35ddc479 100644 --- a/src/Illuminate/Foundation/Console/stubs/cast.stub +++ b/src/Illuminate/Foundation/Console/stubs/cast.stub @@ -2,6 +2,7 @@ namespace {{ namespace }}; +use Illuminate\Database\Eloquent\Model; use Illuminate\Contracts\Database\Eloquent\CastsAttributes; class {{ class }} implements CastsAttributes @@ -9,13 +10,9 @@ class {{ class }} implements CastsAttributes /** * Cast the given value. * - * @param \Illuminate\Database\Eloquent\Model $model - * @param string $key - * @param mixed $value - * @param array $attributes - * @return mixed + * @param array $attributes */ - public function get($model, string $key, $value, array $attributes) + public function get(Model $model, string $key, mixed $value, array $attributes): mixed { return $value; } @@ -23,13 +20,9 @@ class {{ class }} implements CastsAttributes /** * Prepare the given value for storage. * - * @param \Illuminate\Database\Eloquent\Model $model - * @param string $key - * @param mixed $value - * @param array $attributes - * @return mixed + * @param array $attributes */ - public function set($model, string $key, $value, array $attributes) + public function set(Model $model, string $key, mixed $value, array $attributes): mixed { return $value; } diff --git a/src/Illuminate/Foundation/Console/stubs/channel.stub b/src/Illuminate/Foundation/Console/stubs/channel.stub index 1b516980..46c1a532 100644 --- a/src/Illuminate/Foundation/Console/stubs/channel.stub +++ b/src/Illuminate/Foundation/Console/stubs/channel.stub @@ -8,8 +8,6 @@ class {{ class }} { /** * Create a new channel instance. - * - * @return void */ public function __construct() { @@ -18,11 +16,8 @@ class {{ class }} /** * Authenticate the user's access to the channel. - * - * @param \{{ namespacedUserModel }} $user - * @return array|bool */ - public function join({{ userModel }} $user) + public function join({{ userModel }} $user): array|bool { // } diff --git a/src/Illuminate/Foundation/Console/stubs/console.stub b/src/Illuminate/Foundation/Console/stubs/console.stub index cef60a91..055b7d83 100644 --- a/src/Illuminate/Foundation/Console/stubs/console.stub +++ b/src/Illuminate/Foundation/Console/stubs/console.stub @@ -22,11 +22,9 @@ class {{ class }} extends Command /** * Execute the console command. - * - * @return int */ public function handle() { - return Command::SUCCESS; + // } } diff --git a/src/Illuminate/Foundation/Console/stubs/event.stub b/src/Illuminate/Foundation/Console/stubs/event.stub index 47f8c913..cd9e0ec1 100644 --- a/src/Illuminate/Foundation/Console/stubs/event.stub +++ b/src/Illuminate/Foundation/Console/stubs/event.stub @@ -16,8 +16,6 @@ class {{ class }} /** * Create a new event instance. - * - * @return void */ public function __construct() { @@ -27,10 +25,12 @@ class {{ class }} /** * Get the channels the event should broadcast on. * - * @return \Illuminate\Broadcasting\Channel|array + * @return array */ - public function broadcastOn() + public function broadcastOn(): array { - return new PrivateChannel('channel-name'); + return [ + new PrivateChannel('channel-name'), + ]; } } diff --git a/src/Illuminate/Foundation/Console/stubs/exception-render-report.stub b/src/Illuminate/Foundation/Console/stubs/exception-render-report.stub index b72fa575..9209c1de 100644 --- a/src/Illuminate/Foundation/Console/stubs/exception-render-report.stub +++ b/src/Illuminate/Foundation/Console/stubs/exception-render-report.stub @@ -3,26 +3,23 @@ namespace {{ namespace }}; use Exception; +use Illuminate\Http\Request; +use Illuminate\Http\Response; class {{ class }} extends Exception { /** * Report the exception. - * - * @return bool|null */ - public function report() + public function report(): void { // } /** * Render the exception as an HTTP response. - * - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Http\Response */ - public function render($request) + public function render(Request $request): Response { // } diff --git a/src/Illuminate/Foundation/Console/stubs/exception-render.stub b/src/Illuminate/Foundation/Console/stubs/exception-render.stub index b397f212..12b38bac 100644 --- a/src/Illuminate/Foundation/Console/stubs/exception-render.stub +++ b/src/Illuminate/Foundation/Console/stubs/exception-render.stub @@ -3,16 +3,15 @@ namespace {{ namespace }}; use Exception; +use Illuminate\Http\Request; +use Illuminate\Http\Response; class {{ class }} extends Exception { /** * Render the exception as an HTTP response. - * - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Http\Response */ - public function render($request) + public function render(Request $request): Response { // } diff --git a/src/Illuminate/Foundation/Console/stubs/exception-report.stub b/src/Illuminate/Foundation/Console/stubs/exception-report.stub index 250db609..051e04d7 100644 --- a/src/Illuminate/Foundation/Console/stubs/exception-report.stub +++ b/src/Illuminate/Foundation/Console/stubs/exception-report.stub @@ -8,10 +8,8 @@ class {{ class }} extends Exception { /** * Report the exception. - * - * @return bool|null */ - public function report() + public function report(): void { // } diff --git a/src/Illuminate/Foundation/Console/stubs/job.queued.stub b/src/Illuminate/Foundation/Console/stubs/job.queued.stub index 4b78746d..bc67adcf 100644 --- a/src/Illuminate/Foundation/Console/stubs/job.queued.stub +++ b/src/Illuminate/Foundation/Console/stubs/job.queued.stub @@ -15,8 +15,6 @@ class {{ class }} implements ShouldQueue /** * Create a new job instance. - * - * @return void */ public function __construct() { @@ -25,10 +23,8 @@ class {{ class }} implements ShouldQueue /** * Execute the job. - * - * @return void */ - public function handle() + public function handle(): void { // } diff --git a/src/Illuminate/Foundation/Console/stubs/job.stub b/src/Illuminate/Foundation/Console/stubs/job.stub index 89dc9d72..a5393714 100644 --- a/src/Illuminate/Foundation/Console/stubs/job.stub +++ b/src/Illuminate/Foundation/Console/stubs/job.stub @@ -10,8 +10,6 @@ class {{ class }} /** * Create a new job instance. - * - * @return void */ public function __construct() { @@ -20,10 +18,8 @@ class {{ class }} /** * Execute the job. - * - * @return void */ - public function handle() + public function handle(): void { // } diff --git a/src/Illuminate/Foundation/Console/stubs/listener-duck.stub b/src/Illuminate/Foundation/Console/stubs/listener-duck.stub index 40b9a1eb..54abb1e3 100644 --- a/src/Illuminate/Foundation/Console/stubs/listener-duck.stub +++ b/src/Illuminate/Foundation/Console/stubs/listener-duck.stub @@ -9,8 +9,6 @@ class {{ class }} { /** * Create the event listener. - * - * @return void */ public function __construct() { @@ -19,11 +17,8 @@ class {{ class }} /** * Handle the event. - * - * @param object $event - * @return void */ - public function handle($event) + public function handle(object $event): void { // } diff --git a/src/Illuminate/Foundation/Console/stubs/listener-queued-duck.stub b/src/Illuminate/Foundation/Console/stubs/listener-queued-duck.stub index dd57a456..08ced4fb 100644 --- a/src/Illuminate/Foundation/Console/stubs/listener-queued-duck.stub +++ b/src/Illuminate/Foundation/Console/stubs/listener-queued-duck.stub @@ -11,8 +11,6 @@ class {{ class }} implements ShouldQueue /** * Create the event listener. - * - * @return void */ public function __construct() { @@ -21,11 +19,8 @@ class {{ class }} implements ShouldQueue /** * Handle the event. - * - * @param object $event - * @return void */ - public function handle($event) + public function handle(object $event): void { // } diff --git a/src/Illuminate/Foundation/Console/stubs/listener-queued.stub b/src/Illuminate/Foundation/Console/stubs/listener-queued.stub index 81cdacce..c91ea2ce 100644 --- a/src/Illuminate/Foundation/Console/stubs/listener-queued.stub +++ b/src/Illuminate/Foundation/Console/stubs/listener-queued.stub @@ -12,8 +12,6 @@ class {{ class }} implements ShouldQueue /** * Create the event listener. - * - * @return void */ public function __construct() { @@ -22,11 +20,8 @@ class {{ class }} implements ShouldQueue /** * Handle the event. - * - * @param {{ eventNamespace }} $event - * @return void */ - public function handle({{ event }} $event) + public function handle({{ event }} $event): void { // } diff --git a/src/Illuminate/Foundation/Console/stubs/listener.stub b/src/Illuminate/Foundation/Console/stubs/listener.stub index fe1b7447..7c928d09 100644 --- a/src/Illuminate/Foundation/Console/stubs/listener.stub +++ b/src/Illuminate/Foundation/Console/stubs/listener.stub @@ -10,8 +10,6 @@ class {{ class }} { /** * Create the event listener. - * - * @return void */ public function __construct() { @@ -20,11 +18,8 @@ class {{ class }} /** * Handle the event. - * - * @param \{{ eventNamespace }} $event - * @return void */ - public function handle({{ event }} $event) + public function handle({{ event }} $event): void { // } diff --git a/src/Illuminate/Foundation/Console/stubs/mail.stub b/src/Illuminate/Foundation/Console/stubs/mail.stub index 45967d8a..e779df1d 100644 --- a/src/Illuminate/Foundation/Console/stubs/mail.stub +++ b/src/Illuminate/Foundation/Console/stubs/mail.stub @@ -15,8 +15,6 @@ class {{ class }} extends Mailable /** * Create a new message instance. - * - * @return void */ public function __construct() { @@ -25,10 +23,8 @@ class {{ class }} extends Mailable /** * Get the message envelope. - * - * @return \Illuminate\Mail\Mailables\Envelope */ - public function envelope() + public function envelope(): Envelope { return new Envelope( subject: '{{ subject }}', @@ -37,10 +33,8 @@ class {{ class }} extends Mailable /** * Get the message content definition. - * - * @return \Illuminate\Mail\Mailables\Content */ - public function content() + public function content(): Content { return new Content( view: 'view.name', @@ -50,9 +44,9 @@ class {{ class }} extends Mailable /** * Get the attachments for the message. * - * @return array + * @return array */ - public function attachments() + public function attachments(): array { return []; } diff --git a/src/Illuminate/Foundation/Console/stubs/markdown-mail.stub b/src/Illuminate/Foundation/Console/stubs/markdown-mail.stub index 76b6ccc5..191b46f5 100644 --- a/src/Illuminate/Foundation/Console/stubs/markdown-mail.stub +++ b/src/Illuminate/Foundation/Console/stubs/markdown-mail.stub @@ -15,8 +15,6 @@ class {{ class }} extends Mailable /** * Create a new message instance. - * - * @return void */ public function __construct() { @@ -25,10 +23,8 @@ class {{ class }} extends Mailable /** * Get the message envelope. - * - * @return \Illuminate\Mail\Mailables\Envelope */ - public function envelope() + public function envelope(): Envelope { return new Envelope( subject: '{{ subject }}', @@ -37,10 +33,8 @@ class {{ class }} extends Mailable /** * Get the message content definition. - * - * @return \Illuminate\Mail\Mailables\Content */ - public function content() + public function content(): Content { return new Content( markdown: '{{ view }}', @@ -50,9 +44,9 @@ class {{ class }} extends Mailable /** * Get the attachments for the message. * - * @return array + * @return array */ - public function attachments() + public function attachments(): array { return []; } diff --git a/src/Illuminate/Foundation/Console/stubs/markdown-notification.stub b/src/Illuminate/Foundation/Console/stubs/markdown-notification.stub index 5438f045..cc99eac8 100644 --- a/src/Illuminate/Foundation/Console/stubs/markdown-notification.stub +++ b/src/Illuminate/Foundation/Console/stubs/markdown-notification.stub @@ -13,8 +13,6 @@ class {{ class }} extends Notification /** * Create a new notification instance. - * - * @return void */ public function __construct() { @@ -24,21 +22,17 @@ class {{ class }} extends Notification /** * Get the notification's delivery channels. * - * @param mixed $notifiable - * @return array + * @return array */ - public function via($notifiable) + public function via(object $notifiable): array { return ['mail']; } /** * Get the mail representation of the notification. - * - * @param mixed $notifiable - * @return \Illuminate\Notifications\Messages\MailMessage */ - public function toMail($notifiable) + public function toMail(object $notifiable): MailMessage { return (new MailMessage)->markdown('{{ view }}'); } @@ -46,10 +40,9 @@ class {{ class }} extends Notification /** * Get the array representation of the notification. * - * @param mixed $notifiable - * @return array + * @return array */ - public function toArray($notifiable) + public function toArray(object $notifiable): array { return [ // diff --git a/src/Illuminate/Foundation/Console/stubs/notification.stub b/src/Illuminate/Foundation/Console/stubs/notification.stub index b170a463..e573dcd2 100644 --- a/src/Illuminate/Foundation/Console/stubs/notification.stub +++ b/src/Illuminate/Foundation/Console/stubs/notification.stub @@ -13,8 +13,6 @@ class {{ class }} extends Notification /** * Create a new notification instance. - * - * @return void */ public function __construct() { @@ -24,21 +22,17 @@ class {{ class }} extends Notification /** * Get the notification's delivery channels. * - * @param mixed $notifiable - * @return array + * @return array */ - public function via($notifiable) + public function via(object $notifiable): array { return ['mail']; } /** * Get the mail representation of the notification. - * - * @param mixed $notifiable - * @return \Illuminate\Notifications\Messages\MailMessage */ - public function toMail($notifiable) + public function toMail(object $notifiable): MailMessage { return (new MailMessage) ->line('The introduction to the notification.') @@ -49,10 +43,9 @@ class {{ class }} extends Notification /** * Get the array representation of the notification. * - * @param mixed $notifiable - * @return array + * @return array */ - public function toArray($notifiable) + public function toArray(object $notifiable): array { return [ // diff --git a/src/Illuminate/Foundation/Console/stubs/observer.stub b/src/Illuminate/Foundation/Console/stubs/observer.stub index 32ca095e..e9eb25bd 100644 --- a/src/Illuminate/Foundation/Console/stubs/observer.stub +++ b/src/Illuminate/Foundation/Console/stubs/observer.stub @@ -8,55 +8,40 @@ class {{ class }} { /** * Handle the {{ model }} "created" event. - * - * @param \{{ namespacedModel }} ${{ modelVariable }} - * @return void */ - public function created({{ model }} ${{ modelVariable }}) + public function created({{ model }} ${{ modelVariable }}): void { // } /** * Handle the {{ model }} "updated" event. - * - * @param \{{ namespacedModel }} ${{ modelVariable }} - * @return void */ - public function updated({{ model }} ${{ modelVariable }}) + public function updated({{ model }} ${{ modelVariable }}): void { // } /** * Handle the {{ model }} "deleted" event. - * - * @param \{{ namespacedModel }} ${{ modelVariable }} - * @return void */ - public function deleted({{ model }} ${{ modelVariable }}) + public function deleted({{ model }} ${{ modelVariable }}): void { // } /** * Handle the {{ model }} "restored" event. - * - * @param \{{ namespacedModel }} ${{ modelVariable }} - * @return void */ - public function restored({{ model }} ${{ modelVariable }}) + public function restored({{ model }} ${{ modelVariable }}): void { // } /** * Handle the {{ model }} "force deleted" event. - * - * @param \{{ namespacedModel }} ${{ modelVariable }} - * @return void */ - public function forceDeleted({{ model }} ${{ modelVariable }}) + public function forceDeleted({{ model }} ${{ modelVariable }}): void { // } diff --git a/src/Illuminate/Foundation/Console/stubs/policy.plain.stub b/src/Illuminate/Foundation/Console/stubs/policy.plain.stub index b014d859..c8657755 100644 --- a/src/Illuminate/Foundation/Console/stubs/policy.plain.stub +++ b/src/Illuminate/Foundation/Console/stubs/policy.plain.stub @@ -2,17 +2,12 @@ namespace {{ namespace }}; -use Illuminate\Auth\Access\HandlesAuthorization; use {{ namespacedUserModel }}; class {{ class }} { - use HandlesAuthorization; - /** * Create a new policy instance. - * - * @return void */ public function __construct() { diff --git a/src/Illuminate/Foundation/Console/stubs/policy.stub b/src/Illuminate/Foundation/Console/stubs/policy.stub index 985babb5..ffe9ce14 100644 --- a/src/Illuminate/Foundation/Console/stubs/policy.stub +++ b/src/Illuminate/Foundation/Console/stubs/policy.stub @@ -2,92 +2,64 @@ namespace {{ namespace }}; -use Illuminate\Auth\Access\HandlesAuthorization; +use Illuminate\Auth\Access\Response; use {{ namespacedModel }}; use {{ namespacedUserModel }}; class {{ class }} { - use HandlesAuthorization; - /** * Determine whether the user can view any models. - * - * @param \{{ namespacedUserModel }} $user - * @return \Illuminate\Auth\Access\Response|bool */ - public function viewAny({{ user }} $user) + public function viewAny({{ user }} $user): bool { // } /** * Determine whether the user can view the model. - * - * @param \{{ namespacedUserModel }} $user - * @param \{{ namespacedModel }} ${{ modelVariable }} - * @return \Illuminate\Auth\Access\Response|bool */ - public function view({{ user }} $user, {{ model }} ${{ modelVariable }}) + public function view({{ user }} $user, {{ model }} ${{ modelVariable }}): bool { // } /** * Determine whether the user can create models. - * - * @param \{{ namespacedUserModel }} $user - * @return \Illuminate\Auth\Access\Response|bool */ - public function create({{ user }} $user) + public function create({{ user }} $user): bool { // } /** * Determine whether the user can update the model. - * - * @param \{{ namespacedUserModel }} $user - * @param \{{ namespacedModel }} ${{ modelVariable }} - * @return \Illuminate\Auth\Access\Response|bool */ - public function update({{ user }} $user, {{ model }} ${{ modelVariable }}) + public function update({{ user }} $user, {{ model }} ${{ modelVariable }}): bool { // } /** * Determine whether the user can delete the model. - * - * @param \{{ namespacedUserModel }} $user - * @param \{{ namespacedModel }} ${{ modelVariable }} - * @return \Illuminate\Auth\Access\Response|bool */ - public function delete({{ user }} $user, {{ model }} ${{ modelVariable }}) + public function delete({{ user }} $user, {{ model }} ${{ modelVariable }}): bool { // } /** * Determine whether the user can restore the model. - * - * @param \{{ namespacedUserModel }} $user - * @param \{{ namespacedModel }} ${{ modelVariable }} - * @return \Illuminate\Auth\Access\Response|bool */ - public function restore({{ user }} $user, {{ model }} ${{ modelVariable }}) + public function restore({{ user }} $user, {{ model }} ${{ modelVariable }}): bool { // } /** * Determine whether the user can permanently delete the model. - * - * @param \{{ namespacedUserModel }} $user - * @param \{{ namespacedModel }} ${{ modelVariable }} - * @return \Illuminate\Auth\Access\Response|bool */ - public function forceDelete({{ user }} $user, {{ model }} ${{ modelVariable }}) + public function forceDelete({{ user }} $user, {{ model }} ${{ modelVariable }}): bool { // } diff --git a/src/Illuminate/Foundation/Console/stubs/provider.stub b/src/Illuminate/Foundation/Console/stubs/provider.stub index 6dedc584..537ce0ae 100644 --- a/src/Illuminate/Foundation/Console/stubs/provider.stub +++ b/src/Illuminate/Foundation/Console/stubs/provider.stub @@ -8,20 +8,16 @@ class {{ class }} extends ServiceProvider { /** * Register services. - * - * @return void */ - public function register() + public function register(): void { // } /** * Bootstrap services. - * - * @return void */ - public function boot() + public function boot(): void { // } diff --git a/src/Illuminate/Foundation/Console/stubs/request.stub b/src/Illuminate/Foundation/Console/stubs/request.stub index 947cf3dd..a9a50ae5 100644 --- a/src/Illuminate/Foundation/Console/stubs/request.stub +++ b/src/Illuminate/Foundation/Console/stubs/request.stub @@ -8,10 +8,8 @@ class {{ class }} extends FormRequest { /** * Determine if the user is authorized to make this request. - * - * @return bool */ - public function authorize() + public function authorize(): bool { return false; } @@ -19,9 +17,9 @@ class {{ class }} extends FormRequest /** * Get the validation rules that apply to the request. * - * @return array + * @return array */ - public function rules() + public function rules(): array { return [ // diff --git a/src/Illuminate/Foundation/Console/stubs/resource-collection.stub b/src/Illuminate/Foundation/Console/stubs/resource-collection.stub index ddec9614..f75e4819 100644 --- a/src/Illuminate/Foundation/Console/stubs/resource-collection.stub +++ b/src/Illuminate/Foundation/Console/stubs/resource-collection.stub @@ -2,6 +2,7 @@ namespace {{ namespace }}; +use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\ResourceCollection; class {{ class }} extends ResourceCollection @@ -9,10 +10,9 @@ class {{ class }} extends ResourceCollection /** * Transform the resource collection into an array. * - * @param \Illuminate\Http\Request $request - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable + * @return array */ - public function toArray($request) + public function toArray(Request $request): array { return parent::toArray($request); } diff --git a/src/Illuminate/Foundation/Console/stubs/resource.stub b/src/Illuminate/Foundation/Console/stubs/resource.stub index 05bacc36..ce8ece45 100644 --- a/src/Illuminate/Foundation/Console/stubs/resource.stub +++ b/src/Illuminate/Foundation/Console/stubs/resource.stub @@ -2,6 +2,7 @@ namespace {{ namespace }}; +use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; class {{ class }} extends JsonResource @@ -9,10 +10,9 @@ class {{ class }} extends JsonResource /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request $request - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable + * @return array */ - public function toArray($request) + public function toArray(Request $request): array { return parent::toArray($request); } diff --git a/src/Illuminate/Foundation/Console/stubs/rule.invokable.implicit.stub b/src/Illuminate/Foundation/Console/stubs/rule.implicit.stub similarity index 58% rename from src/Illuminate/Foundation/Console/stubs/rule.invokable.implicit.stub rename to src/Illuminate/Foundation/Console/stubs/rule.implicit.stub index 077cae59..341f842a 100644 --- a/src/Illuminate/Foundation/Console/stubs/rule.invokable.implicit.stub +++ b/src/Illuminate/Foundation/Console/stubs/rule.implicit.stub @@ -2,9 +2,10 @@ namespace {{ namespace }}; -use Illuminate\Contracts\Validation\InvokableRule; +use Closure; +use Illuminate\Contracts\Validation\ValidationRule; -class {{ class }} implements InvokableRule +class {{ class }} implements ValidationRule { /** * Indicates whether the rule should be implicit. @@ -16,12 +17,9 @@ class {{ class }} implements InvokableRule /** * Run the validation rule. * - * @param string $attribute - * @param mixed $value * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail - * @return void */ - public function __invoke($attribute, $value, $fail) + public function validate(string $attribute, mixed $value, Closure $fail): void { // } diff --git a/src/Illuminate/Foundation/Console/stubs/rule.invokable.stub b/src/Illuminate/Foundation/Console/stubs/rule.invokable.stub deleted file mode 100644 index ddf9d657..00000000 --- a/src/Illuminate/Foundation/Console/stubs/rule.invokable.stub +++ /dev/null @@ -1,21 +0,0 @@ -get('/'); diff --git a/src/Illuminate/Foundation/Console/stubs/test.unit.stub b/src/Illuminate/Foundation/Console/stubs/test.unit.stub index b6816aa7..7accf88d 100644 --- a/src/Illuminate/Foundation/Console/stubs/test.unit.stub +++ b/src/Illuminate/Foundation/Console/stubs/test.unit.stub @@ -8,10 +8,8 @@ class {{ class }} extends TestCase { /** * A basic unit test example. - * - * @return void */ - public function test_example() + public function test_example(): void { $this->assertTrue(true); } diff --git a/src/Illuminate/Foundation/Console/stubs/view-component.stub b/src/Illuminate/Foundation/Console/stubs/view-component.stub index eab8fd35..95cf5250 100644 --- a/src/Illuminate/Foundation/Console/stubs/view-component.stub +++ b/src/Illuminate/Foundation/Console/stubs/view-component.stub @@ -2,14 +2,14 @@ namespace {{ namespace }}; +use Closure; use Illuminate\View\Component; +use Illuminate\Contracts\View\View; class {{ class }} extends Component { /** * Create a new component instance. - * - * @return void */ public function __construct() { @@ -18,10 +18,8 @@ class {{ class }} extends Component /** * Get the view / contents that represent the component. - * - * @return \Illuminate\Contracts\View\View|\Closure|string */ - public function render() + public function render(): View|Closure|string { return {{ view }}; } diff --git a/src/Illuminate/Foundation/Events/DiscoverEvents.php b/src/Illuminate/Foundation/Events/DiscoverEvents.php index fae42069..1e26f556 100644 --- a/src/Illuminate/Foundation/Events/DiscoverEvents.php +++ b/src/Illuminate/Foundation/Events/DiscoverEvents.php @@ -56,7 +56,7 @@ protected static function getListenerEvents($listeners, $basePath) $listener = new ReflectionClass( static::classFromFile($listener, $basePath) ); - } catch (ReflectionException $e) { + } catch (ReflectionException) { continue; } diff --git a/src/Illuminate/Foundation/Exceptions/Handler.php b/src/Illuminate/Foundation/Exceptions/Handler.php index 40a4dc4c..4a5b3bd3 100644 --- a/src/Illuminate/Foundation/Exceptions/Handler.php +++ b/src/Illuminate/Foundation/Exceptions/Handler.php @@ -299,6 +299,23 @@ protected function shouldntReport(Throwable $e) return ! is_null(Arr::first($dontReport, fn ($type) => $e instanceof $type)); } + /** + * Remove the given exception class from the list of exceptions that should be ignored. + * + * @param string $exception + * @return $this + */ + public function stopIgnoring(string $exception) + { + $this->dontReport = collect($this->dontReport) + ->reject(fn ($ignored) => $ignored === $exception)->values()->all(); + + $this->internalDontReport = collect($this->internalDontReport) + ->reject(fn ($ignored) => $ignored === $exception)->values()->all(); + + return $this; + } + /** * Create the context array for logging the given exception. * @@ -356,6 +373,8 @@ protected function context() */ public function render($request, Throwable $e) { + $e = $this->mapException($e); + if (method_exists($e, 'render') && $response = $e->render($request)) { return Router::toResponse($request, $response); } @@ -364,7 +383,7 @@ public function render($request, Throwable $e) return $e->toResponse($request); } - $e = $this->prepareException($this->mapException($e)); + $e = $this->prepareException($e); if ($response = $this->renderViaCallbacks($request, $e)) { return $response; @@ -451,7 +470,7 @@ protected function renderViaCallbacks($request, Throwable $e) * * @param \Illuminate\Http\Request $request * @param \Throwable $e - * @return \Symfony\Component\HttpFoundation\Response + * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function renderExceptionResponse($request, Throwable $e) { @@ -465,7 +484,7 @@ protected function renderExceptionResponse($request, Throwable $e) * * @param \Illuminate\Http\Request $request * @param \Illuminate\Auth\AuthenticationException $exception - * @return \Symfony\Component\HttpFoundation\Response + * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function unauthenticated($request, AuthenticationException $exception) { @@ -497,7 +516,7 @@ protected function convertValidationExceptionToResponse(ValidationException $e, * * @param \Illuminate\Http\Request $request * @param \Illuminate\Validation\ValidationException $exception - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function invalid($request, ValidationException $exception) { @@ -538,7 +557,7 @@ protected function shouldReturnJson($request, Throwable $e) * * @param \Illuminate\Http\Request $request * @param \Throwable $e - * @return \Symfony\Component\HttpFoundation\Response + * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function prepareResponse($request, Throwable $e) { @@ -670,7 +689,7 @@ protected function getHttpExceptionView(HttpExceptionInterface $e) * * @param \Symfony\Component\HttpFoundation\Response $response * @param \Throwable $e - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { diff --git a/src/Illuminate/Foundation/Http/Exceptions/MaintenanceModeException.php b/src/Illuminate/Foundation/Http/Exceptions/MaintenanceModeException.php deleted file mode 100644 index 5553fde6..00000000 --- a/src/Illuminate/Foundation/Http/Exceptions/MaintenanceModeException.php +++ /dev/null @@ -1,58 +0,0 @@ -wentDownAt = Date::createFromTimestamp($time); - - if ($retryAfter) { - $this->retryAfter = $retryAfter; - - $this->willBeAvailableAt = Date::instance(Carbon::createFromTimestamp($time)->addRealSeconds($this->retryAfter)); - } - } -} diff --git a/src/Illuminate/Foundation/Http/FormRequest.php b/src/Illuminate/Foundation/Http/FormRequest.php index e4a1c061..2a88d9c5 100644 --- a/src/Illuminate/Foundation/Http/FormRequest.php +++ b/src/Illuminate/Foundation/Http/FormRequest.php @@ -96,6 +96,13 @@ protected function getValidatorInstance() $this->withValidator($validator); } + if (method_exists($this, 'after')) { + $validator->after($this->container->call( + $this->after(...), + ['validator' => $validator] + )); + } + $this->setValidator($validator); return $this->validator; diff --git a/src/Illuminate/Foundation/Http/Kernel.php b/src/Illuminate/Foundation/Http/Kernel.php index 5aa7e756..e91543cd 100644 --- a/src/Illuminate/Foundation/Http/Kernel.php +++ b/src/Illuminate/Foundation/Http/Kernel.php @@ -66,9 +66,18 @@ class Kernel implements KernelContract * The application's route middleware. * * @var array + * + * @deprecated */ protected $routeMiddleware = []; + /** + * The application's middleware aliases. + * + * @var array + */ + protected $middlewareAliases = []; + /** * All of the registered request duration handlers. * @@ -93,6 +102,7 @@ class Kernel implements KernelContract protected $middlewarePriority = [ \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class, \Illuminate\Cookie\Middleware\EncryptCookies::class, + \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \Illuminate\Contracts\Auth\Middleware\AuthenticatesRequests::class, @@ -445,7 +455,7 @@ protected function syncMiddlewareToRouter() $this->router->middlewareGroup($key, $middleware); } - foreach ($this->routeMiddleware as $key => $middleware) { + foreach (array_merge($this->routeMiddleware, $this->middlewareAliases) as $key => $middleware) { $this->router->aliasMiddleware($key, $middleware); } } @@ -504,13 +514,25 @@ public function getMiddlewareGroups() } /** - * Get the application's route middleware. + * Get the application's route middleware aliases. * * @return array + * + * @deprecated */ public function getRouteMiddleware() { - return $this->routeMiddleware; + return $this->getMiddlewareAliases(); + } + + /** + * Get the application's route middleware aliases. + * + * @return array + */ + public function getMiddlewareAliases() + { + return array_merge($this->routeMiddleware, $this->middlewareAliases); } /** diff --git a/src/Illuminate/Foundation/Http/Middleware/HandlePrecognitiveRequests.php b/src/Illuminate/Foundation/Http/Middleware/HandlePrecognitiveRequests.php index c37e2cf7..8df5c093 100644 --- a/src/Illuminate/Foundation/Http/Middleware/HandlePrecognitiveRequests.php +++ b/src/Illuminate/Foundation/Http/Middleware/HandlePrecognitiveRequests.php @@ -5,7 +5,6 @@ use Illuminate\Container\Container; use Illuminate\Foundation\Routing\PrecognitionCallableDispatcher; use Illuminate\Foundation\Routing\PrecognitionControllerDispatcher; -use Illuminate\Http\Response; use Illuminate\Routing\Contracts\CallableDispatcher as CallableDispatcherContract; use Illuminate\Routing\Contracts\ControllerDispatcher as ControllerDispatcherContract; diff --git a/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php b/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php index 81146787..69faa527 100644 --- a/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php +++ b/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php @@ -155,7 +155,7 @@ protected function getTokenFromRequest($request) if (! $token && $header = $request->header('X-XSRF-TOKEN')) { try { $token = CookieValuePrefix::remove($this->encrypter->decrypt($header, static::serialized())); - } catch (DecryptException $e) { + } catch (DecryptException) { $token = ''; } } diff --git a/src/Illuminate/Foundation/Precognition.php b/src/Illuminate/Foundation/Precognition.php index 8ea2a675..679b35ed 100644 --- a/src/Illuminate/Foundation/Precognition.php +++ b/src/Illuminate/Foundation/Precognition.php @@ -14,7 +14,7 @@ public static function afterValidationHook($request) { return function ($validator) use ($request) { if ($validator->messages()->isEmpty() && $request->headers->has('Precognition-Validate-Only')) { - abort(204); + abort(204, headers: ['Precognition-Success' => 'true']); } }; } diff --git a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php index 0f5aacff..bc6ac4ec 100755 --- a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php +++ b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php @@ -6,6 +6,7 @@ use Illuminate\Cache\Console\CacheTableCommand; use Illuminate\Cache\Console\ClearCommand as CacheClearCommand; use Illuminate\Cache\Console\ForgetCommand as CacheForgetCommand; +use Illuminate\Cache\Console\PruneStaleTagsCommand; use Illuminate\Console\Scheduling\ScheduleClearCacheCommand; use Illuminate\Console\Scheduling\ScheduleFinishCommand; use Illuminate\Console\Scheduling\ScheduleListCommand; @@ -22,10 +23,12 @@ use Illuminate\Database\Console\Seeds\SeedCommand; use Illuminate\Database\Console\Seeds\SeederMakeCommand; use Illuminate\Database\Console\ShowCommand; +use Illuminate\Database\Console\ShowModelCommand; use Illuminate\Database\Console\TableCommand as DatabaseTableCommand; use Illuminate\Database\Console\WipeCommand; use Illuminate\Foundation\Console\AboutCommand; use Illuminate\Foundation\Console\CastMakeCommand; +use Illuminate\Foundation\Console\ChannelListCommand; use Illuminate\Foundation\Console\ChannelMakeCommand; use Illuminate\Foundation\Console\ClearCompiledCommand; use Illuminate\Foundation\Console\ComponentMakeCommand; @@ -45,6 +48,7 @@ use Illuminate\Foundation\Console\ExceptionMakeCommand; use Illuminate\Foundation\Console\JobMakeCommand; use Illuminate\Foundation\Console\KeyGenerateCommand; +use Illuminate\Foundation\Console\LangPublishCommand; use Illuminate\Foundation\Console\ListenerMakeCommand; use Illuminate\Foundation\Console\MailMakeCommand; use Illuminate\Foundation\Console\ModelMakeCommand; @@ -63,7 +67,6 @@ use Illuminate\Foundation\Console\RuleMakeCommand; use Illuminate\Foundation\Console\ScopeMakeCommand; use Illuminate\Foundation\Console\ServeCommand; -use Illuminate\Foundation\Console\ShowModelCommand; use Illuminate\Foundation\Console\StorageLinkCommand; use Illuminate\Foundation\Console\StubPublishCommand; use Illuminate\Foundation\Console\TestMakeCommand; @@ -124,6 +127,7 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid 'Optimize' => OptimizeCommand::class, 'OptimizeClear' => OptimizeClearCommand::class, 'PackageDiscover' => PackageDiscoverCommand::class, + 'PruneStaleTagsCommand' => PruneStaleTagsCommand::class, 'QueueClear' => QueueClearCommand::class, 'QueueFailed' => ListFailedQueueCommand::class, 'QueueFlush' => FlushFailedQueueCommand::class, @@ -162,6 +166,7 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid protected $devCommands = [ 'CacheTable' => CacheTableCommand::class, 'CastMake' => CastMakeCommand::class, + 'ChannelList' => ChannelListCommand::class, 'ChannelMake' => ChannelMakeCommand::class, 'ComponentMake' => ComponentMakeCommand::class, 'ConsoleMake' => ConsoleMakeCommand::class, @@ -172,6 +177,7 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid 'ExceptionMake' => ExceptionMakeCommand::class, 'FactoryMake' => FactoryMakeCommand::class, 'JobMake' => JobMakeCommand::class, + 'LangPublish' => LangPublishCommand::class, 'ListenerMake' => ListenerMakeCommand::class, 'MailMake' => MailMakeCommand::class, 'MiddlewareMake' => MiddlewareMakeCommand::class, diff --git a/src/Illuminate/Foundation/Routing/PrecognitionCallableDispatcher.php b/src/Illuminate/Foundation/Routing/PrecognitionCallableDispatcher.php index 012dd3f1..66456a19 100644 --- a/src/Illuminate/Foundation/Routing/PrecognitionCallableDispatcher.php +++ b/src/Illuminate/Foundation/Routing/PrecognitionCallableDispatcher.php @@ -18,6 +18,6 @@ public function dispatch(Route $route, $callable) { $this->resolveParameters($route, $callable); - abort(204); + abort(204, headers: ['Precognition-Success' => 'true']); } } diff --git a/src/Illuminate/Foundation/Routing/PrecognitionControllerDispatcher.php b/src/Illuminate/Foundation/Routing/PrecognitionControllerDispatcher.php index 0edcb4ce..7ed86056 100644 --- a/src/Illuminate/Foundation/Routing/PrecognitionControllerDispatcher.php +++ b/src/Illuminate/Foundation/Routing/PrecognitionControllerDispatcher.php @@ -22,7 +22,7 @@ public function dispatch(Route $route, $controller, $method) $this->resolveParameters($route, $controller, $method); - abort(204); + abort(204, headers: ['Precognition-Success' => 'true']); } /** diff --git a/src/Illuminate/Foundation/Support/Providers/AuthServiceProvider.php b/src/Illuminate/Foundation/Support/Providers/AuthServiceProvider.php index 08295bbb..02d3388f 100644 --- a/src/Illuminate/Foundation/Support/Providers/AuthServiceProvider.php +++ b/src/Illuminate/Foundation/Support/Providers/AuthServiceProvider.php @@ -14,6 +14,18 @@ class AuthServiceProvider extends ServiceProvider */ protected $policies = []; + /** + * Register the application's policies. + * + * @return void + */ + public function register() + { + $this->booting(function () { + $this->registerPolicies(); + }); + } + /** * Register the application's policies. * diff --git a/src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php b/src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php index 4fb968bb..d966c5fd 100644 --- a/src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php +++ b/src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php @@ -25,7 +25,7 @@ class EventServiceProvider extends ServiceProvider /** * The model observers to register. * - * @var array + * @var array> */ protected $observers = []; diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithContainer.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithContainer.php index b19a5712..49b688cf 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithContainer.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithContainer.php @@ -5,6 +5,7 @@ use Closure; use Illuminate\Foundation\Mix; use Illuminate\Foundation\Vite; +use Illuminate\Support\Facades\Facade; use Illuminate\Support\HtmlString; use Mockery; @@ -110,6 +111,8 @@ protected function withoutVite() $this->originalVite = app(Vite::class); } + Facade::clearResolvedInstance(Vite::class); + $this->swap(Vite::class, new class { public function __invoke() diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php index 93a396b2..49c0e35e 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php @@ -215,7 +215,7 @@ protected function isSoftDeletableModel($model) * Cast a JSON string to a database compatible type. * * @param array|object|string $value - * @return \Illuminate\Database\Query\Expression + * @return \Illuminate\Contracts\Database\Query\Expression */ public function castAsJson($value) { diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php index e23ae4c3..7784736b 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php @@ -42,7 +42,7 @@ public function setUpRedis() $host = Env::get('REDIS_HOST', '127.0.0.1'); $port = Env::get('REDIS_PORT', 6379); - foreach ($this->redisDriverProvider() as $driver) { + foreach (static::redisDriverProvider() as $driver) { $this->redis[$driver[0]] = new RedisManager($app, $driver[0], [ 'cluster' => false, 'options' => [ @@ -60,7 +60,7 @@ public function setUpRedis() try { $this->redis['phpredis']->connection()->flushdb(); - } catch (Exception $e) { + } catch (Exception) { if ($host === '127.0.0.1' && $port === 6379 && Env::get('REDIS_HOST') === null) { static::$connectionFailedOnceWithDefaultsSkip = true; @@ -80,7 +80,7 @@ public function tearDownRedis() $this->redis['phpredis']->connection()->flushdb(); } - foreach ($this->redisDriverProvider() as $driver) { + foreach (static::redisDriverProvider() as $driver) { if (isset($this->redis[$driver[0]])) { $this->redis[$driver[0]]->connection()->disconnect(); } @@ -92,7 +92,7 @@ public function tearDownRedis() * * @return array */ - public function redisDriverProvider() + public static function redisDriverProvider() { return [ ['predis'], diff --git a/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php b/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php index ca310e60..8211e966 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php +++ b/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php @@ -329,11 +329,12 @@ public function get($uri, array $headers = []) * * @param string $uri * @param array $headers + * @param int $options * @return \Illuminate\Testing\TestResponse */ - public function getJson($uri, array $headers = []) + public function getJson($uri, array $headers = [], $options = 0) { - return $this->json('GET', $uri, [], $headers); + return $this->json('GET', $uri, [], $headers, $options); } /** @@ -358,11 +359,12 @@ public function post($uri, array $data = [], array $headers = []) * @param string $uri * @param array $data * @param array $headers + * @param int $options * @return \Illuminate\Testing\TestResponse */ - public function postJson($uri, array $data = [], array $headers = []) + public function postJson($uri, array $data = [], array $headers = [], $options = 0) { - return $this->json('POST', $uri, $data, $headers); + return $this->json('POST', $uri, $data, $headers, $options); } /** @@ -387,11 +389,12 @@ public function put($uri, array $data = [], array $headers = []) * @param string $uri * @param array $data * @param array $headers + * @param int $options * @return \Illuminate\Testing\TestResponse */ - public function putJson($uri, array $data = [], array $headers = []) + public function putJson($uri, array $data = [], array $headers = [], $options = 0) { - return $this->json('PUT', $uri, $data, $headers); + return $this->json('PUT', $uri, $data, $headers, $options); } /** @@ -416,11 +419,12 @@ public function patch($uri, array $data = [], array $headers = []) * @param string $uri * @param array $data * @param array $headers + * @param int $options * @return \Illuminate\Testing\TestResponse */ - public function patchJson($uri, array $data = [], array $headers = []) + public function patchJson($uri, array $data = [], array $headers = [], $options = 0) { - return $this->json('PATCH', $uri, $data, $headers); + return $this->json('PATCH', $uri, $data, $headers, $options); } /** @@ -445,11 +449,12 @@ public function delete($uri, array $data = [], array $headers = []) * @param string $uri * @param array $data * @param array $headers + * @param int $options * @return \Illuminate\Testing\TestResponse */ - public function deleteJson($uri, array $data = [], array $headers = []) + public function deleteJson($uri, array $data = [], array $headers = [], $options = 0) { - return $this->json('DELETE', $uri, $data, $headers); + return $this->json('DELETE', $uri, $data, $headers, $options); } /** @@ -475,11 +480,12 @@ public function options($uri, array $data = [], array $headers = []) * @param string $uri * @param array $data * @param array $headers + * @param int $options * @return \Illuminate\Testing\TestResponse */ - public function optionsJson($uri, array $data = [], array $headers = []) + public function optionsJson($uri, array $data = [], array $headers = [], $options = 0) { - return $this->json('OPTIONS', $uri, $data, $headers); + return $this->json('OPTIONS', $uri, $data, $headers, $options); } /** @@ -505,13 +511,14 @@ public function head($uri, array $headers = []) * @param string $uri * @param array $data * @param array $headers + * @param int $options * @return \Illuminate\Testing\TestResponse */ - public function json($method, $uri, array $data = [], array $headers = []) + public function json($method, $uri, array $data = [], array $headers = [], $options = 0) { $files = $this->extractFilesFromDataArray($data); - $content = json_encode($data); + $content = json_encode($data, $options); $headers = array_merge([ 'CONTENT_LENGTH' => mb_strlen($content, '8bit'), diff --git a/src/Illuminate/Foundation/Testing/Concerns/MocksApplicationServices.php b/src/Illuminate/Foundation/Testing/Concerns/MocksApplicationServices.php deleted file mode 100644 index 66622950..00000000 --- a/src/Illuminate/Foundation/Testing/Concerns/MocksApplicationServices.php +++ /dev/null @@ -1,289 +0,0 @@ -withoutEvents(); - - $this->beforeApplicationDestroyed(function () use ($events) { - $fired = $this->getFiredEvents($events); - - $this->assertEmpty( - $eventsNotFired = array_diff($events, $fired), - 'These expected events were not fired: ['.implode(', ', $eventsNotFired).']' - ); - }); - - return $this; - } - - /** - * Specify a list of events that should not be fired for the given operation. - * - * These events will be mocked, so that handlers will not actually be executed. - * - * @param array|string $events - * @return $this - */ - public function doesntExpectEvents($events) - { - $events = is_array($events) ? $events : func_get_args(); - - $this->withoutEvents(); - - $this->beforeApplicationDestroyed(function () use ($events) { - $this->assertEmpty( - $fired = $this->getFiredEvents($events), - 'These unexpected events were fired: ['.implode(', ', $fired).']' - ); - }); - - return $this; - } - - /** - * Mock the event dispatcher so all events are silenced and collected. - * - * @return $this - */ - protected function withoutEvents() - { - $mock = Mockery::mock(EventsDispatcherContract::class)->shouldIgnoreMissing(); - - $mock->shouldReceive('dispatch', 'until')->andReturnUsing(function ($called) { - $this->firedEvents[] = $called; - }); - - Event::clearResolvedInstances(); - - $this->app->instance('events', $mock); - - return $this; - } - - /** - * Filter the given events against the fired events. - * - * @param array $events - * @return array - */ - protected function getFiredEvents(array $events) - { - return $this->getDispatched($events, $this->firedEvents); - } - - /** - * Specify a list of jobs that should be dispatched for the given operation. - * - * These jobs will be mocked, so that handlers will not actually be executed. - * - * @param array|string $jobs - * @return $this - */ - protected function expectsJobs($jobs) - { - $jobs = is_array($jobs) ? $jobs : func_get_args(); - - $this->withoutJobs(); - - $this->beforeApplicationDestroyed(function () use ($jobs) { - $dispatched = $this->getDispatchedJobs($jobs); - - $this->assertEmpty( - $jobsNotDispatched = array_diff($jobs, $dispatched), - 'These expected jobs were not dispatched: ['.implode(', ', $jobsNotDispatched).']' - ); - }); - - return $this; - } - - /** - * Specify a list of jobs that should not be dispatched for the given operation. - * - * These jobs will be mocked, so that handlers will not actually be executed. - * - * @param array|string $jobs - * @return $this - */ - protected function doesntExpectJobs($jobs) - { - $jobs = is_array($jobs) ? $jobs : func_get_args(); - - $this->withoutJobs(); - - $this->beforeApplicationDestroyed(function () use ($jobs) { - $this->assertEmpty( - $dispatched = $this->getDispatchedJobs($jobs), - 'These unexpected jobs were dispatched: ['.implode(', ', $dispatched).']' - ); - }); - - return $this; - } - - /** - * Mock the job dispatcher so all jobs are silenced and collected. - * - * @return $this - */ - protected function withoutJobs() - { - $mock = Mockery::mock(BusDispatcherContract::class)->shouldIgnoreMissing(); - - $mock->shouldReceive('dispatch', 'dispatchNow')->andReturnUsing(function ($dispatched) { - $this->dispatchedJobs[] = $dispatched; - }); - - $this->app->instance( - BusDispatcherContract::class, $mock - ); - - return $this; - } - - /** - * Filter the given jobs against the dispatched jobs. - * - * @param array $jobs - * @return array - */ - protected function getDispatchedJobs(array $jobs) - { - return $this->getDispatched($jobs, $this->dispatchedJobs); - } - - /** - * Filter the given classes against an array of dispatched classes. - * - * @param array $classes - * @param array $dispatched - * @return array - */ - protected function getDispatched(array $classes, array $dispatched) - { - return array_filter($classes, function ($class) use ($dispatched) { - return $this->wasDispatched($class, $dispatched); - }); - } - - /** - * Check if the given class exists in an array of dispatched classes. - * - * @param string $needle - * @param array $haystack - * @return bool - */ - protected function wasDispatched($needle, array $haystack) - { - foreach ($haystack as $dispatched) { - if ((is_string($dispatched) && ($dispatched === $needle || is_subclass_of($dispatched, $needle))) || - $dispatched instanceof $needle) { - return true; - } - } - - return false; - } - - /** - * Mock the notification dispatcher so all notifications are silenced. - * - * @return $this - */ - protected function withoutNotifications() - { - $mock = Mockery::mock(NotificationDispatcher::class); - - $mock->shouldReceive('send')->andReturnUsing(function ($notifiable, $instance, $channels = []) { - $this->dispatchedNotifications[] = compact( - 'notifiable', 'instance', 'channels' - ); - }); - - $this->app->instance(NotificationDispatcher::class, $mock); - - return $this; - } - - /** - * Specify a notification that is expected to be dispatched. - * - * @param mixed $notifiable - * @param string $notification - * @return $this - */ - protected function expectsNotification($notifiable, $notification) - { - $this->withoutNotifications(); - - $this->beforeApplicationDestroyed(function () use ($notifiable, $notification) { - foreach ($this->dispatchedNotifications as $dispatched) { - $notified = $dispatched['notifiable']; - - if (($notified === $notifiable || - $notified->getKey() == $notifiable->getKey()) && - get_class($dispatched['instance']) === $notification - ) { - return $this; - } - } - - $this->fail('The following expected notification were not dispatched: ['.$notification.']'); - }); - - return $this; - } -} diff --git a/src/Illuminate/Foundation/Testing/TestCase.php b/src/Illuminate/Foundation/Testing/TestCase.php index e7968631..a7315a2c 100644 --- a/src/Illuminate/Foundation/Testing/TestCase.php +++ b/src/Illuminate/Foundation/Testing/TestCase.php @@ -10,12 +10,12 @@ use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Facade; use Illuminate\Support\Facades\ParallelTesting; +use Illuminate\Support\Sleep; use Illuminate\Support\Str; use Illuminate\View\Component; use Mockery; use Mockery\Exception\InvalidCountException; use PHPUnit\Framework\TestCase as BaseTestCase; -use PHPUnit\Util\Annotation\Registry; use Throwable; abstract class TestCase extends BaseTestCase @@ -29,8 +29,7 @@ abstract class TestCase extends BaseTestCase Concerns\InteractsWithExceptionHandling, Concerns\InteractsWithSession, Concerns\InteractsWithTime, - Concerns\InteractsWithViews, - Concerns\MocksApplicationServices; + Concerns\InteractsWithViews; /** * The Illuminate application instance. @@ -164,6 +163,26 @@ protected function setUpTraits() return $uses; } + /** + * {@inheritdoc} + */ + protected function runTest(): mixed + { + $result = null; + + try { + $result = parent::runTest(); + } catch (Throwable $e) { + if (! is_null(static::$latestResponse)) { + static::$latestResponse->transformNotSuccessfulException($e); + } + + throw $e; + } + + return $result; + } + /** * Clean up the testing environment before the next test. * @@ -227,6 +246,7 @@ protected function tearDown(): void Component::forgetFactory(); Queue::createPayloadUsing(null); HandleExceptions::forgetApp(); + Sleep::fake(false); if ($this->callbackException) { throw $this->callbackException; @@ -242,10 +262,17 @@ public static function tearDownAfterClass(): void { static::$latestResponse = null; - (function () { - $this->classDocBlocks = []; - $this->methodDocBlocks = []; - })->call(Registry::getInstance()); + foreach ([ + \PHPUnit\Util\Annotation\Registry::class, + \PHPUnit\Metadata\Annotation\Parser\Registry::class, + ] as $class) { + if (class_exists($class)) { + (function () { + $this->classDocBlocks = []; + $this->methodDocBlocks = []; + })->call($class::getInstance()); + } + } } /** @@ -291,19 +318,4 @@ protected function callBeforeApplicationDestroyedCallbacks() } } } - - /** - * This method is called when a test method did not execute successfully. - * - * @param \Throwable $exception - * @return void - */ - protected function onNotSuccessfulTest(Throwable $exception): void - { - parent::onNotSuccessfulTest( - is_null(static::$latestResponse) - ? $exception - : static::$latestResponse->transformNotSuccessfulException($exception) - ); - } } diff --git a/src/Illuminate/Foundation/Testing/WithConsoleEvents.php b/src/Illuminate/Foundation/Testing/WithConsoleEvents.php new file mode 100644 index 00000000..5c4fe991 --- /dev/null +++ b/src/Illuminate/Foundation/Testing/WithConsoleEvents.php @@ -0,0 +1,18 @@ +app[ConsoleKernel::class]->rerouteSymfonyCommandEvents(); + } +} diff --git a/src/Illuminate/Foundation/Validation/ValidatesRequests.php b/src/Illuminate/Foundation/Validation/ValidatesRequests.php index 7b2b9e03..bf2aecdd 100644 --- a/src/Illuminate/Foundation/Validation/ValidatesRequests.php +++ b/src/Illuminate/Foundation/Validation/ValidatesRequests.php @@ -42,16 +42,16 @@ public function validateWith($validator, Request $request = null) * @param \Illuminate\Http\Request $request * @param array $rules * @param array $messages - * @param array $customAttributes + * @param array $attributes * @return array * * @throws \Illuminate\Validation\ValidationException */ public function validate(Request $request, array $rules, - array $messages = [], array $customAttributes = []) + array $messages = [], array $attributes = []) { $validator = $this->getValidationFactory()->make( - $request->all(), $rules, $messages, $customAttributes + $request->all(), $rules, $messages, $attributes ); if ($request->isPrecognitive()) { @@ -71,16 +71,16 @@ public function validate(Request $request, array $rules, * @param \Illuminate\Http\Request $request * @param array $rules * @param array $messages - * @param array $customAttributes + * @param array $attributes * @return array * * @throws \Illuminate\Validation\ValidationException */ public function validateWithBag($errorBag, Request $request, array $rules, - array $messages = [], array $customAttributes = []) + array $messages = [], array $attributes = []) { try { - return $this->validate($request, $rules, $messages, $customAttributes); + return $this->validate($request, $rules, $messages, $attributes); } catch (ValidationException $e) { $e->errorBag = $errorBag; diff --git a/src/Illuminate/Foundation/helpers.php b/src/Illuminate/Foundation/helpers.php index 8540f487..5fac6d8b 100644 --- a/src/Illuminate/Foundation/helpers.php +++ b/src/Illuminate/Foundation/helpers.php @@ -109,7 +109,7 @@ function action($name, $parameters = [], $absolute = true) * * @param string|null $abstract * @param array $parameters - * @return mixed|\Illuminate\Contracts\Foundation\Application + * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Foundation\Application|mixed */ function app($abstract = null, array $parameters = []) { @@ -226,15 +226,13 @@ function broadcast($event = null) * * If an array is passed, we'll assume you want to put to the cache. * - * @param dynamic key|key,default|data,expiration|null + * @param mixed ...$arguments key|key,default|data,expiration|null * @return mixed|\Illuminate\Cache\CacheManager * * @throws \InvalidArgumentException */ - function cache() + function cache(...$arguments) { - $arguments = func_get_args(); - if (empty($arguments)) { return app('cache'); } @@ -407,22 +405,6 @@ function dispatch_sync($job, $handler = null) } } -if (! function_exists('dispatch_now')) { - /** - * Dispatch a command to its appropriate handler in the current process. - * - * @param mixed $job - * @param mixed $handler - * @return mixed - * - * @deprecated Will be removed in a future Laravel version. - */ - function dispatch_now($job, $handler = null) - { - return app(Dispatcher::class)->dispatchNow($job, $handler); - } -} - if (! function_exists('encrypt')) { /** * Encrypt the given value. @@ -628,7 +610,7 @@ function precognitive($callable = null) }); if (request()->isPrecognitive()) { - abort(204); + abort(204, headers: ['Precognition-Success' => 'true']); } return $payload; @@ -644,7 +626,7 @@ function precognitive($callable = null) */ function public_path($path = '') { - return app()->make('path.public').($path ? DIRECTORY_SEPARATOR.ltrim($path, DIRECTORY_SEPARATOR) : $path); + return app()->publicPath($path); } } @@ -816,7 +798,7 @@ function response($content = '', $status = 200, array $headers = []) /** * Generate the URL to a named route. * - * @param array|string $name + * @param string $name * @param mixed $parameters * @param bool $absolute * @return string @@ -1000,10 +982,10 @@ function url($path = null, $parameters = [], $secure = null) * @param array $data * @param array $rules * @param array $messages - * @param array $customAttributes + * @param array $attributes * @return \Illuminate\Contracts\Validation\Validator|\Illuminate\Contracts\Validation\Factory */ - function validator(array $data = [], array $rules = [], array $messages = [], array $customAttributes = []) + function validator(array $data = [], array $rules = [], array $messages = [], array $attributes = []) { $factory = app(ValidationFactory::class); @@ -1011,7 +993,7 @@ function validator(array $data = [], array $rules = [], array $messages = [], ar return $factory; } - return $factory->make($data, $rules, $messages, $customAttributes); + return $factory->make($data, $rules, $messages, $attributes); } } diff --git a/src/Illuminate/Foundation/stubs/facade.stub b/src/Illuminate/Foundation/stubs/facade.stub index aadbe746..183dc268 100644 --- a/src/Illuminate/Foundation/stubs/facade.stub +++ b/src/Illuminate/Foundation/stubs/facade.stub @@ -11,10 +11,8 @@ class DummyClass extends Facade { /** * Get the registered name of the component. - * - * @return string */ - protected static function getFacadeAccessor() + protected static function getFacadeAccessor(): string { return 'DummyTarget'; } diff --git a/src/Roots/Acorn/Application.php b/src/Roots/Acorn/Application.php index 4a74db39..16949633 100644 --- a/src/Roots/Acorn/Application.php +++ b/src/Roots/Acorn/Application.php @@ -27,35 +27,14 @@ class Application extends FoundationApplication * * @var string */ - public const VERSION = '3.x-dev'; - - /** - * The custom bootstrap path defined by the developer. - * - * @var string - */ - protected $bootstrapPath; - - /** - * The custom config path defined by the developer. - * - * @var string - */ - protected $configPath; - - /** - * The custom public path defined by the developer. - * - * @var string - */ - protected $publicPath; + public const VERSION = '4.x-dev'; /** * The custom resources path defined by the developer. * * @var string */ - protected $resourcesPath; + protected $resourcePath; /** * Create a new Illuminate application instance. @@ -66,6 +45,9 @@ class Application extends FoundationApplication */ public function __construct($basePath = null, $paths = null) { + if ($basePath) { + $this->basePath = rtrim($basePath, '\/'); + } if ($paths) { $this->usePaths((array)$paths); } @@ -110,7 +92,7 @@ public function usePaths(array $paths) 'public' => 'publicPath', 'storage' => 'storagePath', 'database' => 'databasePath', - 'resources' => 'resourcesPath', + 'resources' => 'resourcePath', 'bootstrap' => 'bootstrapPath', ]; @@ -130,82 +112,26 @@ public function usePaths(array $paths) } /** - * Get the path to the bootstrap directory. - * - * @param string $path Optionally, a path to append to the bootstrap path - * @return string - */ - public function bootstrapPath($path = '') - { - return ($this->bootstrapPath ?: $this->basePath . DIRECTORY_SEPARATOR . 'bootstrap') - . ($path ? DIRECTORY_SEPARATOR . $path : $path); - } - - /** - * Set the bootstrap directory. - * - * @param string $path - * @return $this - */ - public function useBootstrapPath($path) - { - $this->bootstrapPath = $path; - - $this->instance('path.bootstrap', $path); - - return $this; - } - - /** - * Get the path to the application configuration files. - * - * @param string $path Optionally, a path to append to the config path - * @return string - */ - public function configPath($path = '') - { - return ($this->configPath ?: $this->basePath . DIRECTORY_SEPARATOR . 'config') - . ($path ? DIRECTORY_SEPARATOR . $path : $path); - } - - /** - * Set the config directory. + * Bind all of the application paths in the container. * - * @param string $path - * @return $this + * @return void */ - public function useConfigPath($path) + protected function bindPathsInContainer() { - $this->configPath = $path; - - $this->instance('path.config', $path); - - return $this; + $bootstrapPath = $this->bootstrapPath(); + parent::bindPathsInContainer(); + $this->instance('path.bootstrap', $bootstrapPath); } /** - * Get the path to the public / web directory. + * Get the path to the bootstrap directory. * + * @param string $path Optionally, a path to append to the bootstrap path * @return string */ - public function publicPath() - { - return $this->publicPath ?: $this->basePath . DIRECTORY_SEPARATOR . 'public'; - } - - /** - * Set the public directory. - * - * @param string $path - * @return $this - */ - public function usePublicPath($path) + public function bootstrapPath($path = '') { - $this->publicPath = $path; - - $this->instance('path.public', $path); - - return $this; + return $this->joinPaths($this->bootstrapPath ?: $this->storagePath('framework')); } /** @@ -216,8 +142,7 @@ public function usePublicPath($path) */ public function resourcePath($path = '') { - return ($this->resourcesPath ?: $this->basePath . DIRECTORY_SEPARATOR . 'resources') - . ($path ? DIRECTORY_SEPARATOR . $path : $path); + return $this->joinPaths($this->resourcePath ?: $this->basePath('resources'), $path); } /** @@ -228,7 +153,7 @@ public function resourcePath($path = '') */ public function useResourcePath($path) { - $this->resourcesPath = $path; + $this->resourcePath = $path; $this->instance('path.resources', $path); diff --git a/src/Roots/Acorn/Bootloader.php b/src/Roots/Acorn/Bootloader.php index 9a00114b..b8c9d79d 100644 --- a/src/Roots/Acorn/Bootloader.php +++ b/src/Roots/Acorn/Bootloader.php @@ -223,7 +223,7 @@ protected function bootHttp(ApplicationContract $app) add_filter( 'do_parse_request', fn ($do_parse, \WP $wp, $extra_query_vars) => - apply_filters('acorn/router/do_parse_request', $do_parse, $wp, $extra_query_vars), + apply_filters('acorn/router/do_parse_request', $do_parse, $wp, $extra_query_vars), 100, 3 ); From 15d84fabd62bad3441c9c1db5b8b949621e617a9 Mon Sep 17 00:00:00 2001 From: QWp6t Date: Sun, 25 Jun 2023 12:22:25 -0700 Subject: [PATCH 02/48] =?UTF-8?q?=F0=9F=91=B7=20php=208.1=20no=20longer=20?= =?UTF-8?q?supported?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c29b5cbc..7b8da9ce 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ jobs: if: "!contains(github.event.head_commit.message, '[ci skip]')" strategy: matrix: - php: ['8.0', '8.1', '8.2'] + php: ['8.1', '8.2'] steps: - name: Checkout the project From aa73bd4bdb587274125507d269fc13ecc64c75b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Fri, 3 Nov 2023 21:52:06 +0100 Subject: [PATCH 03/48] =?UTF-8?q?=F0=9F=94=A7=20flag=20files=20not=20repre?= =?UTF-8?q?senting=20source=20code=20(#312)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index 37d1332c..499181d8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,4 +2,5 @@ /.github export-ignore /.gitattributes export-ignore /scripts export-ignore -*.css linguist-detectable=false +/src/Illuminate/Foundation/** linguist-vendored +/tests/Assets/__fixtures__/** -linguist-detectable From d96c0737c43a73dc4ce7797ea75f62abd1ea36a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Fri, 3 Nov 2023 21:54:38 +0100 Subject: [PATCH 04/48] =?UTF-8?q?=F0=9F=92=AC=20fix=20typos=20(#304)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php | 2 +- .../{BudCompatabilityTest.php => BudCompatibilityTest.php} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename tests/Assets/{BudCompatabilityTest.php => BudCompatibilityTest.php} (100%) diff --git a/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php b/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php index 75f9ef4b..10f4e8ec 100644 --- a/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php +++ b/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php @@ -44,7 +44,7 @@ public function filterTemplateInclude($file) } /** - * Add Blade compatability for theme templates. + * Add Blade compatibility for theme templates. * * NOTE: Internally, WordPress interchangeably uses "page templates" "post templates" and "theme templates" * diff --git a/tests/Assets/BudCompatabilityTest.php b/tests/Assets/BudCompatibilityTest.php similarity index 100% rename from tests/Assets/BudCompatabilityTest.php rename to tests/Assets/BudCompatibilityTest.php From 7e413cb9143c3fdf9e976ae5d3f6e594a8d8a157 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 16 Nov 2023 12:48:40 -0600 Subject: [PATCH 05/48] =?UTF-8?q?=E2=AC=86=20Bump=20`illuminate/foundation?= =?UTF-8?q?`=20to=20latest=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Illuminate/Foundation/Application.php | 24 +- .../Auth/EmailVerificationRequest.php | 2 +- .../Foundation/Console/AboutCommand.php | 24 +- .../Foundation/Console/ChannelListCommand.php | 2 +- .../Foundation/Console/CliDumper.php | 2 +- .../Console/ComponentMakeCommand.php | 3 + .../Foundation/Console/ConfigShowCommand.php | 124 +++++++++ .../Foundation/Console/DocsCommand.php | 34 +-- src/Illuminate/Foundation/Console/Kernel.php | 32 ++- .../Console/ListenerMakeCommand.php | 11 +- .../Foundation/Console/ModelMakeCommand.php | 29 +-- .../Console/ObserverMakeCommand.php | 9 +- .../Foundation/Console/PolicyMakeCommand.php | 9 +- .../Foundation/Console/QueuedCommand.php | 10 + .../Foundation/Console/RouteListCommand.php | 4 +- .../Foundation/Console/ServeCommand.php | 18 +- .../Foundation/Console/TestMakeCommand.php | 18 +- .../Console/VendorPublishCommand.php | 28 ++- .../Foundation/Console/ViewCacheCommand.php | 8 +- .../Foundation/Console/ViewMakeCommand.php | 236 ++++++++++++++++++ .../Foundation/Console/stubs/request.stub | 2 +- .../Foundation/Console/stubs/view.pest.stub | 9 + .../Foundation/Console/stubs/view.stub | 3 + .../Foundation/Console/stubs/view.test.stub | 20 ++ .../Foundation/Events/DiscoverEvents.php | 22 ++ .../Foundation/Events/Dispatchable.php | 6 +- .../Foundation/Exceptions/Handler.php | 129 +++++++++- .../Foundation/Http/FormRequest.php | 5 +- src/Illuminate/Foundation/Http/Kernel.php | 6 + .../Middleware/HandlePrecognitiveRequests.php | 2 +- .../PreventRequestsDuringMaintenance.php | 19 +- .../Providers/ArtisanServiceProvider.php | 6 + .../Providers/FoundationServiceProvider.php | 4 +- .../Concerns/InteractsWithDatabase.php | 26 +- .../InteractsWithDeprecationHandling.php | 4 +- .../Testing/Concerns/MakesHttpRequests.php | 12 +- .../Testing/DatabaseTransactions.php | 9 +- .../Testing/DatabaseTransactionsManager.php | 47 ++++ .../Foundation/Testing/DatabaseTruncation.php | 55 +++- .../Foundation/Testing/RefreshDatabase.php | 9 +- src/Illuminate/Foundation/Vite.php | 28 ++- .../ViteManifestNotFoundException.php | 10 + src/Illuminate/Foundation/helpers.php | 11 +- 43 files changed, 944 insertions(+), 127 deletions(-) create mode 100644 src/Illuminate/Foundation/Console/ConfigShowCommand.php create mode 100644 src/Illuminate/Foundation/Console/ViewMakeCommand.php create mode 100644 src/Illuminate/Foundation/Console/stubs/view.pest.stub create mode 100644 src/Illuminate/Foundation/Console/stubs/view.stub create mode 100644 src/Illuminate/Foundation/Console/stubs/view.test.stub create mode 100644 src/Illuminate/Foundation/Testing/DatabaseTransactionsManager.php create mode 100644 src/Illuminate/Foundation/ViteManifestNotFoundException.php diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index 09b3387d..bf1b10d4 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -38,7 +38,7 @@ class Application extends Container implements ApplicationContract, CachesConfig * * @var string */ - const VERSION = '10.13.5'; + const VERSION = '10.32.1'; /** * The base path for the Laravel installation. @@ -529,6 +529,10 @@ public function usePublicPath($path) */ public function storagePath($path = '') { + if (isset($_ENV['LARAVEL_STORAGE_PATH'])) { + return $this->joinPaths($this->storagePath ?: $_ENV['LARAVEL_STORAGE_PATH'], $path); + } + return $this->joinPaths($this->storagePath ?: $this->basePath('storage'), $path); } @@ -705,6 +709,24 @@ public function runningInConsole() return $this->isRunningInConsole; } + /** + * Determine if the application is running any of the given console commands. + * + * @param string|array ...$commands + * @return bool + */ + public function runningConsoleCommand(...$commands) + { + if (! $this->runningInConsole()) { + return false; + } + + return in_array( + $_SERVER['argv'][1] ?? null, + is_array($commands[0]) ? $commands[0] : $commands + ); + } + /** * Determine if the application is running unit tests. * diff --git a/src/Illuminate/Foundation/Auth/EmailVerificationRequest.php b/src/Illuminate/Foundation/Auth/EmailVerificationRequest.php index ab5fa56c..96566829 100644 --- a/src/Illuminate/Foundation/Auth/EmailVerificationRequest.php +++ b/src/Illuminate/Foundation/Auth/EmailVerificationRequest.php @@ -56,7 +56,7 @@ public function fulfill() * Configure the validator instance. * * @param \Illuminate\Validation\Validator $validator - * @return void + * @return \Illuminate\Validation\Validator */ public function withValidator(Validator $validator) { diff --git a/src/Illuminate/Foundation/Console/AboutCommand.php b/src/Illuminate/Foundation/Console/AboutCommand.php index 1d1b47e9..3b632b3a 100644 --- a/src/Illuminate/Foundation/Console/AboutCommand.php +++ b/src/Illuminate/Foundation/Console/AboutCommand.php @@ -91,7 +91,7 @@ public function handle() return $index === false ? 99 : $index; }) ->filter(function ($data, $key) { - return $this->option('only') ? in_array(Str::of($key)->lower()->snake(), $this->sections()) : true; + return $this->option('only') ? in_array($this->toSearchKeyword($key), $this->sections()) : true; }) ->pipe(fn ($data) => $this->display($data)); @@ -141,7 +141,11 @@ protected function displayDetail($data) protected function displayJson($data) { $output = $data->flatMap(function ($data, $section) { - return [(string) Str::of($section)->snake() => $data->mapWithKeys(fn ($item, $key) => [(string) Str::of($item[0])->lower()->snake() => value($item[1])])]; + return [ + (string) Str::of($section)->snake() => $data->mapWithKeys(fn ($item, $key) => [ + $this->toSearchKeyword($item[0]) => value($item[1]), + ]), + ]; }); $this->output->writeln(strip_tags(json_encode($output))); @@ -250,6 +254,20 @@ protected static function addToSection(string $section, $data, string $value = n */ protected function sections() { - return array_filter(explode(',', $this->option('only') ?? '')); + return collect(explode(',', $this->option('only') ?? '')) + ->filter() + ->map(fn ($only) => $this->toSearchKeyword($only)) + ->all(); + } + + /** + * Format the given string for searching. + * + * @param string $value + * @return string + */ + protected function toSearchKeyword(string $value) + { + return (string) Str::of($value)->lower()->snake(); } } diff --git a/src/Illuminate/Foundation/Console/ChannelListCommand.php b/src/Illuminate/Foundation/Console/ChannelListCommand.php index dda760a4..8e4d8bac 100644 --- a/src/Illuminate/Foundation/Console/ChannelListCommand.php +++ b/src/Illuminate/Foundation/Console/ChannelListCommand.php @@ -109,7 +109,7 @@ protected function forCli($channels) } /** - * Determine and return the output for displaying the number of registered chanels in the CLI output. + * Determine and return the output for displaying the number of registered channels in the CLI output. * * @param \Illuminate\Support\Collection $channels * @param int $terminalWidth diff --git a/src/Illuminate/Foundation/Console/CliDumper.php b/src/Illuminate/Foundation/Console/CliDumper.php index beed2f2a..304dfcb0 100644 --- a/src/Illuminate/Foundation/Console/CliDumper.php +++ b/src/Illuminate/Foundation/Console/CliDumper.php @@ -94,7 +94,7 @@ public function dumpWithSource(Data $data) $output = (string) $this->dump($data, true); $lines = explode("\n", $output); - $lines[0] .= $this->getDumpSourceContent(); + $lines[array_key_last($lines) - 1] .= $this->getDumpSourceContent(); $this->output->write(implode("\n", $lines)); diff --git a/src/Illuminate/Foundation/Console/ComponentMakeCommand.php b/src/Illuminate/Foundation/Console/ComponentMakeCommand.php index c1c095e3..183206ee 100644 --- a/src/Illuminate/Foundation/Console/ComponentMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ComponentMakeCommand.php @@ -2,6 +2,7 @@ namespace Illuminate\Foundation\Console; +use Illuminate\Console\Concerns\CreatesMatchingTest; use Illuminate\Console\GeneratorCommand; use Illuminate\Foundation\Inspiring; use Illuminate\Support\Str; @@ -11,6 +12,8 @@ #[AsCommand(name: 'make:component')] class ComponentMakeCommand extends GeneratorCommand { + use CreatesMatchingTest; + /** * The console command name. * diff --git a/src/Illuminate/Foundation/Console/ConfigShowCommand.php b/src/Illuminate/Foundation/Console/ConfigShowCommand.php new file mode 100644 index 00000000..60b6b4e2 --- /dev/null +++ b/src/Illuminate/Foundation/Console/ConfigShowCommand.php @@ -0,0 +1,124 @@ +argument('config'); + + if (! config()->has($config)) { + $this->components->error("Configuration file `{$config}` does not exist."); + + return Command::FAILURE; + } + + $this->newLine(); + $this->render($config); + $this->newLine(); + + return Command::SUCCESS; + } + + /** + * Render the configuration values. + * + * @param string $name + * @return void + */ + public function render($name) + { + $data = config($name); + + if (! is_array($data)) { + $this->title($name, $this->formatValue($data)); + + return; + } + + $this->title($name); + + foreach (Arr::dot($data) as $key => $value) { + $this->components->twoColumnDetail( + $this->formatKey($key), + $this->formatValue($value) + ); + } + } + + /** + * Render the title. + * + * @param string $title + * @param string|null $subtitle + * @return void + */ + public function title($title, $subtitle = null) + { + $this->components->twoColumnDetail( + "{$title}", + $subtitle, + ); + } + + /** + * Format the given configuration key. + * + * @param string $key + * @return string + */ + protected function formatKey($key) + { + return preg_replace_callback( + '/(.*)\.(.*)$/', fn ($matches) => sprintf( + '%s ⇁ %s', + str_replace('.', ' ⇁ ', $matches[1]), + $matches[2] + ), $key + ); + } + + /** + * Format the given configuration value. + * + * @param mixed $value + * @return string + */ + protected function formatValue($value) + { + return match (true) { + is_bool($value) => sprintf('%s', $value ? 'true' : 'false'), + is_null($value) => 'null', + is_numeric($value) => "{$value}", + is_array($value) => '[]', + is_object($value) => get_class($value), + is_string($value) => $value, + default => print_r($value, true), + }; + } +} diff --git a/src/Illuminate/Foundation/Console/DocsCommand.php b/src/Illuminate/Foundation/Console/DocsCommand.php index b8f67862..b8a36749 100644 --- a/src/Illuminate/Foundation/Console/DocsCommand.php +++ b/src/Illuminate/Foundation/Console/DocsCommand.php @@ -16,6 +16,8 @@ use Symfony\Component\Process\Process; use Throwable; +use function Laravel\Prompts\suggest; + #[AsCommand(name: 'docs')] class DocsCommand extends Command { @@ -38,7 +40,7 @@ class DocsCommand extends Command * * @var string */ - protected $help = 'If you would like to perform a content search against the documention, you may call: php artisan docs -- search query here'; + protected $help = 'If you would like to perform a content search against the documentation, you may call: php artisan docs -- search query here'; /** * The HTTP client instance. @@ -179,7 +181,7 @@ protected function resolvePage() return $this->didNotRequestPage() ? $this->askForPage() - : $this->guessPage(); + : $this->guessPage($this->argument('page')); } /** @@ -229,18 +231,20 @@ protected function askForPageViaCustomStrategy() */ protected function askForPageViaAutocomplete() { - $choice = $this->components->choice( - 'Which page would you like to open?', - $this->pages()->mapWithKeys(fn ($option) => [ - Str::lower($option['title']) => $option['title'], - ])->all(), - 'installation', - 3 + $choice = suggest( + label: 'Which page would you like to open?', + options: fn ($value) => $this->pages() + ->mapWithKeys(fn ($option) => [ + Str::lower($option['title']) => $option['title'], + ]) + ->filter(fn ($title) => str_contains(Str::lower($title), Str::lower($value))) + ->all(), + placeholder: 'E.g. Collections' ); return $this->pages()->filter( fn ($page) => $page['title'] === $choice || Str::lower($page['title']) === $choice - )->keys()->first() ?: null; + )->keys()->first() ?: $this->guessPage($choice); } /** @@ -248,22 +252,22 @@ protected function askForPageViaAutocomplete() * * @return string|null */ - protected function guessPage() + protected function guessPage($search) { return $this->pages() ->filter(fn ($page) => str_starts_with( Str::slug($page['title'], ' '), - Str::slug($this->argument('page'), ' ') + Str::slug($search, ' ') ))->keys()->first() ?? $this->pages()->map(fn ($page) => similar_text( Str::slug($page['title'], ' '), - Str::slug($this->argument('page'), ' '), + Str::slug($search, ' '), )) - ->filter(fn ($score) => $score >= min(3, Str::length($this->argument('page')))) + ->filter(fn ($score) => $score >= min(3, Str::length($search))) ->sortDesc() ->keys() ->sortByDesc(fn ($slug) => Str::contains( Str::slug($this->pages()[$slug]['title'], ' '), - Str::slug($this->argument('page'), ' ') + Str::slug($search, ' ') ) ? 1 : 0) ->first(); } diff --git a/src/Illuminate/Foundation/Console/Kernel.php b/src/Illuminate/Foundation/Console/Kernel.php index 334b3a40..227f7cae 100644 --- a/src/Illuminate/Foundation/Console/Kernel.php +++ b/src/Illuminate/Foundation/Console/Kernel.php @@ -20,6 +20,7 @@ use Illuminate\Support\InteractsWithTime; use Illuminate\Support\Str; use ReflectionClass; +use SplFileInfo; use Symfony\Component\Console\ConsoleEvents; use Symfony\Component\Console\Event\ConsoleCommandEvent; use Symfony\Component\Console\Event\ConsoleTerminateEvent; @@ -218,6 +219,12 @@ public function terminate($input, $status) { $this->app->terminate(); + if ($this->commandStartedAt === null) { + return; + } + + $this->commandStartedAt->setTimezone($this->app['config']->get('app.timezone') ?? 'UTC'); + foreach ($this->commandLifecycleDurationHandlers as ['threshold' => $threshold, 'handler' => $handler]) { $end ??= Carbon::now(); @@ -333,12 +340,8 @@ protected function load($paths) $namespace = $this->app->getNamespace(); - foreach ((new Finder)->in($paths)->files() as $command) { - $command = $namespace.str_replace( - ['/', '.php'], - ['\\', ''], - Str::after($command->getRealPath(), realpath(app_path()).DIRECTORY_SEPARATOR) - ); + foreach ((new Finder)->in($paths)->files() as $file) { + $command = $this->commandClassFromFile($file, $namespace); if (is_subclass_of($command, Command::class) && ! (new ReflectionClass($command))->isAbstract()) { @@ -349,6 +352,22 @@ protected function load($paths) } } + /** + * Extract the command class name from the given file path. + * + * @param \SplFileInfo $file + * @param string $namespace + * @return string + */ + protected function commandClassFromFile(SplFileInfo $file, string $namespace): string + { + return $namespace.str_replace( + ['/', '.php'], + ['\\', ''], + Str::after($file->getRealPath(), realpath(app_path()).DIRECTORY_SEPARATOR) + ); + } + /** * Register the given command with the console application. * @@ -465,6 +484,7 @@ protected function getArtisan() if ($this->symfonyDispatcher instanceof EventDispatcher) { $this->artisan->setDispatcher($this->symfonyDispatcher); + $this->artisan->setSignalsToDispatchEvent(); } } diff --git a/src/Illuminate/Foundation/Console/ListenerMakeCommand.php b/src/Illuminate/Foundation/Console/ListenerMakeCommand.php index 6d815bbd..d76b4b15 100644 --- a/src/Illuminate/Foundation/Console/ListenerMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ListenerMakeCommand.php @@ -10,6 +10,8 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use function Laravel\Prompts\suggest; + #[AsCommand(name: 'make:listener')] class ListenerMakeCommand extends GeneratorCommand { @@ -44,7 +46,7 @@ class ListenerMakeCommand extends GeneratorCommand */ protected function buildClass($name) { - $event = $this->option('event'); + $event = $this->option('event') ?? ''; if (! Str::startsWith($event, [ $this->laravel->getNamespace(), @@ -130,13 +132,12 @@ protected function afterPromptingForMissingArguments(InputInterface $input, Outp return; } - $event = $this->components->askWithCompletion( - 'What event should be listened for?', + $event = suggest( + 'What event should be listened for? (Optional)', $this->possibleEvents(), - 'none' ); - if ($event && $event !== 'none') { + if ($event) { $input->setOption('event', $event); } } diff --git a/src/Illuminate/Foundation/Console/ModelMakeCommand.php b/src/Illuminate/Foundation/Console/ModelMakeCommand.php index 4a4412a0..b4a44dda 100644 --- a/src/Illuminate/Foundation/Console/ModelMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ModelMakeCommand.php @@ -10,6 +10,8 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use function Laravel\Prompts\multiselect; + #[AsCommand(name: 'make:model')] class ModelMakeCommand extends GeneratorCommand { @@ -142,6 +144,8 @@ protected function createController() '--model' => $this->option('resource') || $this->option('api') ? $modelName : null, '--api' => $this->option('api'), '--requests' => $this->option('requests') || $this->option('all'), + '--test' => $this->option('test'), + '--pest' => $this->option('pest'), ])); } @@ -238,22 +242,13 @@ protected function afterPromptingForMissingArguments(InputInterface $input, Outp return; } - collect($this->components->choice('Would you like any of the following?', [ - 'none', - 'all', - 'factory', - 'form requests', - 'migration', - 'policy', - 'resource controller', - 'seed', - ], default: 0, multiple: true)) - ->reject('none') - ->map(fn ($option) => match ($option) { - 'resource controller' => 'resource', - 'form requests' => 'requests', - default => $option, - }) - ->each(fn ($option) => $input->setOption($option, true)); + collect(multiselect('Would you like any of the following?', [ + 'seed' => 'Database Seeder', + 'factory' => 'Factory', + 'requests' => 'Form Requests', + 'migration' => 'Migration', + 'policy' => 'Policy', + 'resource' => 'Resource Controller', + ]))->each(fn ($option) => $input->setOption($option, true)); } } diff --git a/src/Illuminate/Foundation/Console/ObserverMakeCommand.php b/src/Illuminate/Foundation/Console/ObserverMakeCommand.php index 1a6988d7..2193d858 100644 --- a/src/Illuminate/Foundation/Console/ObserverMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ObserverMakeCommand.php @@ -9,6 +9,8 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use function Laravel\Prompts\suggest; + #[AsCommand(name: 'make:observer')] class ObserverMakeCommand extends GeneratorCommand { @@ -155,13 +157,12 @@ protected function afterPromptingForMissingArguments(InputInterface $input, Outp return; } - $model = $this->components->askWithCompletion( - 'What model should this observer apply to?', + $model = suggest( + 'What model should this observer apply to? (Optional)', $this->possibleModels(), - 'none' ); - if ($model && $model !== 'none') { + if ($model) { $input->setOption('model', $model); } } diff --git a/src/Illuminate/Foundation/Console/PolicyMakeCommand.php b/src/Illuminate/Foundation/Console/PolicyMakeCommand.php index 97672b68..a48eefe2 100644 --- a/src/Illuminate/Foundation/Console/PolicyMakeCommand.php +++ b/src/Illuminate/Foundation/Console/PolicyMakeCommand.php @@ -10,6 +10,8 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use function Laravel\Prompts\suggest; + #[AsCommand(name: 'make:policy')] class PolicyMakeCommand extends GeneratorCommand { @@ -214,13 +216,12 @@ protected function afterPromptingForMissingArguments(InputInterface $input, Outp return; } - $model = $this->components->askWithCompletion( - 'What model should this policy apply to?', + $model = suggest( + 'What model should this policy apply to? (Optional)', $this->possibleModels(), - 'none' ); - if ($model && $model !== 'none') { + if ($model) { $input->setOption('model', $model); } } diff --git a/src/Illuminate/Foundation/Console/QueuedCommand.php b/src/Illuminate/Foundation/Console/QueuedCommand.php index fb3d027b..43848cc2 100644 --- a/src/Illuminate/Foundation/Console/QueuedCommand.php +++ b/src/Illuminate/Foundation/Console/QueuedCommand.php @@ -39,4 +39,14 @@ public function handle(KernelContract $kernel) { $kernel->call(...array_values($this->data)); } + + /** + * Get the display name for the queued job. + * + * @return string + */ + public function displayName() + { + return array_values($this->data)[0]; + } } diff --git a/src/Illuminate/Foundation/Console/RouteListCommand.php b/src/Illuminate/Foundation/Console/RouteListCommand.php index 7cd48f5d..11a8c724 100644 --- a/src/Illuminate/Foundation/Console/RouteListCommand.php +++ b/src/Illuminate/Foundation/Console/RouteListCommand.php @@ -90,7 +90,9 @@ public function __construct(Router $router) */ public function handle() { - $this->router->flushMiddlewareGroups(); + if (! $this->output->isVeryVerbose()) { + $this->router->flushMiddlewareGroups(); + } if (! $this->router->getRoutes()->count()) { return $this->components->error("Your application doesn't have any routes."); diff --git a/src/Illuminate/Foundation/Console/ServeCommand.php b/src/Illuminate/Foundation/Console/ServeCommand.php index 84bcb053..194c80fa 100644 --- a/src/Illuminate/Foundation/Console/ServeCommand.php +++ b/src/Illuminate/Foundation/Console/ServeCommand.php @@ -201,6 +201,13 @@ protected function port() */ protected function getHostAndPort() { + if (preg_match('/(\[.*\]):?([0-9]+)?/', $this->input->getOption('host'), $matches) !== false) { + return [ + $matches[1] ?? $this->input->getOption('host'), + $matches[2] ?? null, + ]; + } + $hostParts = explode(':', $this->input->getOption('host')); return [ @@ -280,8 +287,13 @@ protected function handleProcessOutput() } elseif (str($line)->contains(['Closed without sending a request'])) { // ... } elseif (! empty($line)) { - $warning = explode('] ', $line); - $this->components->warn(count($warning) > 1 ? $warning[1] : $warning[0]); + $position = strpos($line, '] '); + + if ($position !== false) { + $line = substr($line, $position + 1); + } + + $this->components->warn($line); } }); } @@ -298,6 +310,8 @@ protected function getDateFromLine($line) ? '/^\[\d+]\s\[([a-zA-Z0-9: ]+)\]/' : '/^\[([^\]]+)\]/'; + $line = str_replace(' ', ' ', $line); + preg_match($regex, $line, $matches); return Carbon::createFromFormat('D M d H:i:s Y', $matches[1]); diff --git a/src/Illuminate/Foundation/Console/TestMakeCommand.php b/src/Illuminate/Foundation/Console/TestMakeCommand.php index 7ee08a16..7b65cf99 100644 --- a/src/Illuminate/Foundation/Console/TestMakeCommand.php +++ b/src/Illuminate/Foundation/Console/TestMakeCommand.php @@ -9,6 +9,8 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use function Laravel\Prompts\select; + #[AsCommand(name: 'make:test')] class TestMakeCommand extends GeneratorCommand { @@ -125,18 +127,18 @@ protected function afterPromptingForMissingArguments(InputInterface $input, Outp return; } - $type = $this->components->choice('Which type of test would you like', [ - 'feature', - 'unit', - 'pest feature', - 'pest unit', - ], default: 0); + $type = select('Which type of test would you like?', [ + 'feature' => 'Feature (PHPUnit)', + 'unit' => 'Unit (PHPUnit)', + 'pest-feature' => 'Feature (Pest)', + 'pest-unit' => 'Unit (Pest)', + ]); match ($type) { 'feature' => null, 'unit' => $input->setOption('unit', true), - 'pest feature' => $input->setOption('pest', true), - 'pest unit' => tap($input)->setOption('pest', true)->setOption('unit', true), + 'pest-feature' => $input->setOption('pest', true), + 'pest-unit' => tap($input)->setOption('pest', true)->setOption('unit', true), }; } } diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index 7ca5c4fb..f755c3d0 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -15,6 +15,9 @@ use League\Flysystem\Visibility; use Symfony\Component\Console\Attribute\AsCommand; +use function Laravel\Prompts\search; +use function Laravel\Prompts\select; + #[AsCommand(name: 'vendor:publish')] class VendorPublishCommand extends Command { @@ -112,10 +115,23 @@ protected function determineWhatShouldBePublished() */ protected function promptForProviderOrTag() { - $choice = $this->components->choice( - "Which provider or tag's files would you like to publish?", - $choices = $this->publishableChoices() - ); + $choices = $this->publishableChoices(); + + $choice = windows_os() + ? select( + "Which provider or tag's files would you like to publish?", + $choices, + scroll: 15, + ) + : search( + label: "Which provider or tag's files would you like to publish?", + placeholder: 'Search...', + options: fn ($search) => array_values(array_filter( + $choices, + fn ($choice) => str_contains(strtolower($choice), strtolower($search)) + )), + scroll: 15, + ); if ($choice == $choices[0] || is_null($choice)) { return; @@ -132,7 +148,7 @@ protected function promptForProviderOrTag() protected function publishableChoices() { return array_merge( - ['Publish files from all providers and tags listed below'], + ['All providers and tags'], preg_filter('/^/', 'Provider: ', Arr::sort(ServiceProvider::publishableProviders())), preg_filter('/^/', 'Tag: ', Arr::sort(ServiceProvider::publishableGroups())) ); @@ -163,8 +179,6 @@ protected function parseChoice($choice) */ protected function publishTag($tag) { - $published = false; - $pathsToPublish = $this->pathsToPublish($tag); if ($publishing = count($pathsToPublish) > 0) { diff --git a/src/Illuminate/Foundation/Console/ViewCacheCommand.php b/src/Illuminate/Foundation/Console/ViewCacheCommand.php index 1fda88e1..b108ea80 100644 --- a/src/Illuminate/Foundation/Console/ViewCacheCommand.php +++ b/src/Illuminate/Foundation/Console/ViewCacheCommand.php @@ -77,11 +77,17 @@ protected function compileViews(Collection $views) */ protected function bladeFilesIn(array $paths) { + $extensions = collect($this->laravel['view']->getExtensions()) + ->filter(fn ($value) => $value === 'blade') + ->keys() + ->map(fn ($extension) => "*.{$extension}") + ->all(); + return collect( Finder::create() ->in($paths) ->exclude('vendor') - ->name('*.blade.php') + ->name($extensions) ->files() ); } diff --git a/src/Illuminate/Foundation/Console/ViewMakeCommand.php b/src/Illuminate/Foundation/Console/ViewMakeCommand.php new file mode 100644 index 00000000..49899312 --- /dev/null +++ b/src/Illuminate/Foundation/Console/ViewMakeCommand.php @@ -0,0 +1,236 @@ +random(), + $contents, + ); + } + + /** + * Get the destination view path. + * + * @param string $name + * @return string + */ + protected function getPath($name) + { + return $this->viewPath( + $this->getNameInput().'.'.$this->option('extension'), + ); + } + + /** + * Get the desired view name from the input. + * + * @return string + */ + protected function getNameInput() + { + $name = trim($this->argument('name')); + + $name = str_replace(['\\', '.'], '/', $this->argument('name')); + + return $name; + } + + /** + * Get the stub file for the generator. + * + * @return string + */ + protected function getStub() + { + return $this->resolveStubPath( + '/stubs/view.stub', + ); + } + + /** + * Resolve the fully-qualified path to the stub. + * + * @param string $stub + * @return string + */ + protected function resolveStubPath($stub) + { + return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) + ? $customPath + : __DIR__.$stub; + } + + /** + * Get the destination test case path. + * + * @return string + */ + protected function getTestPath() + { + return base_path( + Str::of($this->testClassFullyQualifiedName()) + ->replace('\\', '/') + ->replaceFirst('Tests/Feature', 'tests/Feature') + ->append('Test.php') + ->value() + ); + } + + /** + * Create the matching test case if requested. + * + * @param string $path + */ + protected function handleTestCreation($path): bool + { + if (! $this->option('test') && ! $this->option('pest')) { + return false; + } + + $contents = preg_replace( + ['/\{{ namespace \}}/', '/\{{ class \}}/', '/\{{ name \}}/'], + [$this->testNamespace(), $this->testClassName(), $this->testViewName()], + File::get($this->getTestStub()), + ); + + File::ensureDirectoryExists(dirname($this->getTestPath()), 0755, true); + + return File::put($this->getTestPath(), $contents); + } + + /** + * Get the namespace for the test. + * + * @return string + */ + protected function testNamespace() + { + return Str::of($this->testClassFullyQualifiedName()) + ->beforeLast('\\') + ->value(); + } + + /** + * Get the class name for the test. + * + * @return string + */ + protected function testClassName() + { + return Str::of($this->testClassFullyQualifiedName()) + ->afterLast('\\') + ->append('Test') + ->value(); + } + + /** + * Get the class fully qualified name for the test. + * + * @return string + */ + protected function testClassFullyQualifiedName() + { + $name = Str::of(Str::lower($this->getNameInput()))->replace('.'.$this->option('extension'), ''); + + $namespacedName = Str::of( + Str::of($name) + ->replace('/', ' ') + ->explode(' ') + ->map(fn ($part) => Str::of($part)->ucfirst()) + ->implode('\\') + ) + ->replace(['-', '_'], ' ') + ->explode(' ') + ->map(fn ($part) => Str::of($part)->ucfirst()) + ->implode(''); + + return 'Tests\\Feature\\View\\'.$namespacedName; + } + + /** + * Get the test stub file for the generator. + * + * @return string + */ + protected function getTestStub() + { + $stubName = 'view.'.($this->option('pest') ? 'pest' : 'test').'.stub'; + + return file_exists($customPath = $this->laravel->basePath("stubs/$stubName")) + ? $customPath + : __DIR__.'/stubs/'.$stubName; + } + + /** + * Get the view name for the test. + * + * @return string + */ + protected function testViewName() + { + return Str::of($this->getNameInput()) + ->replace('/', '.') + ->lower() + ->value(); + } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getOptions() + { + return [ + ['extension', null, InputOption::VALUE_OPTIONAL, 'The extension of the generated view', 'blade.php'], + ['force', 'f', InputOption::VALUE_NONE, 'Create the view even if the view already exists'], + ]; + } +} diff --git a/src/Illuminate/Foundation/Console/stubs/request.stub b/src/Illuminate/Foundation/Console/stubs/request.stub index a9a50ae5..090b1456 100644 --- a/src/Illuminate/Foundation/Console/stubs/request.stub +++ b/src/Illuminate/Foundation/Console/stubs/request.stub @@ -17,7 +17,7 @@ class {{ class }} extends FormRequest /** * Get the validation rules that apply to the request. * - * @return array + * @return array|string> */ public function rules(): array { diff --git a/src/Illuminate/Foundation/Console/stubs/view.pest.stub b/src/Illuminate/Foundation/Console/stubs/view.pest.stub new file mode 100644 index 00000000..93d07907 --- /dev/null +++ b/src/Illuminate/Foundation/Console/stubs/view.pest.stub @@ -0,0 +1,9 @@ +view('{{ name }}', [ + // + ]); + + $contents->assertSee(''); +}); diff --git a/src/Illuminate/Foundation/Console/stubs/view.stub b/src/Illuminate/Foundation/Console/stubs/view.stub new file mode 100644 index 00000000..6ecd80c2 --- /dev/null +++ b/src/Illuminate/Foundation/Console/stubs/view.stub @@ -0,0 +1,3 @@ +
+ +
diff --git a/src/Illuminate/Foundation/Console/stubs/view.test.stub b/src/Illuminate/Foundation/Console/stubs/view.test.stub new file mode 100644 index 00000000..8b9a9bf0 --- /dev/null +++ b/src/Illuminate/Foundation/Console/stubs/view.test.stub @@ -0,0 +1,20 @@ +view('{{ name }}', [ + // + ]); + + $contents->assertSee(''); + } +} diff --git a/src/Illuminate/Foundation/Events/DiscoverEvents.php b/src/Illuminate/Foundation/Events/DiscoverEvents.php index 1e26f556..b285759d 100644 --- a/src/Illuminate/Foundation/Events/DiscoverEvents.php +++ b/src/Illuminate/Foundation/Events/DiscoverEvents.php @@ -12,6 +12,13 @@ class DiscoverEvents { + /** + * The callback to be used to guess class names. + * + * @var callable(SplFileInfo, string): string|null + */ + public static $guessClassNamesUsingCallback; + /** * Get all of the events and listeners by searching the given listener directory. * @@ -87,6 +94,10 @@ protected static function getListenerEvents($listeners, $basePath) */ protected static function classFromFile(SplFileInfo $file, $basePath) { + if (static::$guessClassNamesUsingCallback) { + return call_user_func(static::$guessClassNamesUsingCallback, $file, $basePath); + } + $class = trim(Str::replaceFirst($basePath, '', $file->getRealPath()), DIRECTORY_SEPARATOR); return str_replace( @@ -95,4 +106,15 @@ protected static function classFromFile(SplFileInfo $file, $basePath) ucfirst(Str::replaceLast('.php', '', $class)) ); } + + /** + * Specify a callback to be used to guess class names. + * + * @param callable(SplFileInfo, string): string $callback + * @return void + */ + public static function guessClassNamesUsing(callable $callback) + { + static::$guessClassNamesUsingCallback = $callback; + } } diff --git a/src/Illuminate/Foundation/Events/Dispatchable.php b/src/Illuminate/Foundation/Events/Dispatchable.php index ff633150..6e5e979c 100644 --- a/src/Illuminate/Foundation/Events/Dispatchable.php +++ b/src/Illuminate/Foundation/Events/Dispatchable.php @@ -7,7 +7,7 @@ trait Dispatchable /** * Dispatch the event with the given arguments. * - * @return void + * @return mixed */ public static function dispatch() { @@ -19,7 +19,7 @@ public static function dispatch() * * @param bool $boolean * @param mixed ...$arguments - * @return void + * @return mixed */ public static function dispatchIf($boolean, ...$arguments) { @@ -33,7 +33,7 @@ public static function dispatchIf($boolean, ...$arguments) * * @param bool $boolean * @param mixed ...$arguments - * @return void + * @return mixed */ public static function dispatchUnless($boolean, ...$arguments) { diff --git a/src/Illuminate/Foundation/Exceptions/Handler.php b/src/Illuminate/Foundation/Exceptions/Handler.php index 4a5b3bd3..498be561 100644 --- a/src/Illuminate/Foundation/Exceptions/Handler.php +++ b/src/Illuminate/Foundation/Exceptions/Handler.php @@ -6,6 +6,9 @@ use Exception; use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Auth\AuthenticationException; +use Illuminate\Cache\RateLimiter; +use Illuminate\Cache\RateLimiting\Limit; +use Illuminate\Cache\RateLimiting\Unlimited; use Illuminate\Console\View\Components\BulletList; use Illuminate\Console\View\Components\Error; use Illuminate\Contracts\Container\Container; @@ -24,6 +27,7 @@ use Illuminate\Session\TokenMismatchException; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Lottery; use Illuminate\Support\Reflector; use Illuminate\Support\Traits\ReflectsClosures; use Illuminate\Support\ViewErrorBag; @@ -42,6 +46,7 @@ use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Throwable; +use WeakMap; class Handler implements ExceptionHandlerContract { @@ -89,6 +94,13 @@ class Handler implements ExceptionHandlerContract */ protected $exceptionMap = []; + /** + * Indicates that throttled keys should be hashed. + * + * @var bool + */ + protected $hashThrottleKeys = true; + /** * A list of the internal exception types that should not be reported. * @@ -119,6 +131,20 @@ class Handler implements ExceptionHandlerContract 'password_confirmation', ]; + /** + * Indicates that an exception instance should only be reported once. + * + * @var bool + */ + protected $withoutDuplicates = false; + + /** + * The already reported exception map. + * + * @var \WeakMap + */ + protected $reportedExceptionMap; + /** * Create a new exception handler instance. * @@ -129,6 +155,8 @@ public function __construct(Container $container) { $this->container = $container; + $this->reportedExceptionMap = new WeakMap; + $this->register(); } @@ -247,6 +275,21 @@ public function report(Throwable $e) return; } + $this->reportThrowable($e); + } + + /** + * Reports error based on report method on exception or to logger. + * + * @param \Throwable $e + * @return void + * + * @throws \Throwable + */ + protected function reportThrowable(Throwable $e): void + { + $this->reportedExceptionMap[$e] = true; + if (Reflector::isCallable($reportCallable = [$e, 'report']) && $this->container->call($reportCallable) !== false) { return; @@ -259,8 +302,8 @@ public function report(Throwable $e) } try { - $logger = $this->container->make(LoggerInterface::class); - } catch (Exception $ex) { + $logger = $this->newLogger(); + } catch (Exception) { throw $e; } @@ -294,9 +337,43 @@ public function shouldReport(Throwable $e) */ protected function shouldntReport(Throwable $e) { + if ($this->withoutDuplicates && ($this->reportedExceptionMap[$e] ?? false)) { + return true; + } + $dontReport = array_merge($this->dontReport, $this->internalDontReport); - return ! is_null(Arr::first($dontReport, fn ($type) => $e instanceof $type)); + if (! is_null(Arr::first($dontReport, fn ($type) => $e instanceof $type))) { + return true; + } + + return rescue(fn () => with($this->throttle($e), function ($throttle) use ($e) { + if ($throttle instanceof Unlimited || $throttle === null) { + return false; + } + + if ($throttle instanceof Lottery) { + return ! $throttle($e); + } + + return ! $this->container->make(RateLimiter::class)->attempt( + with($throttle->key ?: 'illuminate:foundation:exceptions:'.$e::class, fn ($key) => $this->hashThrottleKeys ? md5($key) : $key), + $throttle->maxAttempts, + fn () => true, + 60 * $throttle->decayMinutes + ); + }), rescue: false, report: false); + } + + /** + * Throttle the given exception. + * + * @param \Throwable $e + * @return \Illuminate\Support\Lottery|\Illuminate\Cache\RateLimiting\Limit|null + */ + protected function throttle(Throwable $e) + { + return Limit::none(); } /** @@ -357,7 +434,7 @@ protected function context() return array_filter([ 'userId' => Auth::id(), ]); - } catch (Throwable $e) { + } catch (Throwable) { return []; } } @@ -470,7 +547,7 @@ protected function renderViaCallbacks($request, Throwable $e) * * @param \Illuminate\Http\Request $request * @param \Throwable $e - * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse + * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse */ protected function renderExceptionResponse($request, Throwable $e) { @@ -484,7 +561,7 @@ protected function renderExceptionResponse($request, Throwable $e) * * @param \Illuminate\Http\Request $request * @param \Illuminate\Auth\AuthenticationException $exception - * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse + * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse */ protected function unauthenticated($request, AuthenticationException $exception) { @@ -516,7 +593,7 @@ protected function convertValidationExceptionToResponse(ValidationException $e, * * @param \Illuminate\Http\Request $request * @param \Illuminate\Validation\ValidationException $exception - * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse + * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse */ protected function invalid($request, ValidationException $exception) { @@ -557,7 +634,7 @@ protected function shouldReturnJson($request, Throwable $e) * * @param \Illuminate\Http\Request $request * @param \Throwable $e - * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse + * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse */ protected function prepareResponse($request, Throwable $e) { @@ -642,10 +719,16 @@ protected function renderHttpException(HttpExceptionInterface $e) $this->registerErrorViewPaths(); if ($view = $this->getHttpExceptionView($e)) { - return response()->view($view, [ - 'errors' => new ViewErrorBag, - 'exception' => $e, - ], $e->getStatusCode(), $e->getHeaders()); + try { + return response()->view($view, [ + 'errors' => new ViewErrorBag, + 'exception' => $e, + ], $e->getStatusCode(), $e->getHeaders()); + } catch (Throwable $t) { + config('app.debug') && throw $t; + + $this->report($t); + } } return $this->convertExceptionToResponse($e); @@ -773,6 +856,18 @@ public function renderForConsole($output, Throwable $e) (new ConsoleApplication)->renderThrowable($e, $output); } + /** + * Do not report duplicate exceptions. + * + * @return $this + */ + public function dontReportDuplicates() + { + $this->withoutDuplicates = true; + + return $this; + } + /** * Determine if the given exception is an HTTP exception. * @@ -783,4 +878,14 @@ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } + + /** + * Create a new logger instance. + * + * @return \Psr\Log\LoggerInterface + */ + protected function newLogger() + { + return $this->container->make(LoggerInterface::class); + } } diff --git a/src/Illuminate/Foundation/Http/FormRequest.php b/src/Illuminate/Foundation/Http/FormRequest.php index 2a88d9c5..772a2635 100644 --- a/src/Illuminate/Foundation/Http/FormRequest.php +++ b/src/Illuminate/Foundation/Http/FormRequest.php @@ -11,7 +11,6 @@ use Illuminate\Http\Request; use Illuminate\Routing\Redirector; use Illuminate\Validation\ValidatesWhenResolvedTrait; -use Illuminate\Validation\ValidationException; class FormRequest extends Request implements ValidatesWhenResolved { @@ -152,7 +151,9 @@ public function validationData() */ protected function failedValidation(Validator $validator) { - throw (new ValidationException($validator)) + $exception = $validator->getException(); + + throw (new $exception($validator)) ->errorBag($this->errorBag) ->redirectTo($this->getRedirectUrl()); } diff --git a/src/Illuminate/Foundation/Http/Kernel.php b/src/Illuminate/Foundation/Http/Kernel.php index e91543cd..51ad7929 100644 --- a/src/Illuminate/Foundation/Http/Kernel.php +++ b/src/Illuminate/Foundation/Http/Kernel.php @@ -214,6 +214,12 @@ public function terminate($request, $response) $this->app->terminate(); + if ($this->requestStartedAt === null) { + return; + } + + $this->requestStartedAt->setTimezone($this->app['config']->get('app.timezone') ?? 'UTC'); + foreach ($this->requestLifecycleDurationHandlers as ['threshold' => $threshold, 'handler' => $handler]) { $end ??= Carbon::now(); diff --git a/src/Illuminate/Foundation/Http/Middleware/HandlePrecognitiveRequests.php b/src/Illuminate/Foundation/Http/Middleware/HandlePrecognitiveRequests.php index 8df5c093..32819c45 100644 --- a/src/Illuminate/Foundation/Http/Middleware/HandlePrecognitiveRequests.php +++ b/src/Illuminate/Foundation/Http/Middleware/HandlePrecognitiveRequests.php @@ -69,7 +69,7 @@ protected function prepareForPrecognition($request) * * @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Response $response - * @return \Illuminate\Http\Response $response + * @return \Illuminate\Http\Response */ protected function appendVaryHeader($request, $response) { diff --git a/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php b/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php index c9aa6c43..a25e4c4a 100644 --- a/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php +++ b/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php @@ -3,6 +3,7 @@ namespace Illuminate\Foundation\Http\Middleware; use Closure; +use ErrorException; use Illuminate\Contracts\Foundation\Application; use Illuminate\Foundation\Http\MaintenanceModeBypassCookie; use Symfony\Component\HttpKernel\Exception\HttpException; @@ -42,18 +43,30 @@ public function __construct(Application $app) * @return mixed * * @throws \Symfony\Component\HttpKernel\Exception\HttpException + * @throws \ErrorException */ public function handle($request, Closure $next) { + if ($this->inExceptArray($request)) { + return $next($request); + } + if ($this->app->maintenanceMode()->active()) { - $data = $this->app->maintenanceMode()->data(); + try { + $data = $this->app->maintenanceMode()->data(); + } catch (ErrorException $exception) { + if (! $this->app->maintenanceMode()->active()) { + return $next($request); + } + + throw $exception; + } if (isset($data['secret']) && $request->path() === $data['secret']) { return $this->bypassResponse($data['secret']); } - if ($this->hasValidBypassCookie($request, $data) || - $this->inExceptArray($request)) { + if ($this->hasValidBypassCookie($request, $data)) { return $next($request); } diff --git a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php index bc6ac4ec..b92bd4ac 100755 --- a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php +++ b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php @@ -9,6 +9,7 @@ use Illuminate\Cache\Console\PruneStaleTagsCommand; use Illuminate\Console\Scheduling\ScheduleClearCacheCommand; use Illuminate\Console\Scheduling\ScheduleFinishCommand; +use Illuminate\Console\Scheduling\ScheduleInterruptCommand; use Illuminate\Console\Scheduling\ScheduleListCommand; use Illuminate\Console\Scheduling\ScheduleRunCommand; use Illuminate\Console\Scheduling\ScheduleTestCommand; @@ -34,6 +35,7 @@ use Illuminate\Foundation\Console\ComponentMakeCommand; use Illuminate\Foundation\Console\ConfigCacheCommand; use Illuminate\Foundation\Console\ConfigClearCommand; +use Illuminate\Foundation\Console\ConfigShowCommand; use Illuminate\Foundation\Console\ConsoleMakeCommand; use Illuminate\Foundation\Console\DocsCommand; use Illuminate\Foundation\Console\DownCommand; @@ -74,6 +76,7 @@ use Illuminate\Foundation\Console\VendorPublishCommand; use Illuminate\Foundation\Console\ViewCacheCommand; use Illuminate\Foundation\Console\ViewClearCommand; +use Illuminate\Foundation\Console\ViewMakeCommand; use Illuminate\Notifications\Console\NotificationTableCommand; use Illuminate\Queue\Console\BatchesTableCommand; use Illuminate\Queue\Console\ClearCommand as QueueClearCommand; @@ -110,6 +113,7 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid 'ClearResets' => ClearResetsCommand::class, 'ConfigCache' => ConfigCacheCommand::class, 'ConfigClear' => ConfigClearCommand::class, + 'ConfigShow' => ConfigShowCommand::class, 'Db' => DbCommand::class, 'DbMonitor' => DatabaseMonitorCommand::class, 'DbPrune' => PruneCommand::class, @@ -151,6 +155,7 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid 'ScheduleClearCache' => ScheduleClearCacheCommand::class, 'ScheduleTest' => ScheduleTestCommand::class, 'ScheduleWork' => ScheduleWorkCommand::class, + 'ScheduleInterrupt' => ScheduleInterruptCommand::class, 'ShowModel' => ShowModelCommand::class, 'StorageLink' => StorageLinkCommand::class, 'Up' => UpCommand::class, @@ -200,6 +205,7 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid 'StubPublish' => StubPublishCommand::class, 'TestMake' => TestMakeCommand::class, 'VendorPublish' => VendorPublishCommand::class, + 'ViewMake' => ViewMakeCommand::class, ]; /** diff --git a/src/Illuminate/Foundation/Providers/FoundationServiceProvider.php b/src/Illuminate/Foundation/Providers/FoundationServiceProvider.php index 484e0124..1d5ed5ff 100644 --- a/src/Illuminate/Foundation/Providers/FoundationServiceProvider.php +++ b/src/Illuminate/Foundation/Providers/FoundationServiceProvider.php @@ -13,6 +13,7 @@ use Illuminate\Foundation\MaintenanceModeManager; use Illuminate\Foundation\Precognition; use Illuminate\Foundation\Vite; +use Illuminate\Http\Client\Factory as HttpFactory; use Illuminate\Http\Request; use Illuminate\Log\Events\MessageLogged; use Illuminate\Support\AggregateServiceProvider; @@ -41,6 +42,7 @@ class FoundationServiceProvider extends AggregateServiceProvider * @var array */ public $singletons = [ + HttpFactory::class => HttpFactory::class, Vite::class => Vite::class, ]; @@ -75,7 +77,7 @@ public function register() } /** - * Register an var dumper (with source) to debug variables. + * Register a var dumper (with source) to debug variables. * * @return void */ diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php index 49c0e35e..141504fd 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php @@ -106,7 +106,12 @@ protected function assertSoftDeleted($table, array $data = [], $connection = nul } $this->assertThat( - $this->getTable($table), new SoftDeletedInDatabase($this->getConnection($connection, $table), $data, $deletedAtColumn) + $this->getTable($table), + new SoftDeletedInDatabase( + $this->getConnection($connection, $table), + $data, + $this->getDeletedAtColumn($table, $deletedAtColumn) + ) ); return $this; @@ -133,7 +138,12 @@ protected function assertNotSoftDeleted($table, array $data = [], $connection = } $this->assertThat( - $this->getTable($table), new NotSoftDeletedInDatabase($this->getConnection($connection, $table), $data, $deletedAtColumn) + $this->getTable($table), + new NotSoftDeletedInDatabase( + $this->getConnection($connection, $table), + $data, + $this->getDeletedAtColumn($table, $deletedAtColumn) + ) ); return $this; @@ -270,6 +280,18 @@ protected function getTableConnection($table) return $this->newModelFor($table)?->getConnectionName(); } + /** + * Get the table column name used for soft deletes. + * + * @param string $table + * @param string $defaultColumnName + * @return string + */ + protected function getDeletedAtColumn($table, $defaultColumnName = 'deleted_at') + { + return $this->newModelFor($table)?->getDeletedAtColumn() ?: $defaultColumnName; + } + /** * Get the model entity from the given model or string. * diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDeprecationHandling.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDeprecationHandling.php index 7a914f7e..6b9300ac 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDeprecationHandling.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDeprecationHandling.php @@ -21,9 +21,7 @@ trait InteractsWithDeprecationHandling protected function withDeprecationHandling() { if ($this->originalDeprecationHandler) { - set_error_handler(tap($this->originalDeprecationHandler, function () { - $this->originalDeprecationHandler = null; - })); + set_error_handler(tap($this->originalDeprecationHandler, fn () => $this->originalDeprecationHandler = null)); } return $this; diff --git a/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php b/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php index 8211e966..6a14fb1d 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php +++ b/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php @@ -309,6 +309,16 @@ public function from(string $url) return $this->withHeader('referer', $url); } + /** + * Set the Precognition header to "true". + * + * @return $this + */ + public function withPrecognition() + { + return $this->withHeader('Precognition', 'true'); + } + /** * Visit the given URI with a GET request. * @@ -674,7 +684,7 @@ protected function prepareCookiesForJsonRequest() /** * Follow a redirect chain until a non-redirect is received. * - * @param \Illuminate\Http\Response $response + * @param \Illuminate\Http\Response|\Illuminate\Testing\TestResponse $response * @return \Illuminate\Http\Response|\Illuminate\Testing\TestResponse */ protected function followRedirects($response) diff --git a/src/Illuminate/Foundation/Testing/DatabaseTransactions.php b/src/Illuminate/Foundation/Testing/DatabaseTransactions.php index d0e0bafc..83a686f3 100644 --- a/src/Illuminate/Foundation/Testing/DatabaseTransactions.php +++ b/src/Illuminate/Foundation/Testing/DatabaseTransactions.php @@ -13,19 +13,16 @@ public function beginDatabaseTransaction() { $database = $this->app->make('db'); + $this->app->instance('db.transactions', $transactionsManager = new DatabaseTransactionsManager); + foreach ($this->connectionsToTransact() as $name) { $connection = $database->connection($name); + $connection->setTransactionManager($transactionsManager); $dispatcher = $connection->getEventDispatcher(); $connection->unsetEventDispatcher(); $connection->beginTransaction(); $connection->setEventDispatcher($dispatcher); - - if ($this->app->resolved('db.transactions')) { - $this->app->make('db.transactions')->callbacksShouldIgnore( - $this->app->make('db.transactions')->getTransactions()->first() - ); - } } $this->beforeApplicationDestroyed(function () use ($database) { diff --git a/src/Illuminate/Foundation/Testing/DatabaseTransactionsManager.php b/src/Illuminate/Foundation/Testing/DatabaseTransactionsManager.php new file mode 100644 index 00000000..bc545048 --- /dev/null +++ b/src/Illuminate/Foundation/Testing/DatabaseTransactionsManager.php @@ -0,0 +1,47 @@ +callbackApplicableTransactions()->count() === 0) { + return $callback(); + } + + $this->pendingTransactions->last()->addCallback($callback); + } + + /** + * Get the transactions that are applicable to callbacks. + * + * @return \Illuminate\Support\Collection + */ + public function callbackApplicableTransactions() + { + return $this->pendingTransactions->skip(1)->values(); + } + + /** + * Determine if after commit callbacks should be executed for the given transaction level. + * + * @param int $level + * @return bool + */ + public function afterCommitCallbacksShouldBeExecuted($level) + { + return $level === 1; + } +} diff --git a/src/Illuminate/Foundation/Testing/DatabaseTruncation.php b/src/Illuminate/Foundation/Testing/DatabaseTruncation.php index b3f1a14f..cea2d8d0 100644 --- a/src/Illuminate/Foundation/Testing/DatabaseTruncation.php +++ b/src/Illuminate/Foundation/Testing/DatabaseTruncation.php @@ -24,6 +24,8 @@ trait DatabaseTruncation */ protected function truncateDatabaseTables(): void { + $this->beforeTruncatingDatabase(); + // Migrate and seed the database on first run... if (! RefreshDatabaseState::$migrated) { $this->artisan('migrate:fresh', $this->migrateFreshUsing()); @@ -45,6 +47,8 @@ protected function truncateDatabaseTables(): void // Use the default seeder class... $this->artisan('db:seed'); } + + $this->afterTruncatingDatabase(); } /** @@ -85,12 +89,28 @@ protected function truncateTablesForConnection(ConnectionInterface $connection, fn ($tables) => $tables->intersect($this->tablesToTruncate), fn ($tables) => $tables->diff($this->exceptTables($name)) ) - ->filter(fn ($table) => $connection->table($table)->exists()) - ->each(fn ($table) => $connection->table($table)->truncate()); + ->filter(fn ($table) => $connection->table($this->withoutTablePrefix($connection, $table))->exists()) + ->each(fn ($table) => $connection->table($this->withoutTablePrefix($connection, $table))->truncate()); $connection->setEventDispatcher($dispatcher); } + /** + * Remove the table prefix from a table name, if it exists. + * + * @param \Illuminate\Database\ConnectionInterface $connection + * @param string $table + * @return string + */ + protected function withoutTablePrefix(ConnectionInterface $connection, string $table) + { + $prefix = $connection->getTablePrefix(); + + return strpos($table, $prefix) === 0 + ? substr($table, strlen($prefix)) + : $table; + } + /** * The database connections that should have their tables truncated. * @@ -111,12 +131,41 @@ protected function connectionsToTruncate(): array protected function exceptTables(?string $connectionName): array { if (property_exists($this, 'exceptTables')) { + $migrationsTable = $this->app['config']->get('database.migrations'); + + if (array_is_list($this->exceptTables ?? [])) { + return array_merge( + $this->exceptTables ?? [], + [$migrationsTable], + ); + } + return array_merge( $this->exceptTables[$connectionName] ?? [], - [$this->app['config']->get('database.migrations')] + [$migrationsTable], ); } return [$this->app['config']->get('database.migrations')]; } + + /** + * Perform any work that should take place before the database has started truncating. + * + * @return void + */ + protected function beforeTruncatingDatabase(): void + { + // + } + + /** + * Perform any work that should take place once the database has finished truncating. + * + * @return void + */ + protected function afterTruncatingDatabase(): void + { + // + } } diff --git a/src/Illuminate/Foundation/Testing/RefreshDatabase.php b/src/Illuminate/Foundation/Testing/RefreshDatabase.php index b486cbb0..0f916ac5 100644 --- a/src/Illuminate/Foundation/Testing/RefreshDatabase.php +++ b/src/Illuminate/Foundation/Testing/RefreshDatabase.php @@ -89,19 +89,16 @@ public function beginDatabaseTransaction() { $database = $this->app->make('db'); + $this->app->instance('db.transactions', $transactionsManager = new DatabaseTransactionsManager); + foreach ($this->connectionsToTransact() as $name) { $connection = $database->connection($name); + $connection->setTransactionManager($transactionsManager); $dispatcher = $connection->getEventDispatcher(); $connection->unsetEventDispatcher(); $connection->beginTransaction(); $connection->setEventDispatcher($dispatcher); - - if ($this->app->resolved('db.transactions')) { - $this->app->make('db.transactions')->callbacksShouldIgnore( - $this->app->make('db.transactions')->getTransactions()->first() - ); - } } $this->beforeApplicationDestroyed(function () use ($database) { diff --git a/src/Illuminate/Foundation/Vite.php b/src/Illuminate/Foundation/Vite.php index dfc92c77..9c0a24d0 100644 --- a/src/Illuminate/Foundation/Vite.php +++ b/src/Illuminate/Foundation/Vite.php @@ -655,6 +655,30 @@ public function asset($asset, $buildDirectory = null) return $this->assetPath($buildDirectory.'/'.$chunk['file']); } + /** + * Get the content of a given asset. + * + * @param string $asset + * @param string|null $buildDirectory + * @return string + * + * @throws \Exception + */ + public function content($asset, $buildDirectory = null) + { + $buildDirectory ??= $this->buildDirectory; + + $chunk = $this->chunk($this->manifest($buildDirectory), $asset); + + $path = public_path($buildDirectory.'/'.$chunk['file']); + + if (! is_file($path) || ! file_exists($path)) { + throw new Exception("Unable to locate file from Vite manifest: {$path}."); + } + + return file_get_contents($path); + } + /** * Generate an asset path for the application. * @@ -673,7 +697,7 @@ protected function assetPath($path, $secure = null) * @param string $buildDirectory * @return array * - * @throws \Exception + * @throws \Illuminate\Foundation\ViteManifestNotFoundException */ protected function manifest($buildDirectory) { @@ -681,7 +705,7 @@ protected function manifest($buildDirectory) if (! isset(static::$manifests[$path])) { if (! is_file($path)) { - throw new Exception("Vite manifest not found at: {$path}"); + throw new ViteManifestNotFoundException("Vite manifest not found at: $path"); } static::$manifests[$path] = json_decode(file_get_contents($path), true); diff --git a/src/Illuminate/Foundation/ViteManifestNotFoundException.php b/src/Illuminate/Foundation/ViteManifestNotFoundException.php new file mode 100644 index 00000000..8c411907 --- /dev/null +++ b/src/Illuminate/Foundation/ViteManifestNotFoundException.php @@ -0,0 +1,10 @@ +'); + return new HtmlString(''); } } @@ -727,10 +727,13 @@ function request($key = null, $default = null) /** * Catch a potential exception and return a default value. * - * @param callable $callback - * @param mixed $rescue + * @template TRescueValue + * @template TRescueFallback + * + * @param callable(): TRescueValue $callback + * @param (callable(\Throwable): TRescueFallback)|TRescueFallback $rescue * @param bool|callable $report - * @return mixed + * @return TRescueValue|TRescueFallback */ function rescue(callable $callback, $rescue = null, $report = true) { From f2a1e269195e79eb31c4c3ff2f79d54e023c04d0 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 16 Nov 2023 12:53:28 -0600 Subject: [PATCH 06/48] =?UTF-8?q?=E2=AC=86=20Bump=20dependencies=20?= =?UTF-8?q?=E2=9E=95=20Add=20`laravel/prompts`=20as=20a=20dependency=20?= =?UTF-8?q?=F0=9F=94=A7=20Bump=20minimum=20PHP=20version=20to=208.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index d389539e..f44e2737 100644 --- a/composer.json +++ b/composer.json @@ -40,22 +40,23 @@ } }, "require": { - "php": "^8.0", + "php": ">=8.1", "ext-json": "*", "ext-mbstring": "*", - "illuminate/cache": "^10.13", - "illuminate/config": "^10.13", - "illuminate/console": "^10.13", - "illuminate/container": "^10.13", - "illuminate/contracts": "^10.13", - "illuminate/database": "^10.13", - "illuminate/events": "^10.13", - "illuminate/filesystem": "^10.13", - "illuminate/http": "^10.13", - "illuminate/log": "^10.13", - "illuminate/routing": "^10.13", - "illuminate/support": "^10.13", - "illuminate/view": "^10.13", + "illuminate/cache": "^10.23", + "illuminate/config": "^10.23", + "illuminate/console": "^10.23", + "illuminate/container": "^10.23", + "illuminate/contracts": "^10.23", + "illuminate/database": "^10.23", + "illuminate/events": "^10.23", + "illuminate/filesystem": "^10.23", + "illuminate/http": "^10.23", + "illuminate/log": "^10.23", + "illuminate/routing": "^10.23", + "illuminate/support": "^10.23", + "illuminate/view": "^10.23", + "laravel/prompts": "^0.1.7", "league/flysystem": "^3.8", "ramsey/uuid": "^4.7", "roots/support": "^1.0", From 454eef8d790b9e877b00b6c51548a727b3e6bc2c Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 16 Nov 2023 12:55:47 -0600 Subject: [PATCH 07/48] =?UTF-8?q?=F0=9F=94=A7=20Update=20default=20Acorn?= =?UTF-8?q?=20configuration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/app.php | 45 ++++++++--------------------------------- config/auth.php | 8 ++++++-- config/broadcasting.php | 1 + config/cache.php | 1 + config/hashing.php | 4 +++- config/logging.php | 9 +++++++++ config/mail.php | 10 ++++++++- config/queue.php | 16 +++++++++++++++ config/sanctum.php | 22 +++++++++++++++++--- 9 files changed, 72 insertions(+), 44 deletions(-) diff --git a/config/app.php b/config/app.php index bd4d4261..64a77e74 100644 --- a/config/app.php +++ b/config/app.php @@ -1,6 +1,7 @@ env('APP_URL', home_url()), + 'asset_url' => env('ASSET_URL'), + /* |-------------------------------------------------------------------------- | Application Timezone @@ -140,7 +143,7 @@ 'maintenance' => [ 'driver' => 'file', - // 'store' => 'redis', + // 'store' => 'redis', ], /* @@ -154,38 +157,7 @@ | */ - 'providers' => [ - - /* - * Framework Service Providers... - */ - Illuminate\Auth\AuthServiceProvider::class, - Illuminate\Broadcasting\BroadcastServiceProvider::class, - Illuminate\Bus\BusServiceProvider::class, - Illuminate\Cache\CacheServiceProvider::class, - Illuminate\Cookie\CookieServiceProvider::class, - Illuminate\Database\DatabaseServiceProvider::class, - Illuminate\Database\MigrationServiceProvider::class, - Illuminate\Encryption\EncryptionServiceProvider::class, - Illuminate\Foundation\Providers\ComposerServiceProvider::class, - Illuminate\Hashing\HashServiceProvider::class, - Illuminate\Mail\MailServiceProvider::class, - Illuminate\Notifications\NotificationServiceProvider::class, - Illuminate\Pagination\PaginationServiceProvider::class, - Illuminate\Pipeline\PipelineServiceProvider::class, - Illuminate\Queue\QueueServiceProvider::class, - Illuminate\Redis\RedisServiceProvider::class, - Illuminate\Routing\RoutingServiceProvider::class, - Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, - Illuminate\Session\SessionServiceProvider::class, - Illuminate\Translation\TranslationServiceProvider::class, - Illuminate\Validation\ValidationServiceProvider::class, - Roots\Acorn\Assets\AssetsServiceProvider::class, - Roots\Acorn\Filesystem\FilesystemServiceProvider::class, - Roots\Acorn\Providers\AcornServiceProvider::class, - Roots\Acorn\Providers\RouteServiceProvider::class, - Roots\Acorn\View\ViewServiceProvider::class, - + 'providers' => ServiceProvider::defaultProviders()->merge([ /* * Package Service Providers... */ @@ -193,9 +165,8 @@ /* * Application Service Providers... */ - // App\Providers\ThemeServiceProvider::class, - - ], + App\Providers\ThemeServiceProvider::class, + ])->toArray(), /* |-------------------------------------------------------------------------- @@ -209,7 +180,7 @@ */ 'aliases' => Facade::defaultAliases()->merge([ - // 'ExampleClass' => App\Example\ExampleClass::class, + // 'Example' => App\Facades\Example::class, ])->toArray(), ]; diff --git a/config/auth.php b/config/auth.php index e29a3f7d..9548c15d 100644 --- a/config/auth.php +++ b/config/auth.php @@ -80,16 +80,20 @@ | than one user table or model in the application and you want to have | separate password reset settings based on the specific user types. | - | The expire time is the number of minutes that the reset token should be + | The expiry time is the number of minutes that each reset token will be | considered valid. This security feature keeps tokens short-lived so | they have less time to be guessed. You may change this as needed. | + | The throttle setting is the number of seconds a user must wait before + | generating more password reset tokens. This prevents the user from + | quickly generating a very large amount of password reset tokens. + | */ 'passwords' => [ 'users' => [ 'provider' => 'users', - 'table' => 'password_resets', + 'table' => 'password_reset_tokens', 'expire' => 60, 'throttle' => 60, ], diff --git a/config/broadcasting.php b/config/broadcasting.php index 9e4d4aa4..24104853 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -36,6 +36,7 @@ 'secret' => env('PUSHER_APP_SECRET'), 'app_id' => env('PUSHER_APP_ID'), 'options' => [ + 'cluster' => env('PUSHER_APP_CLUSTER'), 'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com', 'port' => env('PUSHER_PORT', 443), 'scheme' => env('PUSHER_SCHEME', 'https'), diff --git a/config/cache.php b/config/cache.php index 33bb2954..d4171e22 100644 --- a/config/cache.php +++ b/config/cache.php @@ -52,6 +52,7 @@ 'file' => [ 'driver' => 'file', 'path' => storage_path('framework/cache/data'), + 'lock_path' => storage_path('framework/cache/data'), ], 'memcached' => [ diff --git a/config/hashing.php b/config/hashing.php index bcd3be4c..0e8a0bb3 100644 --- a/config/hashing.php +++ b/config/hashing.php @@ -29,7 +29,8 @@ */ 'bcrypt' => [ - 'rounds' => env('BCRYPT_ROUNDS', 10), + 'rounds' => env('BCRYPT_ROUNDS', 12), + 'verify' => true, ], /* @@ -47,6 +48,7 @@ 'memory' => 65536, 'threads' => 1, 'time' => 4, + 'verify' => true, ], ]; diff --git a/config/logging.php b/config/logging.php index 44bf3ef7..54e27ed2 100644 --- a/config/logging.php +++ b/config/logging.php @@ -3,6 +3,7 @@ use Monolog\Handler\NullHandler; use Monolog\Handler\StreamHandler; use Monolog\Handler\SyslogUdpHandler; +use Monolog\Processor\PsrLogMessageProcessor; return [ @@ -61,6 +62,7 @@ 'driver' => 'single', 'path' => storage_path('logs/application.log'), 'level' => env('LOG_LEVEL', 'debug'), + 'replace_placeholders' => true, ], 'daily' => [ @@ -68,6 +70,7 @@ 'path' => storage_path('logs/application.log'), 'level' => env('LOG_LEVEL', 'debug'), 'days' => 14, + 'replace_placeholders' => true, ], 'slack' => [ @@ -76,6 +79,7 @@ 'username' => 'Application Log', 'emoji' => ':boom:', 'level' => env('LOG_LEVEL', 'critical'), + 'replace_placeholders' => true, ], 'papertrail' => [ @@ -87,6 +91,7 @@ 'port' => env('PAPERTRAIL_PORT'), 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'), ], + 'processors' => [PsrLogMessageProcessor::class], ], 'stderr' => [ @@ -97,16 +102,20 @@ 'with' => [ 'stream' => 'php://stderr', ], + 'processors' => [PsrLogMessageProcessor::class], ], 'syslog' => [ 'driver' => 'syslog', 'level' => env('LOG_LEVEL', 'debug'), + 'facility' => LOG_USER, + 'replace_placeholders' => true, ], 'errorlog' => [ 'driver' => 'errorlog', 'level' => env('LOG_LEVEL', 'debug'), + 'replace_placeholders' => true, ], 'null' => [ diff --git a/config/mail.php b/config/mail.php index be063918..a0962d2e 100644 --- a/config/mail.php +++ b/config/mail.php @@ -28,7 +28,7 @@ | while sending an e-mail. You will specify which one you are using for | your mailers below. You are free to add additional mailers as required. | - | Supported: "smtp", "sendmail", "mailgun", "ses", + | Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2", | "postmark", "log", "array", "failover" | */ @@ -36,6 +36,7 @@ 'mailers' => [ 'smtp' => [ 'transport' => 'smtp', + 'url' => env('MAIL_URL'), 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 'port' => env('MAIL_PORT', 587), 'encryption' => env('MAIL_ENCRYPTION', 'tls'), @@ -51,10 +52,17 @@ 'mailgun' => [ 'transport' => 'mailgun', + // 'client' => [ + // 'timeout' => 5, + // ], ], 'postmark' => [ 'transport' => 'postmark', + // 'message_stream_id' => null, + // 'client' => [ + // 'timeout' => 5, + // ], ], 'sendmail' => [ diff --git a/config/queue.php b/config/queue.php index 1d269804..58f68d48 100644 --- a/config/queue.php +++ b/config/queue.php @@ -73,6 +73,22 @@ ], + /* + |-------------------------------------------------------------------------- + | Job Batching + |-------------------------------------------------------------------------- + | + | The following options configure the database and table that store job + | batching information. These options can be updated to any database + | connection and table which has been defined by your application. + | + */ + + 'batching' => [ + 'database' => env('DB_CONNECTION', 'mysql'), + 'table' => 'job_batches', + ], + /* |-------------------------------------------------------------------------- | Failed Queue Jobs diff --git a/config/sanctum.php b/config/sanctum.php index ad4ddc25..4fd32c77 100644 --- a/config/sanctum.php +++ b/config/sanctum.php @@ -43,13 +43,28 @@ class_exists(Sanctum::class) |-------------------------------------------------------------------------- | | This value controls the number of minutes until an issued token will be - | considered expired. If this value is null, personal access tokens do - | not expire. This won't tweak the lifetime of first-party sessions. + | considered expired. This will override any values set in the token's + | "expires_at" attribute, but first-party sessions are not affected. | */ 'expiration' => null, + /* + |-------------------------------------------------------------------------- + | Token Prefix + |-------------------------------------------------------------------------- + | + | Sanctum can prefix new tokens in order to take advantage of various + | security scanning initiaives maintained by open source platforms + | that alert developers if they commit tokens into repositories. + | + | See: https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning + | + */ + + 'token_prefix' => env('SANCTUM_TOKEN_PREFIX', ''), + /* |-------------------------------------------------------------------------- | Sanctum Middleware @@ -62,8 +77,9 @@ class_exists(Sanctum::class) */ 'middleware' => [ - 'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class, + 'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class, 'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class, + 'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class, ], ]; From 90cf69f0494e8ae961ba4b762665e17e24ae8798 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 16 Nov 2023 12:56:10 -0600 Subject: [PATCH 08/48] =?UTF-8?q?=F0=9F=94=A5=20Remove=20deprecated=20Faca?= =?UTF-8?q?de=20class?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Roots/Acorn/Facade.php | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 src/Roots/Acorn/Facade.php diff --git a/src/Roots/Acorn/Facade.php b/src/Roots/Acorn/Facade.php deleted file mode 100644 index 988bfe6a..00000000 --- a/src/Roots/Acorn/Facade.php +++ /dev/null @@ -1,13 +0,0 @@ - Date: Thu, 16 Nov 2023 12:56:31 -0600 Subject: [PATCH 09/48] =?UTF-8?q?=F0=9F=94=A5=20Remove=20deprecated=20Sage?= =?UTF-8?q?Features=20class=20and=20provider?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Roots/Acorn/Bootstrap/SageFeatures.php | 34 ------------------- .../Providers/SageFeaturesServiceProvider.php | 14 -------- 2 files changed, 48 deletions(-) delete mode 100644 src/Roots/Acorn/Bootstrap/SageFeatures.php delete mode 100644 src/Roots/Acorn/Providers/SageFeaturesServiceProvider.php diff --git a/src/Roots/Acorn/Bootstrap/SageFeatures.php b/src/Roots/Acorn/Bootstrap/SageFeatures.php deleted file mode 100644 index dc68360d..00000000 --- a/src/Roots/Acorn/Bootstrap/SageFeatures.php +++ /dev/null @@ -1,34 +0,0 @@ -ThemeServiceProvider should extend [%s].", - \Roots\Acorn\Sage\SageServiceProvider::class, - ), - 'add_theme_support(\'sage\') is not supported.', - 'Acorn › Boot Error', - 'Check out the release notes for more information.

This message will be removed with the next beta release of Acorn.' - ); - } - } -} diff --git a/src/Roots/Acorn/Providers/SageFeaturesServiceProvider.php b/src/Roots/Acorn/Providers/SageFeaturesServiceProvider.php deleted file mode 100644 index dc655ab4..00000000 --- a/src/Roots/Acorn/Providers/SageFeaturesServiceProvider.php +++ /dev/null @@ -1,14 +0,0 @@ - Date: Thu, 16 Nov 2023 12:58:03 -0600 Subject: [PATCH 10/48] =?UTF-8?q?=F0=9F=8E=A8=20Improve=20provider=20confi?= =?UTF-8?q?g=20property=20name=20on=20the=20AcornServiceProvider?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Roots/Acorn/Providers/AcornServiceProvider.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Roots/Acorn/Providers/AcornServiceProvider.php b/src/Roots/Acorn/Providers/AcornServiceProvider.php index 7907ae01..5b194c18 100644 --- a/src/Roots/Acorn/Providers/AcornServiceProvider.php +++ b/src/Roots/Acorn/Providers/AcornServiceProvider.php @@ -20,7 +20,7 @@ class AcornServiceProvider extends ServiceProvider * * @var string[] */ - protected $provider_configs = [ + protected $providerConfigs = [ \Fruitcake\Cors\CorsServiceProvider::class => 'cors', \Illuminate\Auth\AuthServiceProvider::class => 'auth', \Illuminate\Broadcasting\BroadcastServiceProvider::class => 'broadcasting', @@ -67,7 +67,7 @@ public function boot() */ protected function registerConfigs() { - $configs = array_merge($this->configs, array_values($this->provider_configs)); + $configs = array_merge($this->configs, array_values($this->providerConfigs)); foreach ($configs as $config) { $this->mergeConfigFrom(dirname(__DIR__, 4) . "/config/{$config}.php", $config); @@ -105,7 +105,7 @@ protected function publishConfigs() */ protected function filterPublishableConfigs() { - $configs = array_filter($this->provider_configs, function ($provider) { + $configs = array_filter($this->providerConfigs, function ($provider) { return class_exists($provider) && $this->app->getProviders($provider); }, ARRAY_FILTER_USE_KEY); From 2ca90b5c382bf663b6c3e8a125d8c865597d9aa1 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 16 Nov 2023 13:00:00 -0600 Subject: [PATCH 11/48] =?UTF-8?q?=F0=9F=90=9B=20Add=20missing=20appended?= =?UTF-8?q?=20`$path`=20variable=20to=20the=20`bootstrapPath`=20method=20?= =?UTF-8?q?=F0=9F=8E=A8=20Improve=20Application=20class=20code=20quality?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Roots/Acorn/Application.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Roots/Acorn/Application.php b/src/Roots/Acorn/Application.php index 16949633..e4a68b01 100644 --- a/src/Roots/Acorn/Application.php +++ b/src/Roots/Acorn/Application.php @@ -48,8 +48,9 @@ public function __construct($basePath = null, $paths = null) if ($basePath) { $this->basePath = rtrim($basePath, '\/'); } + if ($paths) { - $this->usePaths((array)$paths); + $this->usePaths((array) $paths); } $this->registerGlobalHelpers(); @@ -131,7 +132,7 @@ protected function bindPathsInContainer() */ public function bootstrapPath($path = '') { - return $this->joinPaths($this->bootstrapPath ?: $this->storagePath('framework')); + return $this->joinPaths($this->bootstrapPath ?: $this->storagePath('framework'), $path); } /** @@ -250,13 +251,9 @@ protected function bootProvider(ServiceProvider $provider) */ public function registerConfiguredProviders() { - $providers = Collection::make($this->config['app.providers']) - ->filter(function ($provider) { - return class_exists($provider); - }) - ->partition(function ($provider) { - return Str::startsWith($provider, ['Illuminate\\', 'Roots\\']); - }); + $providers = Collection::make($this->make('config')->get('app.providers')) + ->filter(fn ($provider) => class_exists($provider)) + ->partition(fn ($provider) => str_starts_with($provider, 'Illuminate\\') || str_starts_with($provider, 'Roots\\')); $providers->splice(1, 0, [$this->make(PackageManifest::class)->providers()]); @@ -277,6 +274,7 @@ public function register($provider, $force = false) if (is_string($provider) && ! class_exists($provider)) { throw new SkipProviderException("Skipping provider [{$provider}] because it does not exist."); } + return parent::register($provider, $force); } catch (Throwable $e) { return $this->skipProvider($provider, $e); @@ -313,6 +311,7 @@ protected function skipProvider($provider, Throwable $e): ServiceProvider } return is_object($provider) ? $provider : new class ($this) extends ServiceProvider { + // }; } From fedb4af0ffeb794a11c5c8794232ecd5bebc849d Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 16 Nov 2023 13:00:34 -0600 Subject: [PATCH 12/48] =?UTF-8?q?=F0=9F=8E=A8=20Improve=20the=20`Sage`=20c?= =?UTF-8?q?lass=20`filter()`=20method?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Roots/Acorn/Sage/Sage.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Roots/Acorn/Sage/Sage.php b/src/Roots/Acorn/Sage/Sage.php index 229695a2..99f982dd 100644 --- a/src/Roots/Acorn/Sage/Sage.php +++ b/src/Roots/Acorn/Sage/Sage.php @@ -82,9 +82,8 @@ public function __construct( */ public function filter($filter) { - if (method_exists($this, $filter)) { - return [$this, $filter]; - } - return [$this, 'filter' . Str::studly($filter)]; + return method_exists($this, $filter) ? + [$this, $filter] : + [$this, 'filter' . Str::studly($filter)]; } } From f2f97ce0059d62622c640c915444d5d200779b9a Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 16 Nov 2023 13:01:27 -0600 Subject: [PATCH 13/48] =?UTF-8?q?=F0=9F=94=A7=20Remove=20`SageFeatures`=20?= =?UTF-8?q?from=20the=20`Kernel`=20bootstrap=20classes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Roots/Acorn/Kernel.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Roots/Acorn/Kernel.php b/src/Roots/Acorn/Kernel.php index bcf285f4..3eb4291e 100644 --- a/src/Roots/Acorn/Kernel.php +++ b/src/Roots/Acorn/Kernel.php @@ -20,7 +20,6 @@ class Kernel implements KernelContract * @var string[] */ protected $bootstrappers = [ - \Roots\Acorn\Bootstrap\SageFeatures::class, \Roots\Acorn\Bootstrap\LoadConfiguration::class, \Roots\Acorn\Bootstrap\HandleExceptions::class, \Roots\Acorn\Bootstrap\RegisterFacades::class, From 4eb8099519b94756ddf5243946e09e87cd87d3ac Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 16 Nov 2023 13:02:38 -0600 Subject: [PATCH 14/48] =?UTF-8?q?=E2=8F=AA=20Undeprecate=20the=20ServicePr?= =?UTF-8?q?ovider=20class=20=E2=9C=A8=20Implement=20the=20`DefaultProvider?= =?UTF-8?q?s`=20method?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Roots/Acorn/DefaultProviders.php | 33 ++++++++++++++++++++++++++++ src/Roots/Acorn/ServiceProvider.php | 13 +++++++---- 2 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 src/Roots/Acorn/DefaultProviders.php diff --git a/src/Roots/Acorn/DefaultProviders.php b/src/Roots/Acorn/DefaultProviders.php new file mode 100644 index 00000000..59f5c4b9 --- /dev/null +++ b/src/Roots/Acorn/DefaultProviders.php @@ -0,0 +1,33 @@ +providers = array_merge($this->providers, $this->acornProviders); + } +} diff --git a/src/Roots/Acorn/ServiceProvider.php b/src/Roots/Acorn/ServiceProvider.php index 534d2b51..1165a47f 100644 --- a/src/Roots/Acorn/ServiceProvider.php +++ b/src/Roots/Acorn/ServiceProvider.php @@ -4,10 +4,15 @@ use Illuminate\Support\ServiceProvider as ServiceProviderBase; -/** - * @deprecated - */ abstract class ServiceProvider extends ServiceProviderBase { - // + /** + * Get the default providers for a Acorn application. + * + * @return \Roots\Acorn\DefaultProviders + */ + public static function defaultProviders() + { + return new DefaultProviders; + } } From a28a5964aedec2ac950fad90eba9de9d3e689612 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 16 Nov 2023 13:05:50 -0600 Subject: [PATCH 15/48] =?UTF-8?q?=F0=9F=9A=A8=20Run=20phpcbf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Roots/Acorn/DefaultProviders.php | 2 +- src/Roots/Acorn/ServiceProvider.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Roots/Acorn/DefaultProviders.php b/src/Roots/Acorn/DefaultProviders.php index 59f5c4b9..9a2edae3 100644 --- a/src/Roots/Acorn/DefaultProviders.php +++ b/src/Roots/Acorn/DefaultProviders.php @@ -11,7 +11,7 @@ class DefaultProviders extends DefaultProvidersBase * * @var array */ - protected $acornProviders =[ + protected $acornProviders = [ \Roots\Acorn\Assets\AssetsServiceProvider::class, \Roots\Acorn\Filesystem\FilesystemServiceProvider::class, \Roots\Acorn\Providers\AcornServiceProvider::class, diff --git a/src/Roots/Acorn/ServiceProvider.php b/src/Roots/Acorn/ServiceProvider.php index 1165a47f..d48bf216 100644 --- a/src/Roots/Acorn/ServiceProvider.php +++ b/src/Roots/Acorn/ServiceProvider.php @@ -13,6 +13,6 @@ abstract class ServiceProvider extends ServiceProviderBase */ public static function defaultProviders() { - return new DefaultProviders; + return new DefaultProviders(); } } From c6aa09b2e4af972f41512694da1c8bc70eb30ea7 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 16 Nov 2023 13:08:25 -0600 Subject: [PATCH 16/48] =?UTF-8?q?=F0=9F=A9=B9=20Add=20missing=20namespace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Roots/Acorn/Kernel.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Roots/Acorn/Kernel.php b/src/Roots/Acorn/Kernel.php index 3eb4291e..cfa6e481 100644 --- a/src/Roots/Acorn/Kernel.php +++ b/src/Roots/Acorn/Kernel.php @@ -4,6 +4,7 @@ use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\Http\Kernel as KernelContract; +use Illuminate\Support\Facades\Facade; class Kernel implements KernelContract { From 3d1c31aaf6284e92344c61936c0419cce03c69e6 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 16 Nov 2023 13:22:41 -0600 Subject: [PATCH 17/48] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20bootstrap=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Roots/Acorn/Application.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Roots/Acorn/Application.php b/src/Roots/Acorn/Application.php index e4a68b01..673080a4 100644 --- a/src/Roots/Acorn/Application.php +++ b/src/Roots/Acorn/Application.php @@ -119,9 +119,20 @@ public function usePaths(array $paths) */ protected function bindPathsInContainer() { - $bootstrapPath = $this->bootstrapPath(); - parent::bindPathsInContainer(); - $this->instance('path.bootstrap', $bootstrapPath); + $this->instance('path', $this->path()); + $this->instance('path.base', $this->basePath()); + $this->instance('path.config', $this->configPath()); + $this->instance('path.database', $this->databasePath()); + $this->instance('path.public', $this->publicPath()); + $this->instance('path.resources', $this->resourcePath()); + $this->instance('path.storage', $this->storagePath()); + $this->instance('path.bootstrap', $this->bootstrapPath()); + + $this->useLangPath(value(function () { + return is_dir($directory = $this->resourcePath('lang')) + ? $directory + : $this->basePath('lang'); + })); } /** From 02ac3d73ec64242bbd2b463c73e04dac1b92f3f7 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 16 Nov 2023 13:50:57 -0600 Subject: [PATCH 18/48] =?UTF-8?q?=F0=9F=94=A5=20Remove=20deprecated=20call?= =?UTF-8?q?s=20to=20`SageFeatures`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Roots/Acorn/Console/Kernel.php | 1 - src/Roots/Acorn/Http/Kernel.php | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Roots/Acorn/Console/Kernel.php b/src/Roots/Acorn/Console/Kernel.php index c96b981d..d92b09d3 100644 --- a/src/Roots/Acorn/Console/Kernel.php +++ b/src/Roots/Acorn/Console/Kernel.php @@ -47,7 +47,6 @@ class Kernel extends FoundationConsoleKernel * @var string[] */ protected $bootstrappers = [ - \Roots\Acorn\Bootstrap\SageFeatures::class, \Roots\Acorn\Bootstrap\LoadConfiguration::class, \Roots\Acorn\Bootstrap\HandleExceptions::class, \Roots\Acorn\Bootstrap\RegisterFacades::class, diff --git a/src/Roots/Acorn/Http/Kernel.php b/src/Roots/Acorn/Http/Kernel.php index 0e9fd456..983962de 100644 --- a/src/Roots/Acorn/Http/Kernel.php +++ b/src/Roots/Acorn/Http/Kernel.php @@ -12,7 +12,6 @@ class Kernel extends HttpKernel * @var string[] */ protected $bootstrappers = [ - \Roots\Acorn\Bootstrap\SageFeatures::class, \Roots\Acorn\Bootstrap\LoadConfiguration::class, \Roots\Acorn\Bootstrap\HandleExceptions::class, \Roots\Acorn\Bootstrap\RegisterFacades::class, From 680b820f00425a949c2a959bc1d82b177831a148 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 16 Nov 2023 13:51:53 -0600 Subject: [PATCH 19/48] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20`timezone=5Fstring`?= =?UTF-8?q?=20sometimes=20returning=20an=20empty=20string?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/app.php b/config/app.php index 64a77e74..0beb750e 100644 --- a/config/app.php +++ b/config/app.php @@ -72,7 +72,7 @@ | */ - 'timezone' => get_option('timezone_string', 'UTC'), + 'timezone' => get_option('timezone_string') ?: 'UTC', /* |-------------------------------------------------------------------------- From a2ca2ec7e37bca48b94c492cd1893ad61d975593 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 16 Nov 2023 13:52:26 -0600 Subject: [PATCH 20/48] =?UTF-8?q?=E2=9E=95=20Replace=20deprecated=20`pestp?= =?UTF-8?q?hp/pest-plugin-mock`=20package=20with=20`mockery/mockery`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f44e2737..838cdb13 100644 --- a/composer.json +++ b/composer.json @@ -66,8 +66,8 @@ }, "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "^1.0.0", + "mockery/mockery": "^1.6", "pestphp/pest": "^1.0", - "pestphp/pest-plugin-mock": "^1.0", "phpcompatibility/php-compatibility": "^9.3", "roave/security-advisories": "dev-master", "spatie/laravel-ignition": "^2.1", From 491dab884b759c80f3be98fba89c3d21bd1e8eac Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 16 Nov 2023 13:53:30 -0600 Subject: [PATCH 21/48] =?UTF-8?q?=F0=9F=90=9B=20Filter=20out=20default=20p?= =?UTF-8?q?roviders=20from=20`illuminate/foundation`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Roots/Acorn/DefaultProviders.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Roots/Acorn/DefaultProviders.php b/src/Roots/Acorn/DefaultProviders.php index 9a2edae3..d9d001c6 100644 --- a/src/Roots/Acorn/DefaultProviders.php +++ b/src/Roots/Acorn/DefaultProviders.php @@ -2,6 +2,7 @@ namespace Roots\Acorn; +use Illuminate\Support\Collection; use Illuminate\Support\DefaultProviders as DefaultProvidersBase; class DefaultProviders extends DefaultProvidersBase @@ -28,6 +29,9 @@ public function __construct(?array $providers = null) { parent::__construct($providers); - $this->providers = array_merge($this->providers, $this->acornProviders); + $this->providers = Collection::make($this->providers) + ->merge($this->acornProviders) + ->filter(fn ($provider) => ! str_contains($provider, 'Illuminate\\Foundation\\')) + ->all(); } } From 349b5c6a55cf3ff9b243a48fd12f78ea4950c4c4 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 16 Nov 2023 14:09:01 -0600 Subject: [PATCH 22/48] =?UTF-8?q?=F0=9F=94=A7=20Comment=20out=20the=20`The?= =?UTF-8?q?meServiceProvider`=20example?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/app.php b/config/app.php index 0beb750e..59cd3d36 100644 --- a/config/app.php +++ b/config/app.php @@ -165,7 +165,7 @@ /* * Application Service Providers... */ - App\Providers\ThemeServiceProvider::class, + // App\Providers\ThemeServiceProvider::class, ])->toArray(), /* From f5394b0e800c16683c519f8f3bbeef5f74aef425 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 16 Nov 2023 14:46:18 -0600 Subject: [PATCH 23/48] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Chang?= =?UTF-8?q?e=20`Roots\Acorn\ServiceProvider`=20to=20`final`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Roots/Acorn/ServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Roots/Acorn/ServiceProvider.php b/src/Roots/Acorn/ServiceProvider.php index d48bf216..354ea564 100644 --- a/src/Roots/Acorn/ServiceProvider.php +++ b/src/Roots/Acorn/ServiceProvider.php @@ -4,7 +4,7 @@ use Illuminate\Support\ServiceProvider as ServiceProviderBase; -abstract class ServiceProvider extends ServiceProviderBase +final class ServiceProvider extends ServiceProviderBase { /** * Get the default providers for a Acorn application. From e7b14d64ca137eaad8a38340a9d4e1e7be64dd73 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 16 Nov 2023 15:08:21 -0600 Subject: [PATCH 24/48] =?UTF-8?q?=E2=9E=95=20Add=20`laravel/pint`=20to=20t?= =?UTF-8?q?he=20project=20=E2=9E=96=20Remove=20`squizlabs/php=5Fcodesniffe?= =?UTF-8?q?r`=20and=20`dealerdirect/phpcodesniffer-composer-installer`=20f?= =?UTF-8?q?rom=20the=20project?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 838cdb13..6427841c 100644 --- a/composer.json +++ b/composer.json @@ -65,7 +65,7 @@ "vlucas/phpdotenv": "^5.4.1" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^1.0.0", + "laravel/pint": "^1.13", "mockery/mockery": "^1.6", "pestphp/pest": "^1.0", "phpcompatibility/php-compatibility": "^9.3", @@ -73,7 +73,6 @@ "spatie/laravel-ignition": "^2.1", "spatie/pest-plugin-snapshots": "^1.0", "spatie/temporary-directory": "^2.0", - "squizlabs/php_codesniffer": "^3.5", "tmarsteel/mockery-callable-mock": "^2.1", "wp-cli/wp-cli": "^2.5" }, @@ -83,15 +82,14 @@ "config": { "sort-packages": true, "allow-plugins": { - "pestphp/pest-plugin": true, - "dealerdirect/phpcodesniffer-composer-installer": true + "pestphp/pest-plugin": true } }, "minimum-stability": "dev", "prefer-stable": true, "scripts": { - "lint": "phpcs", - "lint:fix": "phpcbf", + "lint": "pint --test", + "lint:fix": "pint", "test": "pest", "coverage": "XDEBUG_MODE=coverage pest --coverage --coverage-html=coverage" } From 55d190bb85ffc9363d4f13f9dc676ec79740b7f0 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 16 Nov 2023 15:08:39 -0600 Subject: [PATCH 25/48] =?UTF-8?q?=F0=9F=94=A5=20Remove=20deprecated=20`php?= =?UTF-8?q?cs.xml.dist`=20config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phpcs.xml.dist | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 phpcs.xml.dist diff --git a/phpcs.xml.dist b/phpcs.xml.dist deleted file mode 100644 index ccc35ac3..00000000 --- a/phpcs.xml.dist +++ /dev/null @@ -1,29 +0,0 @@ - - - PSR12 with PHP 8.0+ compatibility - - - - - - - - - src/Illuminate/* - - - - - - src/Roots - - - - 1 - - - - - tests/* - - From 8464250d1c4ba41335ab422f7d0b102ef1f04e99 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 16 Nov 2023 15:08:57 -0600 Subject: [PATCH 26/48] =?UTF-8?q?=F0=9F=94=A7=20Add=20a=20default=20`pint.?= =?UTF-8?q?json`=20config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pint.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 pint.json diff --git a/pint.json b/pint.json new file mode 100644 index 00000000..b3dd6e50 --- /dev/null +++ b/pint.json @@ -0,0 +1,5 @@ +{ + "exclude": [ + "src/Illuminate" + ] +} From b0c6e44abf1a9d72017bf7fcf5e0d3ba16f4768c Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 16 Nov 2023 15:09:20 -0600 Subject: [PATCH 27/48] =?UTF-8?q?=F0=9F=9A=A8=20Run=20Pint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/assets.php | 4 +- config/database.php | 22 ++++---- src/Roots/Acorn/Application.php | 28 ++++------ src/Roots/Acorn/Assets/Asset/Asset.php | 21 +++---- src/Roots/Acorn/Assets/Asset/JsonAsset.php | 6 +- src/Roots/Acorn/Assets/Asset/PhpAsset.php | 5 ++ src/Roots/Acorn/Assets/Asset/TextAsset.php | 23 ++++---- src/Roots/Acorn/Assets/AssetFactory.php | 32 ++--------- src/Roots/Acorn/Assets/Bundle.php | 19 +++---- .../Acorn/Assets/Concerns/Conditional.php | 2 +- .../Acorn/Assets/Concerns/Enqueuable.php | 23 +++----- src/Roots/Acorn/Assets/Contracts/Asset.php | 6 -- src/Roots/Acorn/Assets/Contracts/Manifest.php | 6 +- src/Roots/Acorn/Assets/Manager.php | 22 ++------ src/Roots/Acorn/Assets/Manifest.php | 11 +--- .../Middleware/LaravelMixMiddleware.php | 5 +- .../Assets/Middleware/RootsBudMiddleware.php | 7 +-- .../Acorn/Assets/View/BladeDirective.php | 4 +- src/Roots/Acorn/Bootloader.php | 55 +++++++------------ .../Acorn/Bootstrap/HandleExceptions.php | 9 ++- .../Acorn/Bootstrap/LoadConfiguration.php | 5 +- src/Roots/Acorn/Bootstrap/RegisterConsole.php | 7 +-- src/Roots/Acorn/Bootstrap/RegisterFacades.php | 1 - .../Acorn/Console/Commands/AboutCommand.php | 4 +- .../Console/Commands/AcornInitCommand.php | 9 ++- .../Console/Commands/ComposerMakeCommand.php | 9 ++- .../Acorn/Console/Commands/SummaryCommand.php | 4 +- .../Console/Commands/VendorPublishCommand.php | 8 +-- .../Console/Concerns/GetsFreshApplication.php | 1 - .../Concerns/GracefullyCallsCommands.php | 7 +-- src/Roots/Acorn/Console/Console.php | 21 +------ src/Roots/Acorn/Console/Kernel.php | 4 +- src/Roots/Acorn/DefaultProviders.php | 2 +- src/Roots/Acorn/Exceptions/Handler.php | 3 +- .../Exceptions/SkipProviderException.php | 9 +-- .../Acorn/Exceptions/Whoops/WhoopsHandler.php | 8 +-- src/Roots/Acorn/Filesystem/Filesystem.php | 15 ++--- src/Roots/Acorn/Kernel.php | 2 - src/Roots/Acorn/PackageManifest.php | 9 ++- .../Acorn/Providers/AcornServiceProvider.php | 6 +- .../Acorn/Sage/Concerns/FiltersBodyClass.php | 6 +- .../Acorn/Sage/Concerns/FiltersEnqueues.php | 6 +- .../Acorn/Sage/Concerns/FiltersTemplates.php | 8 +-- .../Acorn/Sage/Concerns/FiltersThePost.php | 2 +- .../Acorn/Sage/Concerns/FiltersViews.php | 2 +- src/Roots/Acorn/Sage/Sage.php | 13 +---- src/Roots/Acorn/Sage/SageServiceProvider.php | 2 - src/Roots/Acorn/Sage/ViewFinder.php | 4 +- src/Roots/Acorn/View/Composer.php | 4 +- .../View/Composers/Concerns/AcfFields.php | 3 +- .../View/Composers/Concerns/Arrayable.php | 1 + .../View/Composers/Concerns/Cacheable.php | 8 +-- src/Roots/Acorn/View/Composers/Debugger.php | 6 +- src/Roots/Acorn/View/FileViewFinder.php | 11 ++-- src/Roots/Acorn/View/ViewServiceProvider.php | 8 +-- src/Roots/helpers.php | 21 ++----- src/_ide-helpers.php | 1 + tests/Application/ApplicationTest.php | 3 +- tests/Assets/AssetsHelpersTest.php | 19 +++---- tests/Assets/AssetsServiceProviderTest.php | 4 +- tests/Assets/BudCompatibilityTest.php | 4 -- tests/Assets/BundleTest.php | 6 +- tests/Assets/ManagerTest.php | 26 ++++----- .../public/scripts/manifest.asset.php | 2 +- .../public/scripts/manifest.asset.php | 2 +- .../HandleExceptionsRegistrationTest.php | 1 - tests/Exceptions/HandlerTest.php | 2 - tests/Exceptions/WhoopsHandlerTest.php | 2 - tests/Helpers.php | 9 ++- tests/Test/Concerns/SupportsGlobalStubs.php | 16 +++--- .../Test/Concerns/SupportsScopedFixtures.php | 4 +- .../Test/Concerns/SupportsScopedSnapshots.php | 4 +- .../Test/Concerns/SupportsWordPressStubs.php | 2 +- tests/Test/Stubs/EmptyClass.php | 2 +- tests/Test/TestCase.php | 2 +- tests/bootstrap.php | 4 +- 76 files changed, 253 insertions(+), 411 deletions(-) diff --git a/config/assets.php b/config/assets.php index faddde51..0edb1280 100644 --- a/config/assets.php +++ b/config/assets.php @@ -36,6 +36,6 @@ 'url' => get_theme_file_uri('public'), 'assets' => get_theme_file_path('public/manifest.json'), 'bundles' => get_theme_file_path('public/entrypoints.json'), - ] - ] + ], + ], ]; diff --git a/config/database.php b/config/database.php index 70aefc4a..7f809573 100644 --- a/config/database.php +++ b/config/database.php @@ -44,18 +44,18 @@ ], 'wordpress' => [ - 'driver' => 'mysql', - 'host' => DB_HOST, - 'database' => DB_NAME, - 'username' => DB_USER, - 'password' => DB_PASSWORD, - 'unix_socket' => env('DB_SOCKET', ''), - 'charset' => DB_CHARSET, - 'collation' => $GLOBALS['wpdb']->collate, - 'prefix' => $GLOBALS['wpdb']->prefix, + 'driver' => 'mysql', + 'host' => DB_HOST, + 'database' => DB_NAME, + 'username' => DB_USER, + 'password' => DB_PASSWORD, + 'unix_socket' => env('DB_SOCKET', ''), + 'charset' => DB_CHARSET, + 'collation' => $GLOBALS['wpdb']->collate, + 'prefix' => $GLOBALS['wpdb']->prefix, 'prefix_indexes' => true, - 'strict' => true, - 'engine' => null, + 'strict' => true, + 'engine' => null, 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], diff --git a/src/Roots/Acorn/Application.php b/src/Roots/Acorn/Application.php index 673080a4..70d2a24d 100644 --- a/src/Roots/Acorn/Application.php +++ b/src/Roots/Acorn/Application.php @@ -10,8 +10,6 @@ use Illuminate\Support\Collection; use Illuminate\Support\Env; use Illuminate\Support\ServiceProvider; -use Illuminate\Support\Str; -use Roots\Acorn\PackageManifest; use Roots\Acorn\Exceptions\SkipProviderException; use Roots\Acorn\Filesystem\Filesystem; use RuntimeException; @@ -40,7 +38,7 @@ class Application extends FoundationApplication * Create a new Illuminate application instance. * * @param string|null $basePath - * @param array|null $paths + * @param array|null $paths * @return void */ public function __construct($basePath = null, $paths = null) @@ -65,7 +63,7 @@ public function __construct($basePath = null, $paths = null) */ protected function registerGlobalHelpers() { - require_once dirname(__DIR__, 2) . '/Illuminate/Foundation/helpers.php'; + require_once dirname(__DIR__, 2).'/Illuminate/Foundation/helpers.php'; } /** @@ -190,7 +188,7 @@ protected function registerPackageManifest() $composer_paths = collect(get_option('active_plugins')) ->map(function ($plugin) { - return WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . dirname($plugin); + return WP_PLUGIN_DIR.DIRECTORY_SEPARATOR.dirname($plugin); }) ->merge([ $this->basePath(), @@ -225,7 +223,7 @@ protected function registerPackageManifest() */ public function isDownForMaintenance() { - return is_file($this->storagePath() . '/framework/down') || (defined('ABSPATH') && is_file(constant('ABSPATH') . '/.maintenance')); + return is_file($this->storagePath().'/framework/down') || (defined('ABSPATH') && is_file(constant('ABSPATH').'/.maintenance')); } /** @@ -243,7 +241,6 @@ public function registerCoreContainerAliases() /** * Boot the given service provider. * - * @param \Illuminate\Support\ServiceProvider $provider * @return void */ protected function bootProvider(ServiceProvider $provider) @@ -296,8 +293,6 @@ public function register($provider, $force = false) * Skip booting service provider and log error. * * @param \Illuminate\Support\ServiceProvider|string $provider - * @param Throwable $e - * @return \Illuminate\Support\ServiceProvider */ protected function skipProvider($provider, Throwable $e): ServiceProvider { @@ -321,7 +316,8 @@ protected function skipProvider($provider, Throwable $e): ServiceProvider throw $e; } - return is_object($provider) ? $provider : new class ($this) extends ServiceProvider { + return is_object($provider) ? $provider : new class($this) extends ServiceProvider + { // }; } @@ -343,7 +339,7 @@ public function getNamespace() foreach ((array) data_get($composer, 'autoload.psr-4') as $namespace => $path) { foreach ((array) $path as $pathChoice) { - if (realpath($this->path()) === realpath(dirname($composer_path) . DIRECTORY_SEPARATOR . $pathChoice)) { + if (realpath($this->path()) === realpath(dirname($composer_path).DIRECTORY_SEPARATOR.$pathChoice)) { return $this->namespace = $namespace; } } @@ -360,23 +356,21 @@ public function getNamespace() * * If one is not found, then it will assume that there's a * composer.json file in the base path. - * - * @return string */ protected function getAppComposer(): string { - return ((new Filesystem())->closest($this->path(), 'composer.json')) ?? $this->basePath('composer.json'); + return (new Filesystem())->closest($this->path(), 'composer.json') ?? $this->basePath('composer.json'); } /** * Set the application namespace. * - * @param string $namespace + * @param string $namespace * @return $this */ public function useNamespace($namespace) { - $this->namespace = trim($namespace, '\\') . '\\'; + $this->namespace = trim($namespace, '\\').'\\'; return $this; } @@ -388,7 +382,7 @@ public function useNamespace($namespace) */ public function version() { - return 'Acorn ' . static::VERSION . ' (Laravel ' . parent::VERSION . ')'; + return 'Acorn '.static::VERSION.' (Laravel '.parent::VERSION.')'; } public static function isExperimentalRouterEnabled() diff --git a/src/Roots/Acorn/Assets/Asset/Asset.php b/src/Roots/Acorn/Assets/Asset/Asset.php index 4efd90e6..adb73819 100644 --- a/src/Roots/Acorn/Assets/Asset/Asset.php +++ b/src/Roots/Acorn/Assets/Asset/Asset.php @@ -2,9 +2,9 @@ namespace Roots\Acorn\Assets\Asset; -use SplFileInfo; use Roots\Acorn\Assets\Contracts\Asset as AssetContract; use Roots\Acorn\Filesystem\Filesystem; +use SplFileInfo; class Asset implements AssetContract { @@ -46,8 +46,8 @@ class Asset implements AssetContract /** * Get asset from manifest * - * @param string $path Local path - * @param string $uri Remote URI + * @param string $path Local path + * @param string $uri Remote URI */ public function __construct(string $path, string $uri) { @@ -86,12 +86,11 @@ public function contents(): string /** * Get the relative path to the asset. * - * @param string $base_path Base path to use for relative path. - * @return string + * @param string $base_path Base path to use for relative path. */ public function relativePath(string $base_path): string { - $base_path = rtrim($base_path, '/\\') . '/'; + $base_path = rtrim($base_path, '/\\').'/'; return (new Filesystem())->getRelativePath($base_path, $this->path()); } @@ -113,10 +112,9 @@ public function base64() /** * Get data URL of asset. * - * @param string $mediatype MIME content type - * @return string + * @param string $mediatype MIME content type */ - public function dataUrl(?string $mediatype = null): string + public function dataUrl(string $mediatype = null): string { if ($this->dataUrl) { return $this->dataUrl; @@ -132,10 +130,9 @@ public function dataUrl(?string $mediatype = null): string /** * Get data URL of asset. * - * @param string $mediatype MIME content type - * @return string + * @param string $mediatype MIME content type */ - public function dataUri(?string $mediatype = null): string + public function dataUri(string $mediatype = null): string { return $this->dataUrl($mediatype); } diff --git a/src/Roots/Acorn/Assets/Asset/JsonAsset.php b/src/Roots/Acorn/Assets/Asset/JsonAsset.php index 40d4676c..7ae3fa51 100644 --- a/src/Roots/Acorn/Assets/Asset/JsonAsset.php +++ b/src/Roots/Acorn/Assets/Asset/JsonAsset.php @@ -5,7 +5,7 @@ use Illuminate\Contracts\Support\Arrayable; use Illuminate\Contracts\Support\Jsonable; -class JsonAsset extends TextAsset implements Jsonable, Arrayable +class JsonAsset extends TextAsset implements Arrayable, Jsonable { /** * {@inheritdoc} @@ -26,8 +26,8 @@ public function toArray(): array /** * Decode JSON data. * - * @param int $options - * @param int $depth + * @param int $options + * @param int $depth * @return array|null */ public function decode($options = 0, $depth = 512) diff --git a/src/Roots/Acorn/Assets/Asset/PhpAsset.php b/src/Roots/Acorn/Assets/Asset/PhpAsset.php index 97e33b71..2baaffb5 100644 --- a/src/Roots/Acorn/Assets/Asset/PhpAsset.php +++ b/src/Roots/Acorn/Assets/Asset/PhpAsset.php @@ -14,6 +14,7 @@ class PhpAsset extends Asset public function requireOnce() { $this->assertExists(); + return require_once $this->path(); } @@ -25,6 +26,7 @@ public function requireOnce() public function require() { $this->assertExists(); + return require $this->path(); } @@ -36,6 +38,7 @@ public function require() public function includeOnce() { $this->assertExists(); + return include_once $this->path(); } @@ -47,11 +50,13 @@ public function includeOnce() public function include() { $this->assertExists(); + return include $this->path(); } /** * Assert that the asset exists. + * * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ protected function assertExists() diff --git a/src/Roots/Acorn/Assets/Asset/TextAsset.php b/src/Roots/Acorn/Assets/Asset/TextAsset.php index 2f432912..9db6143f 100644 --- a/src/Roots/Acorn/Assets/Asset/TextAsset.php +++ b/src/Roots/Acorn/Assets/Asset/TextAsset.php @@ -14,8 +14,7 @@ class TextAsset extends Asset /** * Get character encoding. * - * @param string $fallback Fallback if charset cannot be determined - * @return string + * @param string $fallback Fallback if charset cannot be determined */ public function charset($fallback = 'UTF-8'): string { @@ -37,12 +36,11 @@ public function charset($fallback = 'UTF-8'): string /** * Get data URL of asset. * - * @param string $mediatype MIME content type - * @param string $charset Character encoding - * @param string $urlencode List of characters to be percent-encoded - * @return string + * @param string $mediatype MIME content type + * @param string $charset Character encoding + * @param string $urlencode List of characters to be percent-encoded */ - public function dataUrl(?string $mediatype = null, ?string $charset = null, string $urlencode = '%\'"'): string + public function dataUrl(string $mediatype = null, string $charset = null, string $urlencode = '%\'"'): string { if ($this->dataUrl) { return $this->dataUrl; @@ -53,7 +51,7 @@ public function dataUrl(?string $mediatype = null, ?string $charset = null, stri } if (! strstr($mediatype, 'charset')) { - $mediatype .= ';charset=' . ($charset ?: $this->charset()); + $mediatype .= ';charset='.($charset ?: $this->charset()); } $percents = []; @@ -69,12 +67,11 @@ public function dataUrl(?string $mediatype = null, ?string $charset = null, stri /** * Get data URL of asset. * - * @param string $mediatype MIME content type - * @param string $charset Character encoding - * @param string $urlencode List of characters to be percent-encoded - * @return string + * @param string $mediatype MIME content type + * @param string $charset Character encoding + * @param string $urlencode List of characters to be percent-encoded */ - public function dataUri(?string $mediatype = null, ?string $charset = null, string $urlencode = '%\'"'): string + public function dataUri(string $mediatype = null, string $charset = null, string $urlencode = '%\'"'): string { return $this->dataUrl($mediatype, $charset, $urlencode); } diff --git a/src/Roots/Acorn/Assets/AssetFactory.php b/src/Roots/Acorn/Assets/AssetFactory.php index c413bced..20dedc49 100644 --- a/src/Roots/Acorn/Assets/AssetFactory.php +++ b/src/Roots/Acorn/Assets/AssetFactory.php @@ -2,10 +2,10 @@ namespace Roots\Acorn\Assets; +use Roots\Acorn\Assets\Asset\Asset; use Roots\Acorn\Assets\Asset\JsonAsset; use Roots\Acorn\Assets\Asset\PhpAsset; use Roots\Acorn\Assets\Asset\SvgAsset; -use Roots\Acorn\Assets\Asset\Asset; use Roots\Acorn\Assets\Contracts\Asset as AssetContract; class AssetFactory @@ -13,17 +13,17 @@ class AssetFactory /** * Create Asset instance. * - * @param string $path Local path - * @param string $uri Remote URI - * @param string $type Asset type + * @param string $path Local path + * @param string $uri Remote URI + * @param string $type Asset type */ - public static function create(string $path, string $uri, ?string $type = null): AssetContract + public static function create(string $path, string $uri, string $type = null): AssetContract { if (! $type) { $type = pathinfo($path, PATHINFO_EXTENSION); } - if (method_exists(self::class, $method = 'create' . ucfirst(strtolower($type)) . 'Asset')) { + if (method_exists(self::class, $method = 'create'.ucfirst(strtolower($type)).'Asset')) { return self::{$method}($path, $uri); } @@ -32,10 +32,6 @@ public static function create(string $path, string $uri, ?string $type = null): /** * Convert an asset to another asset type. - * - * @param AssetContract $asset - * @param string $type - * @return AssetContract */ public static function convert(AssetContract $asset, string $type): AssetContract { @@ -44,10 +40,6 @@ public static function convert(AssetContract $asset, string $type): AssetContrac /** * Create Asset instance. - * - * @param string $path - * @param string $uri - * @return Asset */ protected static function createAsset(string $path, string $uri): Asset { @@ -56,10 +48,6 @@ protected static function createAsset(string $path, string $uri): Asset /** * Create JsonAsset instance. - * - * @param string $path - * @param string $uri - * @return JsonAsset */ protected static function createJsonAsset(string $path, string $uri): JsonAsset { @@ -68,10 +56,6 @@ protected static function createJsonAsset(string $path, string $uri): JsonAsset /** * Create PhpAsset instance. - * - * @param string $path - * @param string $uri - * @return PhpAsset */ protected static function createPhpAsset(string $path, string $uri): PhpAsset { @@ -80,10 +64,6 @@ protected static function createPhpAsset(string $path, string $uri): PhpAsset /** * Create SvgAsset instance. - * - * @param string $path - * @param string $uri - * @return SvgAsset */ protected static function createSvgAsset(string $path, string $uri): SvgAsset { diff --git a/src/Roots/Acorn/Assets/Bundle.php b/src/Roots/Acorn/Assets/Bundle.php index 1b214938..aa84bb88 100644 --- a/src/Roots/Acorn/Assets/Bundle.php +++ b/src/Roots/Acorn/Assets/Bundle.php @@ -10,24 +10,23 @@ class Bundle implements BundleContract { - use Enqueuable; use Conditional; + use Enqueuable; protected $id; + protected $path; + protected $uri; + protected $runtime; + protected $bundle; protected static $runtimes = []; /** * Create a new bundle. - * - * @param string $id - * @param array $bundle - * @param string $path - * @param string $uri */ public function __construct(string $id, array $bundle, string $path, string $uri = '/') { @@ -43,10 +42,9 @@ public function __construct(string $id, array $bundle, string $path, string $uri * * Optionally pass a function to execute on each CSS file. * - * @param callable $callable * @return Collection|$this */ - public function css(?callable $callable = null) + public function css(callable $callable = null) { $styles = $this->conditional ? $this->bundle['css'] : []; @@ -67,10 +65,9 @@ public function css(?callable $callable = null) * * Optionally pass a function to execute on each JS file. * - * @param callable $callable * @return Collection|$this */ - public function js(?callable $callable = null) + public function js(callable $callable = null) { $scripts = $this->conditional ? array_merge($this->bundle['js'], $this->bundle['mjs']) : []; @@ -128,7 +125,7 @@ public function runtimeSource() /** * Get the bundle URL. * - * @param string $path + * @param string $path * @return string */ protected function getUrl($path) diff --git a/src/Roots/Acorn/Assets/Concerns/Conditional.php b/src/Roots/Acorn/Assets/Concerns/Conditional.php index 00044956..30d4a92c 100644 --- a/src/Roots/Acorn/Assets/Concerns/Conditional.php +++ b/src/Roots/Acorn/Assets/Concerns/Conditional.php @@ -14,7 +14,7 @@ trait Conditional /** * Set conditional loading. * - * @param bool|callable $conditional + * @param bool|callable $conditional * @return $this */ public function when($conditional, ...$args) diff --git a/src/Roots/Acorn/Assets/Concerns/Enqueuable.php b/src/Roots/Acorn/Assets/Concerns/Enqueuable.php index 522822c9..ab955b83 100644 --- a/src/Roots/Acorn/Assets/Concerns/Enqueuable.php +++ b/src/Roots/Acorn/Assets/Concerns/Enqueuable.php @@ -16,20 +16,18 @@ trait Enqueuable * * Optionally pass a function to execute on each JS file. * - * @param callable $callable * @return Collection|$this */ - abstract public function js(?callable $callable = null); + abstract public function js(callable $callable = null); /** * Get CSS files in bundle. * * Optionally pass a function to execute on each CSS file. * - * @param callable $callable * @return Collection|$this */ - abstract public function css(?callable $callable = null); + abstract public function css(callable $callable = null); abstract public function runtime(); @@ -38,8 +36,6 @@ abstract public function runtimeSource(); /** * Enqueue CSS files in WordPress. * - * @param string $media - * @param array $dependencies * @return $this */ public function enqueueCss(string $media = 'all', array $dependencies = []) @@ -55,8 +51,6 @@ public function enqueueCss(string $media = 'all', array $dependencies = []) /** * Enqueue JS files in WordPress. * - * @param bool $in_footer - * @param array $dependencies * @return $this */ public function enqueueJs(bool $in_footer = true, array $dependencies = []) @@ -149,8 +143,8 @@ public function inlineRuntime() /** * Add an inline script before or after the bundle loads * - * @param string $contents - * @param string $position + * @param string $contents + * @param string $position * @return $this */ public function inline($contents, $position = 'after') @@ -159,7 +153,7 @@ public function inline($contents, $position = 'after') return $this; } - $handle = "{$this->id}/" . ( + $handle = "{$this->id}/".( $position === 'after' ? array_pop($handles) : array_shift($handles) @@ -173,8 +167,8 @@ public function inline($contents, $position = 'after') /** * Add localization data to be used by the bundle * - * @param string $name - * @param array $object + * @param string $name + * @param array $object * @return $this */ public function localize($name, $object) @@ -192,8 +186,6 @@ public function localize($name, $object) /** * Merge two or more arrays. * - * @param array $dependencies - * @param array $more_dependencies * @return void */ protected function mergeDependencies(array &$dependencies, array ...$more_dependencies) @@ -205,6 +197,7 @@ protected function mergeDependencies(array &$dependencies, array ...$more_depend * Reset inlined sources. * * @internal + * * @return void */ public static function resetInlinedSources() diff --git a/src/Roots/Acorn/Assets/Contracts/Asset.php b/src/Roots/Acorn/Assets/Contracts/Asset.php index 5240318d..12145849 100644 --- a/src/Roots/Acorn/Assets/Contracts/Asset.php +++ b/src/Roots/Acorn/Assets/Contracts/Asset.php @@ -8,8 +8,6 @@ interface Asset * Get the asset's remote URI * * Example: https://example.com/app/themes/sage/dist/styles/a1b2c3.min.css - * - * @return string */ public function uri(): string; @@ -17,15 +15,11 @@ public function uri(): string; * Get the asset's local path * * Example: /srv/www/example.com/current/web/app/themes/sage/dist/styles/a1b2c3.min.css - * - * @return string */ public function path(): string; /** * Check whether the asset exists on the file system - * - * @return bool */ public function exists(): bool; diff --git a/src/Roots/Acorn/Assets/Contracts/Manifest.php b/src/Roots/Acorn/Assets/Contracts/Manifest.php index 4e280b6f..012abbfb 100644 --- a/src/Roots/Acorn/Assets/Contracts/Manifest.php +++ b/src/Roots/Acorn/Assets/Contracts/Manifest.php @@ -7,16 +7,14 @@ interface Manifest /** * Get an asset object from the Manifest * - * @param string $key - * @return Asset + * @param string $key */ public function asset($key): Asset; /** * Get an asset bundle from the Manifest * - * @param string $key - * @return Bundle + * @param string $key */ public function bundle($key): Bundle; } diff --git a/src/Roots/Acorn/Assets/Manager.php b/src/Roots/Acorn/Assets/Manager.php index a64db474..9e240f2d 100644 --- a/src/Roots/Acorn/Assets/Manager.php +++ b/src/Roots/Acorn/Assets/Manager.php @@ -43,7 +43,7 @@ class Manager /** * Initialize the AssetManager instance. * - * @param Container $container + * @param Container $container */ public function __construct($config = []) { @@ -53,8 +53,7 @@ public function __construct($config = []) /** * Register the given manifest * - * @param string $name - * @param Manifest $manifest + * @param Manifest $manifest * @return static */ public function register(string $name, ManifestContract $manifest): self @@ -66,12 +65,8 @@ public function register(string $name, ManifestContract $manifest): self /** * Get a Manifest - * - * @param string $name - * @param array $config - * @return ManifestContract */ - public function manifest(string $name, ?array $config = null): ManifestContract + public function manifest(string $name, array $config = null): ManifestContract { $manifest = $this->manifests[$name] ?? $this->resolve($name, $config); @@ -81,8 +76,6 @@ public function manifest(string $name, ?array $config = null): ManifestContract /** * Resolve the given manifest. * - * @param string $name - * @return ManifestContract * * @throws InvalidArgumentException */ @@ -106,9 +99,6 @@ protected function resolve(string $name, ?array $config): ManifestContract /** * Manifest config pipeline. - * - * @param array $config - * @return array */ protected function pipeline(array $config): array { @@ -124,8 +114,7 @@ protected function pipeline(array $config): array /** * Opens a JSON manifest file from the local file system * - * @param string $jsonManifest Path to .json file - * @return array + * @param string $jsonManifest Path to .json file */ protected function getJsonManifest(string $jsonManifest): array { @@ -138,9 +127,6 @@ protected function getJsonManifest(string $jsonManifest): array /** * Get the assets manifest configuration. - * - * @param string $name - * @return array */ protected function getConfig(string $name): array { diff --git a/src/Roots/Acorn/Assets/Manifest.php b/src/Roots/Acorn/Assets/Manifest.php index b09ca56b..6507d2e0 100644 --- a/src/Roots/Acorn/Assets/Manifest.php +++ b/src/Roots/Acorn/Assets/Manifest.php @@ -6,7 +6,6 @@ use Roots\Acorn\Assets\Contracts\Asset as AssetContract; use Roots\Acorn\Assets\Contracts\Bundle as BundleContract; use Roots\Acorn\Assets\Contracts\Manifest as ManifestContract; -use Roots\Acorn\Assets\AssetFactory; class Manifest implements ManifestContract { @@ -18,7 +17,7 @@ class Manifest implements ManifestContract protected $uri; - public function __construct(string $path, string $uri, array $assets = [], ?array $bundles = null) + public function __construct(string $path, string $uri, array $assets = [], array $bundles = null) { $this->path = $path; $this->uri = $uri; @@ -32,8 +31,7 @@ public function __construct(string $path, string $uri, array $assets = [], ?arra /** * Get specified asset. * - * @param string $key - * @return AssetContract + * @param string $key */ public function asset($key): AssetContract { @@ -48,8 +46,7 @@ public function asset($key): AssetContract /** * Get specified bundles. * - * @param string $key - * @return BundleContract + * @param string $key */ public function bundle($key): BundleContract { @@ -58,8 +55,6 @@ public function bundle($key): BundleContract /** * Normalizes to forward slashes and removes leading slash. - * - * @return string */ protected function normalizeRelativePath(string $path): string { diff --git a/src/Roots/Acorn/Assets/Middleware/LaravelMixMiddleware.php b/src/Roots/Acorn/Assets/Middleware/LaravelMixMiddleware.php index 52bd0149..e8f0b1e9 100644 --- a/src/Roots/Acorn/Assets/Middleware/LaravelMixMiddleware.php +++ b/src/Roots/Acorn/Assets/Middleware/LaravelMixMiddleware.php @@ -9,7 +9,7 @@ class LaravelMixMiddleware /** * Handle the manifest config. * - * @param array $config + * @param array $config * @return array */ public function handle($config) @@ -25,9 +25,6 @@ public function handle($config) * Get the URI to a Mix hot module replacement server. * * @link https://laravel-mix.com/docs/hot-module-replacement - * - * @param string $path - * @return string|null */ protected function getMixHotUri(string $path): ?string { diff --git a/src/Roots/Acorn/Assets/Middleware/RootsBudMiddleware.php b/src/Roots/Acorn/Assets/Middleware/RootsBudMiddleware.php index 694eb7b6..feddf617 100644 --- a/src/Roots/Acorn/Assets/Middleware/RootsBudMiddleware.php +++ b/src/Roots/Acorn/Assets/Middleware/RootsBudMiddleware.php @@ -13,7 +13,7 @@ class RootsBudMiddleware */ protected $dev_origin; - public function __construct(?string $dev_origin = null) + public function __construct(string $dev_origin = null) { $this->dev_origin = $dev_origin; } @@ -21,7 +21,7 @@ public function __construct(?string $dev_origin = null) /** * Handle the manifest config. * - * @param array $config + * @param array $config * @return array */ public function handle($config) @@ -37,9 +37,6 @@ public function handle($config) * Get the URI to a Bud hot module replacement server. * * @link https://budjs.netlify.app/docs/bud.serve - * - * @param string $path - * @return string|null */ protected function getBudDevUri(string $path): ?string { diff --git a/src/Roots/Acorn/Assets/View/BladeDirective.php b/src/Roots/Acorn/Assets/View/BladeDirective.php index 342d7a91..c9d57d39 100644 --- a/src/Roots/Acorn/Assets/View/BladeDirective.php +++ b/src/Roots/Acorn/Assets/View/BladeDirective.php @@ -7,11 +7,11 @@ class BladeDirective /** * Invoke the @asset directive. * - * @param string $expression + * @param string $expression * @return string */ public function __invoke($expression) { - return sprintf("", '\Roots\asset', $expression); + return sprintf('', '\Roots\asset', $expression); } } diff --git a/src/Roots/Acorn/Bootloader.php b/src/Roots/Acorn/Bootloader.php index 1852968e..228e1731 100644 --- a/src/Roots/Acorn/Bootloader.php +++ b/src/Roots/Acorn/Bootloader.php @@ -42,8 +42,6 @@ class Bootloader /** * Set the Bootloader instance - * - * @param Bootloader $bootloader */ public static function setInstance(?self $bootloader) { @@ -53,20 +51,17 @@ public static function setInstance(?self $bootloader) /** * Get the Bootloader instance * - * @param \Illuminate\Contracts\Foundation\Application $app * @return static */ - public static function getInstance(?ApplicationContract $app = null) + public static function getInstance(ApplicationContract $app = null) { return static::$instance ??= new static($app); } /** * Create a new bootloader instance. - * - * @param \Illuminate\Contracts\Foundation\Application $app */ - public function __construct(?ApplicationContract $app = null) + public function __construct(ApplicationContract $app = null) { $this->app = $app; @@ -86,7 +81,7 @@ public function __invoke() /** * Boot the Application. * - * @param callable $callback + * @param callable $callback * @return void */ public function boot($callback = null) @@ -107,6 +102,7 @@ public function boot($callback = null) if ($app->runningInConsole()) { $this->enableHttpsInConsole(); + return class_exists('WP_CLI') ? $this->bootWpCli($app) : $this->bootConsole($app); } @@ -115,6 +111,7 @@ public function boot($callback = null) \Illuminate\Contracts\Http\Kernel::class, \Roots\Acorn\Http\Kernel::class ); + return $this->bootHttp($app); } @@ -138,7 +135,6 @@ protected function enableHttpsInConsole() /** * Boot the Application for console. * - * @param ApplicationContract $app * @return void */ protected function bootConsole(ApplicationContract $app) @@ -157,7 +153,6 @@ protected function bootConsole(ApplicationContract $app) /** * Boot the Application for wp-cli. * - * @param ApplicationContract $app * @return void */ protected function bootWpCli(ApplicationContract $app) @@ -173,6 +168,7 @@ protected function bootWpCli(ApplicationContract $app) foreach ($assoc_args as $key => $value) { if ($key === 'interaction' && $value === false) { $command .= ' --no-interaction'; + continue; } @@ -199,7 +195,6 @@ protected function bootWpCli(ApplicationContract $app) /** * Boot the Application for HTTP requests. * - * @param ApplicationContract $app * @return void */ protected function bootHttp(ApplicationContract $app) @@ -222,8 +217,7 @@ protected function bootHttp(ApplicationContract $app) add_filter( 'do_parse_request', - fn ($do_parse, \WP $wp, $extra_query_vars) => - apply_filters('acorn/router/do_parse_request', $do_parse, $wp, $extra_query_vars), + fn ($do_parse, \WP $wp, $extra_query_vars) => apply_filters('acorn/router/do_parse_request', $do_parse, $wp, $extra_query_vars), 100, 3 ); @@ -247,7 +241,6 @@ protected function bootHttp(ApplicationContract $app) /** * Boot the Application for WordPress requests. * - * @param ApplicationContract $app * @return void */ protected function bootWordPress(ApplicationContract $app) @@ -259,8 +252,7 @@ protected function bootWordPress(ApplicationContract $app) /** * Get Application instance. * - * @param ApplicationContract $app - * @return \Illuminate\Contracts\Foundation\Application + * @param ApplicationContract $app */ public function getApplication(): ApplicationContract { @@ -284,8 +276,7 @@ public function getApplication(): ApplicationContract if (class_exists(\Whoops\Run::class)) { $this->app->bind( \Illuminate\Contracts\Foundation\ExceptionRenderer::class, - fn (\Illuminate\Contracts\Foundation\Application $app) => - $app->make(\Roots\Acorn\Exceptions\Whoops\WhoopsExceptionRenderer::class) + fn (\Illuminate\Contracts\Foundation\Application $app) => $app->make(\Roots\Acorn\Exceptions\Whoops\WhoopsExceptionRenderer::class) ); } @@ -294,8 +285,6 @@ public function getApplication(): ApplicationContract /** * Get the application basepath - * - * @return string */ protected function basePath(): string { @@ -320,8 +309,6 @@ protected function basePath(): string /** * Use paths that are configurable by the developer. - * - * @return array */ protected function usePaths(): array { @@ -373,15 +360,14 @@ public function addAbsoluteApplicationPathPrefix($prefix) /** * Find a path that is configurable by the developer. * - * @param string $path - * @return string + * @param string $path */ protected function findPath($path): string { $path = trim($path, '\\/'); $searchPaths = [ - $this->basePath() . DIRECTORY_SEPARATOR . $path, + $this->basePath().DIRECTORY_SEPARATOR.$path, get_theme_file_path($path), ]; @@ -399,17 +385,14 @@ protected function findPath($path): string /** * Fallbacks for path types. - * - * @param string $path - * @return string */ protected function fallbackPath(string $path): string { return match ($path) { 'storage' => $this->fallbackStoragePath(), - 'app' => $this->basePath() . DIRECTORY_SEPARATOR . 'app', - 'public' => $this->basePath() . DIRECTORY_SEPARATOR . 'public', - default => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . $path, + 'app' => $this->basePath().DIRECTORY_SEPARATOR.'app', + 'public' => $this->basePath().DIRECTORY_SEPARATOR.'public', + default => dirname(__DIR__, 3).DIRECTORY_SEPARATOR.$path, }; } @@ -421,11 +404,11 @@ protected function fallbackPath(string $path): string protected function fallbackStoragePath() { $files = new Filesystem(); - $path = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'acorn'; - $files->ensureDirectoryExists($path . DIRECTORY_SEPARATOR . 'framework' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'data', 0755, true); - $files->ensureDirectoryExists($path . DIRECTORY_SEPARATOR . 'framework' . DIRECTORY_SEPARATOR . 'views', 0755, true); - $files->ensureDirectoryExists($path . DIRECTORY_SEPARATOR . 'framework' . DIRECTORY_SEPARATOR . 'sessions', 0755, true); - $files->ensureDirectoryExists($path . DIRECTORY_SEPARATOR . 'logs', 0755, true); + $path = WP_CONTENT_DIR.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.'acorn'; + $files->ensureDirectoryExists($path.DIRECTORY_SEPARATOR.'framework'.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.'data', 0755, true); + $files->ensureDirectoryExists($path.DIRECTORY_SEPARATOR.'framework'.DIRECTORY_SEPARATOR.'views', 0755, true); + $files->ensureDirectoryExists($path.DIRECTORY_SEPARATOR.'framework'.DIRECTORY_SEPARATOR.'sessions', 0755, true); + $files->ensureDirectoryExists($path.DIRECTORY_SEPARATOR.'logs', 0755, true); return $path; } diff --git a/src/Roots/Acorn/Bootstrap/HandleExceptions.php b/src/Roots/Acorn/Bootstrap/HandleExceptions.php index 23bf98ba..4cab9b7a 100644 --- a/src/Roots/Acorn/Bootstrap/HandleExceptions.php +++ b/src/Roots/Acorn/Bootstrap/HandleExceptions.php @@ -2,9 +2,9 @@ namespace Roots\Acorn\Bootstrap; -use Throwable; use Illuminate\Contracts\Foundation\Application; use Illuminate\Foundation\Bootstrap\HandleExceptions as FoundationHandleExceptionsBootstrapper; +use Throwable; use function apply_filters; @@ -22,7 +22,7 @@ public function bootstrap(Application $app) static::$app = $app; - if (!$this->isDebug() || $this->hasHandler()) { + if (! $this->isDebug() || $this->hasHandler()) { return; } @@ -73,14 +73,13 @@ protected function isDebug() */ protected function hasHandler() { - return !static::$app->runningInConsole() - && is_readable(WP_CONTENT_DIR . '/fatal-error-handler.php'); + return ! static::$app->runningInConsole() + && is_readable(WP_CONTENT_DIR.'/fatal-error-handler.php'); } /** * Render an exception as an HTTP response and send it. * - * @param \Throwable $e * @return void */ protected function renderHttpResponse(Throwable $e) diff --git a/src/Roots/Acorn/Bootstrap/LoadConfiguration.php b/src/Roots/Acorn/Bootstrap/LoadConfiguration.php index dc82060d..a85671db 100644 --- a/src/Roots/Acorn/Bootstrap/LoadConfiguration.php +++ b/src/Roots/Acorn/Bootstrap/LoadConfiguration.php @@ -12,7 +12,6 @@ class LoadConfiguration extends FoundationLoadConfiguration /** * Bootstrap the given application. * - * @param Application $app * @return void */ public function bootstrap(Application $app) @@ -50,8 +49,6 @@ public function bootstrap(Application $app) * * Fallback to internal app config. * - * @param \Illuminate\Contracts\Foundation\Application $app - * @param \Illuminate\Contracts\Config\Repository $repository * @return void */ protected function loadConfigurationFiles(Application $app, RepositoryContract $repository) @@ -59,7 +56,7 @@ protected function loadConfigurationFiles(Application $app, RepositoryContract $ $files = $this->getConfigurationFiles($app); if (! isset($files['app'])) { - $repository->set('app', require dirname(__DIR__, 4) . '/config/app.php'); + $repository->set('app', require dirname(__DIR__, 4).'/config/app.php'); } foreach ($files as $key => $path) { diff --git a/src/Roots/Acorn/Bootstrap/RegisterConsole.php b/src/Roots/Acorn/Bootstrap/RegisterConsole.php index 2975ca0a..e8c20141 100644 --- a/src/Roots/Acorn/Bootstrap/RegisterConsole.php +++ b/src/Roots/Acorn/Bootstrap/RegisterConsole.php @@ -2,11 +2,11 @@ namespace Roots\Acorn\Bootstrap; -use WP_CLI; use Illuminate\Contracts\Foundation\Application; use Roots\Acorn\Console\Kernel; use Symfony\Component\Console\Input\StringInput; use Symfony\Component\Console\Output\ConsoleOutput; +use WP_CLI; class RegisterConsole { @@ -20,7 +20,6 @@ class RegisterConsole /** * Bootstrap the given application. * - * @param \Illuminate\Contracts\Foundation\Application $app * @return void */ public function bootstrap(Application $app) @@ -56,8 +55,8 @@ public function bootstrap(Application $app) /** * Formats and escapes argument for StringInput. * - * @param string $key - * @param string $value + * @param string $key + * @param string $value * @return string */ protected function formatOption($key, $value) diff --git a/src/Roots/Acorn/Bootstrap/RegisterFacades.php b/src/Roots/Acorn/Bootstrap/RegisterFacades.php index 32e56ed0..ff780556 100644 --- a/src/Roots/Acorn/Bootstrap/RegisterFacades.php +++ b/src/Roots/Acorn/Bootstrap/RegisterFacades.php @@ -12,7 +12,6 @@ class RegisterFacades /** * Bootstrap the given application. * - * @param Application $app * @return void */ public function bootstrap(Application $app) diff --git a/src/Roots/Acorn/Console/Commands/AboutCommand.php b/src/Roots/Acorn/Console/Commands/AboutCommand.php index 277e2e96..804e45da 100644 --- a/src/Roots/Acorn/Console/Commands/AboutCommand.php +++ b/src/Roots/Acorn/Console/Commands/AboutCommand.php @@ -5,8 +5,8 @@ use Illuminate\Foundation\Application as FoundationApplication; use Illuminate\Foundation\Console\AboutCommand as BaseCommand; use Illuminate\Support\Str; -use Roots\Acorn\Application; use ReflectionFunction; +use Roots\Acorn\Application; class AboutCommand extends BaseCommand { @@ -52,6 +52,6 @@ protected function aboutEnvironment() protected function formatVersion($version) { - return $version ? ('v' . ltrim($version, 'vV')) : '-'; + return $version ? ('v'.ltrim($version, 'vV')) : '-'; } } diff --git a/src/Roots/Acorn/Console/Commands/AcornInitCommand.php b/src/Roots/Acorn/Console/Commands/AcornInitCommand.php index 24f7ea79..91b60ec7 100644 --- a/src/Roots/Acorn/Console/Commands/AcornInitCommand.php +++ b/src/Roots/Acorn/Console/Commands/AcornInitCommand.php @@ -13,7 +13,7 @@ class AcornInitCommand extends Command * * @var string */ - protected $signature = <<app->usePaths([$key => $path]); } - if (method_exists($this->app, $method = 'use' . ucfirst($key))) { + if (method_exists($this->app, $method = 'use'.ucfirst($key))) { $this->app->{$method}($path); } @@ -139,14 +138,14 @@ protected function initPath($key, $path) /** * Initialize the given path. * - * @param string $path + * @param string $path * @return bool */ protected function createPath($path) { $this->files->ensureDirectoryExists("{$this->base_path}/{$path}", 0755, true); - if ($this->files->isDirectory($from = __DIR__ . "/stubs/paths/{$path}")) { + if ($this->files->isDirectory($from = __DIR__."/stubs/paths/{$path}")) { return $this->files->copyDirectory($from, "{$this->base_path}/{$path}"); } diff --git a/src/Roots/Acorn/Console/Commands/ComposerMakeCommand.php b/src/Roots/Acorn/Console/Commands/ComposerMakeCommand.php index 713eadcb..81a875a4 100644 --- a/src/Roots/Acorn/Console/Commands/ComposerMakeCommand.php +++ b/src/Roots/Acorn/Console/Commands/ComposerMakeCommand.php @@ -19,6 +19,7 @@ class ComposerMakeCommand extends GeneratorCommand * @var string */ protected $description = 'Create a new view composer class'; + /** * The type of class being generated. * @@ -40,7 +41,7 @@ class ComposerMakeCommand extends GeneratorCommand */ protected function getStub() { - return __DIR__ . '/stubs/composer.stub'; + return __DIR__.'/stubs/composer.stub'; } /** @@ -51,7 +52,7 @@ protected function getStub() */ protected function getDefaultNamespace($rootNamespace) { - return $rootNamespace . '\View\Composers'; + return $rootNamespace.'\View\Composers'; } /** @@ -59,6 +60,7 @@ protected function getDefaultNamespace($rootNamespace) * * @param string $name * @return string + * * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ protected function buildClass($name) @@ -72,12 +74,13 @@ protected function buildClass($name) * Replace the class name for the given stub. * * @param string $stub - * @param array $views + * @param array $views * @return string */ protected function replaceViews($stub, $views) { $views = implode("',\n '", $views); + return str_replace('DummyViews', empty($views) ? '//' : "'{$views}'", $stub); } diff --git a/src/Roots/Acorn/Console/Commands/SummaryCommand.php b/src/Roots/Acorn/Console/Commands/SummaryCommand.php index 43466827..9dbf3bba 100644 --- a/src/Roots/Acorn/Console/Commands/SummaryCommand.php +++ b/src/Roots/Acorn/Console/Commands/SummaryCommand.php @@ -30,7 +30,7 @@ class SummaryCommand extends ListCommand */ protected $format = 'txt'; - /** + /** * The command name width. * * @var int @@ -39,8 +39,6 @@ class SummaryCommand extends ListCommand /** * Create a new Summary command instance. - * - * @param Container $app */ public function __construct(Container $app) { diff --git a/src/Roots/Acorn/Console/Commands/VendorPublishCommand.php b/src/Roots/Acorn/Console/Commands/VendorPublishCommand.php index d6da3b4d..d4f0dc2a 100644 --- a/src/Roots/Acorn/Console/Commands/VendorPublishCommand.php +++ b/src/Roots/Acorn/Console/Commands/VendorPublishCommand.php @@ -28,8 +28,8 @@ protected function publishItem($from, $to) /** * Call acorn:init if item cannot be published. * - * @param string $from - * @param string $to + * @param string $from + * @param string $to */ protected function callAcornInit($from, $to) { @@ -39,8 +39,8 @@ protected function callAcornInit($from, $to) $this->info("Cannot publish [{$from}] until Acorn is initialized."); - if (! $this->confirm("Would you like to initialize Acorn right now?", true)) { - throw new \Exception("Please run wp acorn acorn:init"); + if (! $this->confirm('Would you like to initialize Acorn right now?', true)) { + throw new \Exception('Please run wp acorn acorn:init'); } $this->call('acorn:init', ['--base' => $this->getLaravel()->basePath()]); diff --git a/src/Roots/Acorn/Console/Concerns/GetsFreshApplication.php b/src/Roots/Acorn/Console/Concerns/GetsFreshApplication.php index f30b7fa9..f829c5f3 100644 --- a/src/Roots/Acorn/Console/Concerns/GetsFreshApplication.php +++ b/src/Roots/Acorn/Console/Concerns/GetsFreshApplication.php @@ -40,7 +40,6 @@ protected function getFreshConfiguration() /** * Get all of the configured paths for the Application. * - * @param Application $app * @return array */ protected function getApplicationPaths(Application $app) diff --git a/src/Roots/Acorn/Console/Concerns/GracefullyCallsCommands.php b/src/Roots/Acorn/Console/Concerns/GracefullyCallsCommands.php index 183f021e..2ce786e9 100644 --- a/src/Roots/Acorn/Console/Concerns/GracefullyCallsCommands.php +++ b/src/Roots/Acorn/Console/Concerns/GracefullyCallsCommands.php @@ -27,8 +27,6 @@ abstract protected function resolveCommand($command); * Run the given the console command. * * @param \Symfony\Component\Console\Command\Command|string $command - * @param array $arguments - * @param \Symfony\Component\Console\Output\OutputInterface $output * @return int */ abstract protected function runCommand($command, array $arguments, OutputInterface $output); @@ -39,7 +37,6 @@ abstract protected function runCommand($command, array $arguments, OutputInterfa * Silently fail if command does not exist. * * @param \Symfony\Component\Console\Command\Command|string $command - * @param array $arguments * @return int */ public function gracefulCall($command, array $arguments = []) @@ -57,7 +54,6 @@ public function gracefulCall($command, array $arguments = []) * Silently fail if command does not exist. * * @param \Symfony\Component\Console\Command\Command|string $command - * @param array $arguments * @return int */ public function gracefulCallSilent($command, array $arguments = []) @@ -72,7 +68,7 @@ public function gracefulCallSilent($command, array $arguments = []) /** * Check whether a command exists. * - * @param \Symfony\Component\Console\Command\Command|string $command + * @param \Symfony\Component\Console\Command\Command|string $command * @return bool */ protected function commandExists($command) @@ -81,6 +77,7 @@ protected function commandExists($command) $this->resolveCommand($command); } catch (CommandNotFoundException $e) { $this->getLaravel()->make('log')->debug("Command [{$command}] not found. Skipping."); + return false; } diff --git a/src/Roots/Acorn/Console/Console.php b/src/Roots/Acorn/Console/Console.php index 63234e5e..7f581b2f 100644 --- a/src/Roots/Acorn/Console/Console.php +++ b/src/Roots/Acorn/Console/Console.php @@ -8,8 +8,6 @@ class Console extends Composer { /** * Execute acorn clear-compiled command. - * - * @return int */ public function clearCompiled(): int { @@ -18,8 +16,6 @@ public function clearCompiled(): int /** * Execute acorn config:cache command. - * - * @return int */ public function configCache(): int { @@ -28,8 +24,6 @@ public function configCache(): int /** * Execute acorn config:clear command. - * - * @return int */ public function configClear(): int { @@ -38,8 +32,6 @@ public function configClear(): int /** * Execute acorn optimize command. - * - * @return int */ public function optimize(): int { @@ -48,8 +40,6 @@ public function optimize(): int /** * Execute acorn optimize:clear command. - * - * @return int */ public function optimizeClear(): int { @@ -58,8 +48,6 @@ public function optimizeClear(): int /** * Execute acorn package:discover command. - * - * @return int */ public function packageDiscover(): int { @@ -68,8 +56,6 @@ public function packageDiscover(): int /** * Execute acorn vendor:public command. - * - * @return int */ public function vendorPublish(): int { @@ -78,8 +64,6 @@ public function vendorPublish(): int /** * Execute acorn view:cache command. - * - * @return int */ public function viewCache(): int { @@ -88,8 +72,6 @@ public function viewCache(): int /** * Execute acorn view:clear command. - * - * @return int */ public function viewClear(): int { @@ -100,7 +82,6 @@ public function viewClear(): int * Execute acorn command. * * @param array $command - * @return int */ public function acorn($command): int { @@ -116,7 +97,7 @@ public function acorn($command): int */ protected function findWpCli() { - if ($this->files->exists($this->workingPath . '/wp-cli.phar')) { + if ($this->files->exists($this->workingPath.'/wp-cli.phar')) { return [$this->phpBinary(), 'wp-cli.phar']; } diff --git a/src/Roots/Acorn/Console/Kernel.php b/src/Roots/Acorn/Console/Kernel.php index d92b09d3..56ca1af0 100644 --- a/src/Roots/Acorn/Console/Kernel.php +++ b/src/Roots/Acorn/Console/Kernel.php @@ -58,14 +58,12 @@ class Kernel extends FoundationConsoleKernel /** * Create a new console kernel instance. * - * @param \Illuminate\Contracts\Foundation\Application $app - * @param \Illuminate\Contracts\Events\Dispatcher $events * @return void */ public function __construct(Application $app, Dispatcher $events) { if (! defined('ARTISAN_BINARY')) { - define('ARTISAN_BINARY', dirname(__DIR__, 4) . '/bin/acorn'); + define('ARTISAN_BINARY', dirname(__DIR__, 4).'/bin/acorn'); } $this->app = $app; diff --git a/src/Roots/Acorn/DefaultProviders.php b/src/Roots/Acorn/DefaultProviders.php index d9d001c6..b80055aa 100644 --- a/src/Roots/Acorn/DefaultProviders.php +++ b/src/Roots/Acorn/DefaultProviders.php @@ -25,7 +25,7 @@ class DefaultProviders extends DefaultProvidersBase * * @return void */ - public function __construct(?array $providers = null) + public function __construct(array $providers = null) { parent::__construct($providers); diff --git a/src/Roots/Acorn/Exceptions/Handler.php b/src/Roots/Acorn/Exceptions/Handler.php index 7dbb62f5..d8c15d08 100644 --- a/src/Roots/Acorn/Exceptions/Handler.php +++ b/src/Roots/Acorn/Exceptions/Handler.php @@ -2,9 +2,9 @@ namespace Roots\Acorn\Exceptions; -use Throwable; use Illuminate\Contracts\Support\Responsable; use Illuminate\Foundation\Exceptions\Handler as FoundationHandler; +use Throwable; class Handler extends FoundationHandler { @@ -12,7 +12,6 @@ class Handler extends FoundationHandler * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request - * @param \Throwable $e * @return \Symfony\Component\HttpFoundation\Response * * @throws \Throwable diff --git a/src/Roots/Acorn/Exceptions/SkipProviderException.php b/src/Roots/Acorn/Exceptions/SkipProviderException.php index 181dcf98..55cec059 100644 --- a/src/Roots/Acorn/Exceptions/SkipProviderException.php +++ b/src/Roots/Acorn/Exceptions/SkipProviderException.php @@ -10,19 +10,15 @@ class SkipProviderException extends InvalidArgumentException /** * Create a new exception. * - * @param string $message - * @param int $code - * @param Throwable $previous * @return void */ - public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null, string $package = '') + public function __construct(string $message = '', int $code = 0, Throwable $previous = null, string $package = '') { parent::__construct($message, $code, $previous); $this->package = $package; } - /** * Name of the provider's package. * @@ -33,7 +29,6 @@ public function __construct(string $message = "", int $code = 0, ?Throwable $pre /** * Set the name of the provider's package. * - * @param string $package * @return void */ public function setPackage(string $package) @@ -59,7 +54,7 @@ public function package() public function context() { return [ - 'package' => $this->package() + 'package' => $this->package(), ]; } } diff --git a/src/Roots/Acorn/Exceptions/Whoops/WhoopsHandler.php b/src/Roots/Acorn/Exceptions/Whoops/WhoopsHandler.php index 79a1d247..4d789d9e 100644 --- a/src/Roots/Acorn/Exceptions/Whoops/WhoopsHandler.php +++ b/src/Roots/Acorn/Exceptions/Whoops/WhoopsHandler.php @@ -58,7 +58,7 @@ protected function registerWordPressData($handler) ->addDataTableCallback('WordPress Data', function () { global $wp; - if (!$wp instanceof WP) { + if (! $wp instanceof WP) { return []; } @@ -71,7 +71,7 @@ protected function registerWordPressData($handler) ->addDataTableCallback(sprintf('%s Data', WP_Query::class), function () { global $wp_query; - if (!$wp_query instanceof WP_Query) { + if (! $wp_query instanceof WP_Query) { return []; } @@ -84,7 +84,7 @@ protected function registerWordPressData($handler) ->addDataTableCallback(sprintf('%s Data', WP_Post::class), function () { $post = get_post(); - if (!$post instanceof WP_Post) { + if (! $post instanceof WP_Post) { return []; } @@ -104,7 +104,7 @@ protected function registerBlacklist($handler) { $blacklist = [ '_ENV' => $this->secrets, - '_SERVER' => $this->secrets + '_SERVER' => $this->secrets, ]; foreach ($blacklist as $key => $secrets) { diff --git a/src/Roots/Acorn/Filesystem/Filesystem.php b/src/Roots/Acorn/Filesystem/Filesystem.php index e641f4ea..b2ebf04c 100644 --- a/src/Roots/Acorn/Filesystem/Filesystem.php +++ b/src/Roots/Acorn/Filesystem/Filesystem.php @@ -10,7 +10,7 @@ class Filesystem extends FilesystemBase * Normalizes file path separators * * @param mixed $path - * @param string $separator + * @param string $separator * @return mixed */ public function normalizePath($path, $separator = '/') @@ -21,8 +21,8 @@ public function normalizePath($path, $separator = '/') /** * Find the closest file up the directory tree. * - * @param string $path - * @param string $file + * @param string $path + * @param string $file * @return string|null */ public function closest($path, $file) @@ -30,7 +30,7 @@ public function closest($path, $file) $current_directory = $path; while ($this->isReadable($current_directory)) { - if ($this->isFile($file_path = $current_directory . DIRECTORY_SEPARATOR . $file)) { + if ($this->isFile($file_path = $current_directory.DIRECTORY_SEPARATOR.$file)) { return $file_path; } @@ -49,12 +49,13 @@ public function closest($path, $file) /** * Get relative path of target from specified base * - * @param string $basePath - * @param string $targetPath + * @param string $basePath + * @param string $targetPath * @return string * * @copyright Fabien Potencier * @license MIT + * * @link https://github.com/symfony/routing/blob/v4.1.1/Generator/UrlGenerator.php#L280-L329 */ public function getRelativePath($basePath, $targetPath) @@ -80,7 +81,7 @@ public function getRelativePath($basePath, $targetPath) } $targetDirs[] = $targetFile; - $path = str_repeat('../', count($sourceDirs)) . implode('/', $targetDirs); + $path = str_repeat('../', count($sourceDirs)).implode('/', $targetDirs); return $path === '' || $path[0] === '/' || ($colonPos = strpos($path, ':')) !== false && ($colonPos < ($slashPos = strpos($path, '/')) diff --git a/src/Roots/Acorn/Kernel.php b/src/Roots/Acorn/Kernel.php index cfa6e481..dbf9a4d2 100644 --- a/src/Roots/Acorn/Kernel.php +++ b/src/Roots/Acorn/Kernel.php @@ -31,7 +31,6 @@ class Kernel implements KernelContract /** * Create a new Acorn kernel instance. * - * @param \Illuminate\Contracts\Foundation\Application $app * @return void */ public function __construct(Application $app) @@ -101,7 +100,6 @@ public function getApplication() /** * Set the Laravel application instance. * - * @param \Illuminate\Contracts\Foundation\Application $app * @return $this */ public function setApplication(Application $app) diff --git a/src/Roots/Acorn/PackageManifest.php b/src/Roots/Acorn/PackageManifest.php index c243cca4..ec36a296 100644 --- a/src/Roots/Acorn/PackageManifest.php +++ b/src/Roots/Acorn/PackageManifest.php @@ -19,7 +19,6 @@ class PackageManifest extends FoundationPackageManifest /** * Create a new package manifest instance. * - * @param \Illuminate\Filesystem\Filesystem $files * @param string[] $composerPaths * @param string $manifestPath * @return void @@ -34,8 +33,9 @@ public function __construct(Filesystem $files, array $composerPaths, $manifestPa /** * Get a package name based on its provider * - * @param string $provider_name + * @param string $provider_name * @return string + * * @throws FileNotFoundException * @throws Exception */ @@ -78,8 +78,7 @@ public function build() return collect($packages)->mapWithKeys(function ($package) use ($path, $composerPath) { return [ - $this->format($package['name'] ?? basename($composerPath), dirname($path, 2)) => - $package['extra']['acorn'] ?? $package['extra']['laravel'] ?? [] + $this->format($package['name'] ?? basename($composerPath), dirname($path, 2)) => $package['extra']['acorn'] ?? $package['extra']['laravel'] ?? [], ]; })->each(function ($configuration) use (&$ignore) { $ignore = array_merge($ignore, $configuration['dont-discover'] ?? []); @@ -100,7 +99,7 @@ public function build() */ protected function format($package, $vendorPath = null) { - return str_replace($vendorPath . '/', '', $package); + return str_replace($vendorPath.'/', '', $package); } /** diff --git a/src/Roots/Acorn/Providers/AcornServiceProvider.php b/src/Roots/Acorn/Providers/AcornServiceProvider.php index 5b194c18..4eef4466 100644 --- a/src/Roots/Acorn/Providers/AcornServiceProvider.php +++ b/src/Roots/Acorn/Providers/AcornServiceProvider.php @@ -70,7 +70,7 @@ protected function registerConfigs() $configs = array_merge($this->configs, array_values($this->providerConfigs)); foreach ($configs as $config) { - $this->mergeConfigFrom(dirname(__DIR__, 4) . "/config/{$config}.php", $config); + $this->mergeConfigFrom(dirname(__DIR__, 4)."/config/{$config}.php", $config); } } @@ -93,7 +93,7 @@ protected function publishConfigs() { foreach ($this->filterPublishableConfigs() as $config) { $this->publishes([ - dirname(__DIR__, 4) . "/config/{$config}.php" => config_path("{$config}.php") + dirname(__DIR__, 4)."/config/{$config}.php" => config_path("{$config}.php"), ], ['acorn', 'acorn-configs']); } } @@ -130,7 +130,7 @@ protected function registerPostInitEvent() $files = new Filesystem(); - $files->deleteDirectory(WP_CONTENT_DIR . '/cache/acorn'); + $files->deleteDirectory(WP_CONTENT_DIR.'/cache/acorn'); }); } } diff --git a/src/Roots/Acorn/Sage/Concerns/FiltersBodyClass.php b/src/Roots/Acorn/Sage/Concerns/FiltersBodyClass.php index 8694a235..212bc4c3 100644 --- a/src/Roots/Acorn/Sage/Concerns/FiltersBodyClass.php +++ b/src/Roots/Acorn/Sage/Concerns/FiltersBodyClass.php @@ -9,7 +9,7 @@ trait FiltersBodyClass * * Filter: body_class * - * @param array $classes + * @param array $classes * @return array */ public function filterBodyClass($classes) @@ -25,7 +25,7 @@ public function filterBodyClass($classes) return $classes->map(function ($class) { return preg_replace(['/-blade(-php)?$/', '/^page-template-views/'], '', $class); }) - ->filter() - ->all(); + ->filter() + ->all(); } } diff --git a/src/Roots/Acorn/Sage/Concerns/FiltersEnqueues.php b/src/Roots/Acorn/Sage/Concerns/FiltersEnqueues.php index aed55994..7d140f88 100644 --- a/src/Roots/Acorn/Sage/Concerns/FiltersEnqueues.php +++ b/src/Roots/Acorn/Sage/Concerns/FiltersEnqueues.php @@ -9,9 +9,9 @@ trait FiltersEnqueues * * Filter: script_loader_tag * - * @param string $tag - * @param string $handle - * @param string $src + * @param string $tag + * @param string $handle + * @param string $src * @return string */ public function filterScriptLoaderTag($tag, $handle, $src) diff --git a/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php b/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php index 10f4e8ec..d94410e4 100644 --- a/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php +++ b/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php @@ -9,7 +9,7 @@ trait FiltersTemplates * * Filter: {type}_template_hierarchy * - * @param array $files + * @param array $files * @return string[] List of possible views */ public function filterTemplateHierarchy($files) @@ -40,7 +40,7 @@ public function filterTemplateInclude($file) $this->app['sage.view'] = $this->view->exists($view) ? $view : $file; $this->app['sage.data'] = $data; - return get_template_directory() . '/index.php'; + return get_template_directory().'/index.php'; } /** @@ -68,8 +68,8 @@ public function filterThemeTemplates($_templates, $_theme, $_post, $post_type) * @see \WP_Theme::get_post_templates() * @link https://github.com/WordPress/WordPress/blob/5.8.1/wp-includes/class-wp-theme.php#L1203-L1221 * - * @param string $post_type - * @param string $text_domain + * @param string $post_type + * @param string $text_domain * @return string[] */ protected function getTemplates($post_type = '', $text_domain = '') diff --git a/src/Roots/Acorn/Sage/Concerns/FiltersThePost.php b/src/Roots/Acorn/Sage/Concerns/FiltersThePost.php index 45ca26c2..8bf295d4 100644 --- a/src/Roots/Acorn/Sage/Concerns/FiltersThePost.php +++ b/src/Roots/Acorn/Sage/Concerns/FiltersThePost.php @@ -11,7 +11,7 @@ trait FiltersThePost * * Filter: the_post * - * @param WP_Post $post + * @param WP_Post $post * @return void */ public function filterThePost($post) diff --git a/src/Roots/Acorn/Sage/Concerns/FiltersViews.php b/src/Roots/Acorn/Sage/Concerns/FiltersViews.php index 60317120..43089b7a 100644 --- a/src/Roots/Acorn/Sage/Concerns/FiltersViews.php +++ b/src/Roots/Acorn/Sage/Concerns/FiltersViews.php @@ -11,7 +11,7 @@ trait FiltersViews * * Filter: comments_template * - * @param string $file + * @param string $file * @return string Path to comments template */ public function filterCommentsTemplate($file) diff --git a/src/Roots/Acorn/Sage/Sage.php b/src/Roots/Acorn/Sage/Sage.php index 99f982dd..9cd8a63a 100644 --- a/src/Roots/Acorn/Sage/Sage.php +++ b/src/Roots/Acorn/Sage/Sage.php @@ -6,16 +6,15 @@ use Illuminate\Contracts\View\Factory as ViewFactory; use Illuminate\Support\Str; use Roots\Acorn\Filesystem\Filesystem; -use Roots\Acorn\Sage\ViewFinder; use Roots\Acorn\View\FileViewFinder; class Sage { use Concerns\FiltersBodyClass; + use Concerns\FiltersEnqueues; use Concerns\FiltersTemplates; use Concerns\FiltersThePost; use Concerns\FiltersViews; - use Concerns\FiltersEnqueues; /** * The application implementation. @@ -47,19 +46,11 @@ class Sage /** * The Filesystem instance. - * - * @var Filesystem */ protected Filesystem $files; /** * Creates a new Sage instance. - * - * @param Filesystem $files - * @param ViewFinder $sageFinder - * @param FileViewFinder $fileFinder - * @param ViewFactory $view - * @param ContainerContract $app */ public function __construct( Filesystem $files, @@ -84,6 +75,6 @@ public function filter($filter) { return method_exists($this, $filter) ? [$this, $filter] : - [$this, 'filter' . Str::studly($filter)]; + [$this, 'filter'.Str::studly($filter)]; } } diff --git a/src/Roots/Acorn/Sage/SageServiceProvider.php b/src/Roots/Acorn/Sage/SageServiceProvider.php index c7b9c68a..4b4ce367 100644 --- a/src/Roots/Acorn/Sage/SageServiceProvider.php +++ b/src/Roots/Acorn/Sage/SageServiceProvider.php @@ -3,8 +3,6 @@ namespace Roots\Acorn\Sage; use Illuminate\Support\ServiceProvider; -use Roots\Acorn\Sage\Sage; -use Roots\Acorn\Sage\ViewFinder; use function Roots\add_filters; diff --git a/src/Roots/Acorn/Sage/ViewFinder.php b/src/Roots/Acorn/Sage/ViewFinder.php index 3709f53c..3ef12ea3 100644 --- a/src/Roots/Acorn/Sage/ViewFinder.php +++ b/src/Roots/Acorn/Sage/ViewFinder.php @@ -32,9 +32,7 @@ class ViewFinder /** * Create new ViewFinder instance. * - * @param FileViewFinder $finder - * @param Filesystem $files - * @param string $path + * @param string $path * @return void */ public function __construct(FileViewFinder $finder, Filesystem $files, $path = '') diff --git a/src/Roots/Acorn/View/Composer.php b/src/Roots/Acorn/View/Composer.php index dafb44dc..fab3cb97 100644 --- a/src/Roots/Acorn/View/Composer.php +++ b/src/Roots/Acorn/View/Composer.php @@ -2,8 +2,8 @@ namespace Roots\Acorn\View; -use Illuminate\Support\Str; use Illuminate\Support\Fluent; +use Illuminate\Support\Str; use Illuminate\View\View; abstract class Composer @@ -42,13 +42,13 @@ public static function views() $view = array_slice(explode('\\', static::class), 3); $view = array_map([Str::class, 'snake'], $view, array_fill(0, count($view), '-')); + return implode('/', $view); } /** * Compose the view before rendering. * - * @param View $view * @return void */ public function compose(View $view) diff --git a/src/Roots/Acorn/View/Composers/Concerns/AcfFields.php b/src/Roots/Acorn/View/Composers/Concerns/AcfFields.php index e33f349b..398615af 100644 --- a/src/Roots/Acorn/View/Composers/Concerns/AcfFields.php +++ b/src/Roots/Acorn/View/Composers/Concerns/AcfFields.php @@ -10,7 +10,7 @@ trait AcfFields /** * ACF data to be passed to the view before rendering. * - * @param int $post_id + * @param int $post_id * @return array */ protected function fields($post_id = null) @@ -19,6 +19,7 @@ protected function fields($post_id = null) ->mapWithKeys(function ($value, $key) { $value = is_array($value) ? new Fluent($value) : $value; $method = Str::camel($key); + return [$key => method_exists($this, $method) ? $this->{$method}($value) : $value]; })->all(); } diff --git a/src/Roots/Acorn/View/Composers/Concerns/Arrayable.php b/src/Roots/Acorn/View/Composers/Concerns/Arrayable.php index 2e6b8ef3..7366ef8a 100644 --- a/src/Roots/Acorn/View/Composers/Concerns/Arrayable.php +++ b/src/Roots/Acorn/View/Composers/Concerns/Arrayable.php @@ -35,6 +35,7 @@ public function toArray() }) ->mapWithKeys(function ($method) { $data = $this->{$method->name}(); + return [Str::snake($method->name) => is_array($data) ? new Fluent($data) : $data]; }) ->all(); diff --git a/src/Roots/Acorn/View/Composers/Concerns/Cacheable.php b/src/Roots/Acorn/View/Composers/Concerns/Cacheable.php index 7e3d87b7..9153315a 100644 --- a/src/Roots/Acorn/View/Composers/Concerns/Cacheable.php +++ b/src/Roots/Acorn/View/Composers/Concerns/Cacheable.php @@ -49,7 +49,7 @@ public function cache() static $cache; $arguments = func_get_args(); - $tags = $this->cache_tags ?? [static::class, 'post-' . get_the_ID(), get_post_type()]; + $tags = $this->cache_tags ?? [static::class, 'post-'.get_the_ID(), get_post_type()]; if (! $cache) { try { @@ -94,12 +94,12 @@ public function cache() /** * Forget cache data * - * @param string $key + * @param string $key * @return void */ protected function forget($key = null) { - return $this->cache()->forget($key ?? static::class . get_the_ID()); + return $this->cache()->forget($key ?? static::class.get_the_ID()); } /** @@ -121,7 +121,7 @@ protected function flush() */ protected function merge() { - $key = $this->cache_key ?? hash('crc32b', static::class . serialize( + $key = $this->cache_key ?? hash('crc32b', static::class.serialize( get_queried_object() ?? collect($_SERVER)->only('HTTP_HOST', 'REQUEST_URI', 'QUERY_STRING', 'WP_HOME')->toArray() )); diff --git a/src/Roots/Acorn/View/Composers/Debugger.php b/src/Roots/Acorn/View/Composers/Debugger.php index 6f1bdf55..c23b7afd 100644 --- a/src/Roots/Acorn/View/Composers/Debugger.php +++ b/src/Roots/Acorn/View/Composers/Debugger.php @@ -9,8 +9,6 @@ class Debugger { /** * Create a new Debugger instance. - * - * @param Application $app */ public function __construct(Application $app) { @@ -20,7 +18,7 @@ public function __construct(Application $app) /** * Compose the view before rendering. * - * @param View $view + * @param View $view * @return void */ public function compose($view) @@ -29,6 +27,7 @@ public function compose($view) if ($this->debugLevel === 'view') { dump($name); + return; } @@ -42,6 +41,7 @@ public function compose($view) if ($this->debugLevel === 'data') { dump($data); + return; } diff --git a/src/Roots/Acorn/View/FileViewFinder.php b/src/Roots/Acorn/View/FileViewFinder.php index 770902c6..6147a5f4 100644 --- a/src/Roots/Acorn/View/FileViewFinder.php +++ b/src/Roots/Acorn/View/FileViewFinder.php @@ -9,19 +9,20 @@ class FileViewFinder extends FileViewFinderBase /** * Get possible relative locations of view files * - * @param string $path Absolute or relative path to possible view file + * @param string $path Absolute or relative path to possible view file * @return string[] */ public function getPossibleViewFilesFromPath($path) { $path = $this->getPossibleViewNameFromPath($path); + return $this->getPossibleViewFiles($path); } /** * Get possible view name based on path * - * @param string $path Absolute or relative path to possible view file + * @param string $path Absolute or relative path to possible view file * @return string */ public function getPossibleViewNameFromPath($file) @@ -55,7 +56,7 @@ public function getPossibleViewNameFromPath($file) /** * Remove recognized extensions from path * - * @param string $file relative path to view file + * @param string $file relative path to view file * @return string view name */ protected function stripExtensions($path) @@ -68,8 +69,8 @@ protected function stripExtensions($path) /** * Normalize paths * - * @param string|string[] $path - * @param string $separator + * @param string|string[] $path + * @param string $separator * @return string|string[] */ protected function normalizePath($path, $separator = '/') diff --git a/src/Roots/Acorn/View/ViewServiceProvider.php b/src/Roots/Acorn/View/ViewServiceProvider.php index 8a53f7b4..303e2c59 100644 --- a/src/Roots/Acorn/View/ViewServiceProvider.php +++ b/src/Roots/Acorn/View/ViewServiceProvider.php @@ -2,13 +2,13 @@ namespace Roots\Acorn\View; -use ReflectionClass; use Illuminate\Contracts\View\Engine; use Illuminate\Support\Arr; use Illuminate\Support\Str; use Illuminate\View\Engines\CompilerEngine; use Illuminate\View\View; use Illuminate\View\ViewServiceProvider as ViewServiceProviderBase; +use ReflectionClass; use Roots\Acorn\View\Composers\Debugger; use Symfony\Component\Finder\Finder; @@ -114,7 +114,7 @@ public function registerMacros() $compiled_extension = $app['config']->get('view.compiled_extension', 'php'); $content = "render(); ?>" - . "\n"; + ."\n"; if (! file_exists($loader = "{$compiled_path}/{$id}-loader.{$compiled_extension}")) { file_put_contents($loader, $content); @@ -184,10 +184,10 @@ public function attachComposers() // TODO: This should be cacheable, perhaps via `wp acorn` command foreach ((new Finder())->in($path)->files() as $composer) { - $composer = $namespace . str_replace( + $composer = $namespace.str_replace( ['/', '.php'], ['\\', ''], - Str::after($composer->getPathname(), $this->app->path() . DIRECTORY_SEPARATOR) + Str::after($composer->getPathname(), $this->app->path().DIRECTORY_SEPARATOR) ); if ( diff --git a/src/Roots/helpers.php b/src/Roots/helpers.php index d04b3bb0..04978a59 100644 --- a/src/Roots/helpers.php +++ b/src/Roots/helpers.php @@ -3,19 +3,15 @@ namespace Roots; use Illuminate\Contracts\Foundation\Application; +use Illuminate\Contracts\View\Factory as ViewFactory; use Roots\Acorn\Assets\Bundle; use Roots\Acorn\Assets\Contracts\Asset; -use Illuminate\Contracts\View\Factory as ViewFactory; use Roots\Acorn\Bootloader; /** * Get asset from manifest - * - * @param string $asset - * @param string $manifest - * @return Asset */ -function asset(string $asset, ?string $manifest = null): Asset +function asset(string $asset, string $manifest = null): Asset { if (! $manifest) { return \app('assets.manifest')->asset($asset); @@ -26,12 +22,8 @@ function asset(string $asset, ?string $manifest = null): Asset /** * Get bundle from manifest - * - * @param string $bundle - * @param string $manifest - * @return Bundle */ -function bundle(string $bundle, ?string $manifest = null): Bundle +function bundle(string $bundle, string $manifest = null): Bundle { if (! $manifest) { return \app('assets.manifest')->bundle($bundle); @@ -42,11 +34,8 @@ function bundle(string $bundle, ?string $manifest = null): Bundle /** * Instantiate the bootloader. - * - * @param Application $app - * @return Bootloader */ -function bootloader(?Application $app = null): Bootloader +function bootloader(Application $app = null): Bootloader { $bootloader = Bootloader::getInstance($app); @@ -84,6 +73,7 @@ function bootloader(?Application $app = null): Bootloader * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory * * @copyright Taylor Otwell + * * @link https://github.com/laravel/framework/blob/8.x/src/Illuminate/Foundation/helpers.php */ function view($view = null, $data = [], $mergeData = []) @@ -99,7 +89,6 @@ function view($view = null, $data = [], $mergeData = []) : $factory->file($view, $data, $mergeData); } - /** * @deprecated */ diff --git a/src/_ide-helpers.php b/src/_ide-helpers.php index 7a0382b4..2bf68478 100644 --- a/src/_ide-helpers.php +++ b/src/_ide-helpers.php @@ -6,6 +6,7 @@ /** * @method string getCompiled() Get the compiled path of the view * @method string makeLoader() Creates a loader for the view to be called later + * * @codeCoverageIgnore */ class View diff --git a/tests/Application/ApplicationTest.php b/tests/Application/ApplicationTest.php index eaa2be57..00d173ff 100644 --- a/tests/Application/ApplicationTest.php +++ b/tests/Application/ApplicationTest.php @@ -159,7 +159,8 @@ // the core of this test is to make sure that when a class or function is called that // does not exist, things don't blow up. - $provider = new class($app) extends BootableServiceProvider { + $provider = new class($app) extends BootableServiceProvider + { public function boot() { new \kjo(); diff --git a/tests/Assets/AssetsHelpersTest.php b/tests/Assets/AssetsHelpersTest.php index 28dc4193..bf85bba7 100644 --- a/tests/Assets/AssetsHelpersTest.php +++ b/tests/Assets/AssetsHelpersTest.php @@ -1,11 +1,10 @@ $this->fixture('bud_multi_compiler/public/editor/manifest.json'), 'bundles' => $this->fixture('bud_multi_compiler/public/editor/entrypoints.json'), ], - ] - ] + ], + ], ])); $app->register(\Roots\Acorn\Assets\AssetsServiceProvider::class); @@ -53,8 +52,8 @@ 'assets' => $this->fixture('bud_multi_compiler/public/editor/manifest.json'), 'bundles' => $this->fixture('bud_multi_compiler/public/editor/entrypoints.json'), ], - ] - ] + ], + ], ])); $app->register(\Roots\Acorn\Assets\AssetsServiceProvider::class); @@ -79,8 +78,8 @@ 'assets' => $this->fixture('bud_multi_compiler/public/editor/manifest.json'), 'bundles' => $this->fixture('bud_multi_compiler/public/editor/entrypoints.json'), ], - ] - ] + ], + ], ])); $app->register(\Roots\Acorn\Assets\AssetsServiceProvider::class); @@ -105,8 +104,8 @@ 'assets' => $this->fixture('bud_multi_compiler/public/editor/manifest.json'), 'bundles' => $this->fixture('bud_multi_compiler/public/editor/entrypoints.json'), ], - ] - ] + ], + ], ])); $app->register(\Roots\Acorn\Assets\AssetsServiceProvider::class); diff --git a/tests/Assets/AssetsServiceProviderTest.php b/tests/Assets/AssetsServiceProviderTest.php index 79726485..12292ca1 100644 --- a/tests/Assets/AssetsServiceProviderTest.php +++ b/tests/Assets/AssetsServiceProviderTest.php @@ -28,8 +28,8 @@ 'assets' => $this->fixture('bud_multi_compiler/public/app/manifest.json'), 'bundles' => $this->fixture('bud_multi_compiler/public/app/entrypoints.json'), ], - ] - ] + ], + ], ])); $app->register(\Roots\Acorn\Assets\AssetsServiceProvider::class); diff --git a/tests/Assets/BudCompatibilityTest.php b/tests/Assets/BudCompatibilityTest.php index c47dfba0..30704ed5 100644 --- a/tests/Assets/BudCompatibilityTest.php +++ b/tests/Assets/BudCompatibilityTest.php @@ -1,12 +1,8 @@ Bundle::resetInlinedSources()); diff --git a/tests/Assets/BundleTest.php b/tests/Assets/BundleTest.php index 1a781d45..242e98ee 100644 --- a/tests/Assets/BundleTest.php +++ b/tests/Assets/BundleTest.php @@ -26,12 +26,10 @@ $manifest = json_decode(file_get_contents($this->fixture('bud_single_runtime/public/entrypoints.json')), JSON_OBJECT_AS_ARRAY); $app = new Bundle('app', $manifest['app'], $this->fixture('bud_single_runtime'), 'https://k.jo'); - $app->js(fn ($handle, $src, $dependencies) => - assertMatchesSnapshot(compact('handle', 'src', 'dependencies')) + $app->js(fn ($handle, $src, $dependencies) => assertMatchesSnapshot(compact('handle', 'src', 'dependencies')) ); - $app->css(fn ($handle, $src) => - assertMatchesSnapshot(compact('handle', 'src')) + $app->css(fn ($handle, $src) => assertMatchesSnapshot(compact('handle', 'src')) ); }); diff --git a/tests/Assets/ManagerTest.php b/tests/Assets/ManagerTest.php index 332bb10f..ec2a9fcc 100644 --- a/tests/Assets/ManagerTest.php +++ b/tests/Assets/ManagerTest.php @@ -40,9 +40,9 @@ 'theme' => [ 'path' => $this->fixture('bud_single_runtime'), 'url' => 'https://k.jo', - 'assets' => __DIR__ . '/does/not/exist/manifest.json', - ] - ] + 'assets' => __DIR__.'/does/not/exist/manifest.json', + ], + ], ]); $assets->manifest('theme')->asset('app.css')->uri(); @@ -55,8 +55,8 @@ 'path' => $this->fixture('bud_single_runtime'), 'url' => 'https://k.jo', 'assets' => $this->fixture('bud_single_runtime/public/manifest.json'), - ] - ] + ], + ], ]); assertMatchesSnapshot($assets->manifest('theme')->asset('app.css')->uri()); @@ -78,7 +78,7 @@ 'assets' => $this->fixture('bud_multi_compiler/public/editor/manifest.json'), 'bundles' => $this->fixture('bud_multi_compiler/public/editor/entrypoints.json'), ], - ] + ], ]); assertMatchesSnapshot($assets->manifest('app')->asset('app.js')->uri()); @@ -91,9 +91,9 @@ 'theme' => [ 'path' => $this->fixture('bud_single_runtime'), 'url' => 'https://k.jo', - 'bundles' => __DIR__ . '/does/not/exist/entrypoints.json', - ] - ] + 'bundles' => __DIR__.'/does/not/exist/entrypoints.json', + ], + ], ]); $assets->manifest('theme')->bundle('app')->js()->toJson(); @@ -106,8 +106,8 @@ 'path' => $this->fixture('bud_single_runtime'), 'url' => 'https://k.jo', 'bundles' => $this->fixture('bud_single_runtime/public/entrypoints.json'), - ] - ] + ], + ], ]); assertMatchesSnapshot($assets->manifest('theme')->bundle('app')->js()->toJson()); @@ -122,8 +122,8 @@ 'path' => $this->fixture('mix_no_bundle/public'), 'url' => 'https://k.jo/public', 'assets' => $this->fixture('mix_no_bundle/public/mix-manifest.json'), - ] - ] + ], + ], ]); assertMatchesSnapshot($assets->manifest('theme')->asset('styles/app.css')->uri()); diff --git a/tests/Assets/__fixtures__/mix_no_bundle/public/scripts/manifest.asset.php b/tests/Assets/__fixtures__/mix_no_bundle/public/scripts/manifest.asset.php index 09a614e5..b38b43db 100644 --- a/tests/Assets/__fixtures__/mix_no_bundle/public/scripts/manifest.asset.php +++ b/tests/Assets/__fixtures__/mix_no_bundle/public/scripts/manifest.asset.php @@ -1 +1 @@ - array('wp-blocks', 'wp-dom-ready', 'wp-edit-post'), 'version' => 'e39511caf2eccc797793102b4a605369'); \ No newline at end of file + ['wp-blocks', 'wp-dom-ready', 'wp-edit-post'], 'version' => 'e39511caf2eccc797793102b4a605369']; diff --git a/tests/Assets/__fixtures__/mix_no_bundle_hmr/public/scripts/manifest.asset.php b/tests/Assets/__fixtures__/mix_no_bundle_hmr/public/scripts/manifest.asset.php index 7645a599..af6eed5b 100644 --- a/tests/Assets/__fixtures__/mix_no_bundle_hmr/public/scripts/manifest.asset.php +++ b/tests/Assets/__fixtures__/mix_no_bundle_hmr/public/scripts/manifest.asset.php @@ -1 +1 @@ - array('wp-blocks', 'wp-dom-ready', 'wp-edit-post'), 'version' => 'aafb3aa27c9e6dd03dc133edc8aedb79'); \ No newline at end of file + ['wp-blocks', 'wp-dom-ready', 'wp-edit-post'], 'version' => 'aafb3aa27c9e6dd03dc133edc8aedb79']; diff --git a/tests/Bootstrap/HandleExceptionsRegistrationTest.php b/tests/Bootstrap/HandleExceptionsRegistrationTest.php index 1190c07a..f5165c7e 100644 --- a/tests/Bootstrap/HandleExceptionsRegistrationTest.php +++ b/tests/Bootstrap/HandleExceptionsRegistrationTest.php @@ -9,7 +9,6 @@ uses(TestCase::class); - beforeAll(function () { if (! defined('WP_DEBUG')) { define('WP_DEBUG', true); diff --git a/tests/Exceptions/HandlerTest.php b/tests/Exceptions/HandlerTest.php index 257d557d..24d651b2 100644 --- a/tests/Exceptions/HandlerTest.php +++ b/tests/Exceptions/HandlerTest.php @@ -2,6 +2,4 @@ use Roots\Acorn\Tests\Test\TestCase; -use function Roots\Acorn\Tests\mock; - uses(TestCase::class); diff --git a/tests/Exceptions/WhoopsHandlerTest.php b/tests/Exceptions/WhoopsHandlerTest.php index 257d557d..24d651b2 100644 --- a/tests/Exceptions/WhoopsHandlerTest.php +++ b/tests/Exceptions/WhoopsHandlerTest.php @@ -2,6 +2,4 @@ use Roots\Acorn\Tests\Test\TestCase; -use function Roots\Acorn\Tests\mock; - uses(TestCase::class); diff --git a/tests/Helpers.php b/tests/Helpers.php index 9e2ad257..6ebb0962 100644 --- a/tests/Helpers.php +++ b/tests/Helpers.php @@ -6,23 +6,22 @@ use Mockery\MockInterface; use Spatie\TemporaryDirectory\TemporaryDirectory; -function acorn_root(?string $path = null) +function acorn_root(string $path = null) { - return dirname(__DIR__) . ($path ? "/{$path}" : ''); + return dirname(__DIR__).($path ? "/{$path}" : ''); } function plugin_entrypoint() { - return __DIR__ . '/../acorn.php'; + return __DIR__.'/../acorn.php'; } /** * Get a temporary directory * - * @param string|null $path * @return string|TemporaryDirectory */ -function temp(?string $path = null) +function temp(string $path = null) { static $temp; diff --git a/tests/Test/Concerns/SupportsGlobalStubs.php b/tests/Test/Concerns/SupportsGlobalStubs.php index 280c06a2..255a810c 100644 --- a/tests/Test/Concerns/SupportsGlobalStubs.php +++ b/tests/Test/Concerns/SupportsGlobalStubs.php @@ -11,15 +11,15 @@ trait SupportsGlobalStubs /** * Create stubs and spies for global functions. * - * @param string $fn The name of the global function - * @param null|callable $callable The real function to monitor + * @param string $fn The name of the global function + * @param null|callable $callable The real function to monitor */ - protected function stub(string $fn, ?callable $callable = null): MockeryCallableMock + protected function stub(string $fn, callable $callable = null): MockeryCallableMock { - $script = << fn ($path = null) => temp($path ?? 'stylesheet_directory'), 'get_template_directory' => fn ($path = null) => temp($path ?? 'template_directory'), 'get_theme_file_path' => fn ($path = null) => temp($path ?? 'theme_file_path'), - 'do_action' => fn (...$args) => !! $this->apply(...$args), + 'do_action' => fn (...$args) => (bool) $this->apply(...$args), 'doing_action', 'did_action', 'add_action' => fn (...$args) => $this->filter(...$args), diff --git a/tests/Test/Stubs/EmptyClass.php b/tests/Test/Stubs/EmptyClass.php index 88ce8c7a..c807564e 100644 --- a/tests/Test/Stubs/EmptyClass.php +++ b/tests/Test/Stubs/EmptyClass.php @@ -4,5 +4,5 @@ class EmptyClass { - + // } diff --git a/tests/Test/TestCase.php b/tests/Test/TestCase.php index 31ebccce..0063ebeb 100644 --- a/tests/Test/TestCase.php +++ b/tests/Test/TestCase.php @@ -10,8 +10,8 @@ class TestCase extends MockeryTestCase { use SupportsGlobalStubs; - use SupportsWordPressStubs; use SupportsScopedFixtures; + use SupportsWordPressStubs; protected function setUp(): void { diff --git a/tests/bootstrap.php b/tests/bootstrap.php index f58c0d40..80fa3f11 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,4 +1,4 @@ Date: Thu, 16 Nov 2023 15:20:41 -0600 Subject: [PATCH 28/48] =?UTF-8?q?=F0=9F=94=A7=20Exclude=20`tests/Assets/?= =?UTF-8?q?=5F=5Ffixtures=5F=5F`=20on=20Pint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pint.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pint.json b/pint.json index b3dd6e50..adc7a145 100644 --- a/pint.json +++ b/pint.json @@ -1,5 +1,6 @@ { "exclude": [ - "src/Illuminate" + "src/Illuminate", + "tests/Assets/__fixtures__" ] } From fcf323dbc592c7908b9e5ab3de8e7d32466f98f9 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 16 Nov 2023 15:20:57 -0600 Subject: [PATCH 29/48] =?UTF-8?q?=E2=8F=AA=20Revert=20linted=20fixtures?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mix_no_bundle/public/scripts/manifest.asset.php | 2 +- .../mix_no_bundle_hmr/public/scripts/manifest.asset.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Assets/__fixtures__/mix_no_bundle/public/scripts/manifest.asset.php b/tests/Assets/__fixtures__/mix_no_bundle/public/scripts/manifest.asset.php index b38b43db..09a614e5 100644 --- a/tests/Assets/__fixtures__/mix_no_bundle/public/scripts/manifest.asset.php +++ b/tests/Assets/__fixtures__/mix_no_bundle/public/scripts/manifest.asset.php @@ -1 +1 @@ - ['wp-blocks', 'wp-dom-ready', 'wp-edit-post'], 'version' => 'e39511caf2eccc797793102b4a605369']; + array('wp-blocks', 'wp-dom-ready', 'wp-edit-post'), 'version' => 'e39511caf2eccc797793102b4a605369'); \ No newline at end of file diff --git a/tests/Assets/__fixtures__/mix_no_bundle_hmr/public/scripts/manifest.asset.php b/tests/Assets/__fixtures__/mix_no_bundle_hmr/public/scripts/manifest.asset.php index af6eed5b..7645a599 100644 --- a/tests/Assets/__fixtures__/mix_no_bundle_hmr/public/scripts/manifest.asset.php +++ b/tests/Assets/__fixtures__/mix_no_bundle_hmr/public/scripts/manifest.asset.php @@ -1 +1 @@ - ['wp-blocks', 'wp-dom-ready', 'wp-edit-post'], 'version' => 'aafb3aa27c9e6dd03dc133edc8aedb79']; + array('wp-blocks', 'wp-dom-ready', 'wp-edit-post'), 'version' => 'aafb3aa27c9e6dd03dc133edc8aedb79'); \ No newline at end of file From cd560be1e70082f30956708df4fc2ad5eda61cde Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 16 Nov 2023 16:12:25 -0600 Subject: [PATCH 30/48] =?UTF-8?q?=F0=9F=8E=A8=20Use=20shorthanded=20functi?= =?UTF-8?q?ons=20where=20possible=20=F0=9F=8E=A8=20Various=20random=20code?= =?UTF-8?q?=20cleanup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Roots/Acorn/Application.php | 28 +++++-------- src/Roots/Acorn/Assets/Asset/TextAsset.php | 1 + src/Roots/Acorn/Bootloader.php | 8 +--- .../Acorn/Console/Commands/SummaryCommand.php | 40 +++++++++---------- src/Roots/Acorn/Filesystem/Filesystem.php | 14 ++++--- .../Filesystem/FilesystemServiceProvider.php | 4 +- src/Roots/Acorn/PackageManifest.php | 25 ++++++------ .../Acorn/Providers/AcornServiceProvider.php | 8 ++-- .../Acorn/Sage/Concerns/FiltersBodyClass.php | 7 +--- .../Acorn/Sage/Concerns/FiltersEnqueues.php | 2 - .../Acorn/Sage/Concerns/FiltersTemplates.php | 12 +++--- src/Roots/Acorn/Sage/ViewFinder.php | 19 +++------ .../View/Composers/Concerns/Arrayable.php | 13 +++--- src/Roots/Acorn/View/FileViewFinder.php | 16 +++++--- src/Roots/Acorn/View/ViewServiceProvider.php | 13 +++--- 15 files changed, 97 insertions(+), 113 deletions(-) diff --git a/src/Roots/Acorn/Application.php b/src/Roots/Acorn/Application.php index 70d2a24d..bdad862c 100644 --- a/src/Roots/Acorn/Application.php +++ b/src/Roots/Acorn/Application.php @@ -186,29 +186,23 @@ protected function registerPackageManifest() $this->singleton(FoundationPackageManifest::class, function () { $files = new Filesystem(); - $composer_paths = collect(get_option('active_plugins')) - ->map(function ($plugin) { - return WP_PLUGIN_DIR.DIRECTORY_SEPARATOR.dirname($plugin); - }) + $composerPaths = collect(get_option('active_plugins')) + ->map(fn ($plugin) => WP_PLUGIN_DIR.DIRECTORY_SEPARATOR.dirname($plugin)) ->merge([ $this->basePath(), dirname(WP_CONTENT_DIR, 2), get_template_directory(), get_stylesheet_directory(), ]) - ->map(function ($path) use ($files) { - return rtrim($files->normalizePath($path), '/'); - }) + ->map(fn ($path) => rtrim($files->normalizePath($path), '/')) ->unique() - ->filter(function ($path) use ($files) { - return @$files->isFile("{$path}/vendor/composer/installed.json") - && @$files->isFile("{$path}/composer.json"); - }) - ->all(); + ->filter(fn ($path) => @$files->isFile("{$path}/vendor/composer/installed.json") && + @$files->isFile("{$path}/composer.json") + )->all(); return new PackageManifest( $files, - $composer_paths, + $composerPaths, $this->getCachedPackagesPath() ); }); @@ -296,18 +290,18 @@ public function register($provider, $force = false) */ protected function skipProvider($provider, Throwable $e): ServiceProvider { - $provider_name = is_object($provider) ? get_class($provider) : $provider; + $providerName = is_object($provider) ? get_class($provider) : $provider; if (! $e instanceof SkipProviderException) { $message = [ - BindingResolutionException::class => "Skipping provider [{$provider_name}] because it requires a dependency that cannot be found.", - ][$error = get_class($e)] ?? "Skipping provider [{$provider_name}] because it encountered an error [{$error}]."; + BindingResolutionException::class => "Skipping provider [{$providerName}] because it requires a dependency that cannot be found.", + ][$error = get_class($e)] ?? "Skipping provider [{$providerName}] because it encountered an error [{$error}]."; $e = new SkipProviderException($message, 0, $e); } if (method_exists($packages = $this->make(PackageManifest::class), 'getPackage')) { - $e->setPackage($packages->getPackage($provider_name)); + $e->setPackage($packages->getPackage($providerName)); } report($e); diff --git a/src/Roots/Acorn/Assets/Asset/TextAsset.php b/src/Roots/Acorn/Assets/Asset/TextAsset.php index 9db6143f..ee8399c7 100644 --- a/src/Roots/Acorn/Assets/Asset/TextAsset.php +++ b/src/Roots/Acorn/Assets/Asset/TextAsset.php @@ -55,6 +55,7 @@ public function dataUrl(string $mediatype = null, string $charset = null, string } $percents = []; + foreach (preg_split('//u', $urlencode, -1, PREG_SPLIT_NO_EMPTY) as $char) { $percents[$char] = rawurlencode($char); } diff --git a/src/Roots/Acorn/Bootloader.php b/src/Roots/Acorn/Bootloader.php index 228e1731..34d8764a 100644 --- a/src/Roots/Acorn/Bootloader.php +++ b/src/Roots/Acorn/Bootloader.php @@ -372,13 +372,9 @@ protected function findPath($path): string ]; return collect($searchPaths) - ->map(function ($path) { - return (is_string($path) && is_dir($path)) ? $path : null; - }) + ->map(fn ($path) => (is_string($path) && is_dir($path)) ? $path : null) ->filter() - ->whenEmpty(function ($paths) use ($path) { - return $paths->add($this->fallbackPath($path)); - }) + ->whenEmpty(fn ($paths) => $paths->add($this->fallbackPath($path))) ->unique() ->first(); } diff --git a/src/Roots/Acorn/Console/Commands/SummaryCommand.php b/src/Roots/Acorn/Console/Commands/SummaryCommand.php index 9dbf3bba..2f8ec5e4 100644 --- a/src/Roots/Acorn/Console/Commands/SummaryCommand.php +++ b/src/Roots/Acorn/Console/Commands/SummaryCommand.php @@ -96,32 +96,30 @@ protected function commands(OutputInterface $output) { $this->width = 0; - $namespaces = collect($this->getApplication()->all())->filter(function ($command) { - return ! $command->isHidden(); - })->groupBy(function ($command) { - $nameParts = explode(':', $name = $command->getName()); + $namespaces = collect($this->getApplication()->all()) + ->filter(fn ($command) => ! $command->isHidden()) + ->groupBy(function ($command) { + $nameParts = explode(':', $name = $command->getName()); - $this->width = max($this->width, mb_strlen($name)); + $this->width = max($this->width, mb_strlen($name)); - return isset($nameParts[1]) ? $nameParts[0] : ''; - })->sortKeys()->each(function ($commands) use ($output) { - $output->write("\n"); + return isset($nameParts[1]) ? $nameParts[0] : ''; + })->sortKeys()->each(function ($commands) use ($output) { + $output->write("\n"); - $commands = $commands->toArray(); + $commands = $commands->toArray(); - usort($commands, function ($a, $b) { - return $a->getName() > $b->getName() ? 1 : -1; - }); + usort($commands, fn ($a, $b) => $a->getName() > $b->getName() ? 1 : -1); - foreach ($commands as $command) { - $output->write(sprintf( - " %s%s%s\n", - $command->getName(), - str_repeat(' ', $this->width - mb_strlen($command->getName()) + 1), - $command->getDescription() - )); - } - }); + foreach ($commands as $command) { + $output->write(sprintf( + " %s%s%s\n", + $command->getName(), + str_repeat(' ', $this->width - mb_strlen($command->getName()) + 1), + $command->getDescription() + )); + } + }); return $this; } diff --git a/src/Roots/Acorn/Filesystem/Filesystem.php b/src/Roots/Acorn/Filesystem/Filesystem.php index b2ebf04c..b5a722db 100644 --- a/src/Roots/Acorn/Filesystem/Filesystem.php +++ b/src/Roots/Acorn/Filesystem/Filesystem.php @@ -27,20 +27,20 @@ public function normalizePath($path, $separator = '/') */ public function closest($path, $file) { - $current_directory = $path; + $currentDirectory = $path; - while ($this->isReadable($current_directory)) { - if ($this->isFile($file_path = $current_directory.DIRECTORY_SEPARATOR.$file)) { + while ($this->isReadable($currentDirectory)) { + if ($this->isFile($file_path = $currentDirectory.DIRECTORY_SEPARATOR.$file)) { return $file_path; } - $parent_directory = $this->dirname($current_directory); + $parentDirectory = $this->dirname($currentDirectory); - if (empty($parent_directory) || $parent_directory === $current_directory) { + if (empty($parentDirectory) || $parentDirectory === $currentDirectory) { break; } - $current_directory = $parent_directory; + $currentDirectory = $parentDirectory; } return null; @@ -69,7 +69,9 @@ public function getRelativePath($basePath, $targetPath) $sourceDirs = explode('/', ltrim($basePath, '/')); $targetDirs = explode('/', ltrim($targetPath, '/')); + array_pop($sourceDirs); + $targetFile = array_pop($targetDirs); foreach ($sourceDirs as $i => $dir) { diff --git a/src/Roots/Acorn/Filesystem/FilesystemServiceProvider.php b/src/Roots/Acorn/Filesystem/FilesystemServiceProvider.php index a01c01b0..e5674d9c 100644 --- a/src/Roots/Acorn/Filesystem/FilesystemServiceProvider.php +++ b/src/Roots/Acorn/Filesystem/FilesystemServiceProvider.php @@ -13,9 +13,7 @@ class FilesystemServiceProvider extends FilesystemServiceProviderBase */ protected function registerNativeFilesystem() { - $this->app->singleton('files', function () { - return new Filesystem(); - }); + $this->app->singleton('files', fn () => new Filesystem()); $this->app->alias('files', \Roots\Acorn\Filesystem\Filesystem::class); } diff --git a/src/Roots/Acorn/PackageManifest.php b/src/Roots/Acorn/PackageManifest.php index ec36a296..0eebf55f 100644 --- a/src/Roots/Acorn/PackageManifest.php +++ b/src/Roots/Acorn/PackageManifest.php @@ -33,17 +33,17 @@ public function __construct(Filesystem $files, array $composerPaths, $manifestPa /** * Get a package name based on its provider * - * @param string $provider_name + * @param string $providerName * @return string * * @throws FileNotFoundException * @throws Exception */ - public function getPackage($provider_name) + public function getPackage($providerName) { foreach ($this->getManifest() as $package => $configuration) { foreach ($configuration['providers'] ?? [] as $provider) { - if ($provider !== $provider_name) { + if ($provider !== $providerName) { continue; } @@ -76,15 +76,16 @@ public function build() $ignoreAll = in_array('*', $ignore = $this->packagesToIgnore()); - return collect($packages)->mapWithKeys(function ($package) use ($path, $composerPath) { - return [ - $this->format($package['name'] ?? basename($composerPath), dirname($path, 2)) => $package['extra']['acorn'] ?? $package['extra']['laravel'] ?? [], - ]; - })->each(function ($configuration) use (&$ignore) { - $ignore = array_merge($ignore, $configuration['dont-discover'] ?? []); - })->reject(function ($configuration, $package) use ($ignore, $ignoreAll) { - return $ignoreAll || in_array($package, $ignore); - })->filter()->merge($all)->all(); + return collect($packages)->mapWithKeys(fn ($package) => [ + $this->format($package['name'] ?? basename($composerPath), dirname($path, 2)) => $package['extra']['acorn'] ?? $package['extra']['laravel'] ?? [], + ]) + ->each(function ($configuration) use (&$ignore) { + $ignore = array_merge($ignore, $configuration['dont-discover'] ?? []); + }) + ->reject(fn ($configuration, $package) => $ignoreAll || in_array($package, $ignore)) + ->filter() + ->merge($all) + ->all(); }, []); $this->write($packages); diff --git a/src/Roots/Acorn/Providers/AcornServiceProvider.php b/src/Roots/Acorn/Providers/AcornServiceProvider.php index 4eef4466..f44549c8 100644 --- a/src/Roots/Acorn/Providers/AcornServiceProvider.php +++ b/src/Roots/Acorn/Providers/AcornServiceProvider.php @@ -105,9 +105,11 @@ protected function publishConfigs() */ protected function filterPublishableConfigs() { - $configs = array_filter($this->providerConfigs, function ($provider) { - return class_exists($provider) && $this->app->getProviders($provider); - }, ARRAY_FILTER_USE_KEY); + $configs = array_filter( + $this->providerConfigs, + fn ($provider) => class_exists($provider) && $this->app->getProviders($provider), + ARRAY_FILTER_USE_KEY + ); return array_unique(array_merge($this->configs, array_values($configs))); } diff --git a/src/Roots/Acorn/Sage/Concerns/FiltersBodyClass.php b/src/Roots/Acorn/Sage/Concerns/FiltersBodyClass.php index 212bc4c3..ac162b46 100644 --- a/src/Roots/Acorn/Sage/Concerns/FiltersBodyClass.php +++ b/src/Roots/Acorn/Sage/Concerns/FiltersBodyClass.php @@ -22,10 +22,7 @@ public function filterBodyClass($classes) } } - return $classes->map(function ($class) { - return preg_replace(['/-blade(-php)?$/', '/^page-template-views/'], '', $class); - }) - ->filter() - ->all(); + return $classes->map(fn ($class) => preg_replace(['/-blade(-php)?$/', '/^page-template-views/'], '', $class) + )->filter()->all(); } } diff --git a/src/Roots/Acorn/Sage/Concerns/FiltersEnqueues.php b/src/Roots/Acorn/Sage/Concerns/FiltersEnqueues.php index 7d140f88..c546be56 100644 --- a/src/Roots/Acorn/Sage/Concerns/FiltersEnqueues.php +++ b/src/Roots/Acorn/Sage/Concerns/FiltersEnqueues.php @@ -24,10 +24,8 @@ public function filterScriptLoaderTag($tag, $handle, $src) return $tag; } - // remove current type if it's defined $tag = preg_replace('/type=["\'][^"\']+["\']/', '', $tag); - // now add module type return str_replace('