diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index 4148a6b7..cd91699f 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -45,7 +45,7 @@ class Application extends Container implements ApplicationContract, CachesConfig * * @var string */ - const VERSION = '11.34.2'; + const VERSION = '11.40.0'; /** * The base path for the Laravel installation. @@ -254,7 +254,10 @@ public static function inferBasePath() { return match (true) { isset($_ENV['APP_BASE_PATH']) => $_ENV['APP_BASE_PATH'], - default => dirname(array_keys(ClassLoader::getRegisteredLoaders())[0]), + default => dirname(array_values(array_filter( + array_keys(ClassLoader::getRegisteredLoaders()), + fn ($path) => ! str_contains($path, '/vendor/'), + ))[0]), }; } @@ -836,13 +839,13 @@ public function registered($callback) */ public function registerConfiguredProviders() { - $providers = Collection::make($this->make('config')->get('app.providers')) - ->partition(fn ($provider) => str_starts_with($provider, 'Illuminate\\')); + $providers = (new Collection($this->make('config')->get('app.providers'))) + ->partition(fn ($provider) => str_starts_with($provider, 'Illuminate\\')); $providers->splice(1, 0, [$this->make(PackageManifest::class)->providers()]); (new ProviderRepository($this, new Filesystem, $this->getCachedServicesPath())) - ->load($providers->collapse()->toArray()); + ->load($providers->collapse()->toArray()); $this->fireAppCallbacks($this->registeredCallbacks); } diff --git a/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php b/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php index d5dd1f27..8a887b19 100644 --- a/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php +++ b/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php @@ -57,7 +57,7 @@ public function bootstrap(Application $app) } if (laravel_cloud()) { - $this->configureCloudSocketLogChannel($app); + $this->configureCloudLogging($app); } } @@ -252,19 +252,28 @@ protected function fatalErrorFromPhpError(array $error, $traceOffset = null) } /** - * Configure the Laravel Cloud socket log channel. + * Configure the Laravel Cloud log channels. * * @param \Illuminate\Contracts\Foundation\Application $app * @return void */ - protected function configureCloudSocketLogChannel(Application $app) + protected function configureCloudLogging(Application $app) { + $app['config']->set('logging.channels.stderr.formatter_with', [ + 'includeStacktraces' => true, + ]); + $app['config']->set('logging.channels.laravel-cloud-socket', [ 'driver' => 'monolog', 'handler' => SocketHandler::class, 'formatter' => JsonFormatter::class, + 'formatter_with' => [ + 'includeStacktraces' => true, + ], 'with' => [ - 'connectionString' => $_ENV['LARAVEL_CLOUD_LOG_SOCKET'] ?? '127.0.0.1:8765', + 'connectionString' => $_ENV['LARAVEL_CLOUD_LOG_SOCKET'] ?? + $_SERVER['LARAVEL_CLOUD_LOG_SOCKET'] ?? + 'unix:///tmp/cloud-init.sock', 'persistent' => true, ], ]); diff --git a/src/Illuminate/Foundation/Bus/Dispatchable.php b/src/Illuminate/Foundation/Bus/Dispatchable.php index 46b50055..1fef9872 100644 --- a/src/Illuminate/Foundation/Bus/Dispatchable.php +++ b/src/Illuminate/Foundation/Bus/Dispatchable.php @@ -16,7 +16,7 @@ trait Dispatchable */ public static function dispatch(...$arguments) { - return new PendingDispatch(new static(...$arguments)); + return static::newPendingDispatch(new static(...$arguments)); } /** @@ -32,12 +32,12 @@ public static function dispatchIf($boolean, ...$arguments) $dispatchable = new static(...$arguments); return value($boolean, $dispatchable) - ? new PendingDispatch($dispatchable) + ? static::newPendingDispatch($dispatchable) : new Fluent; } return value($boolean) - ? new PendingDispatch(new static(...$arguments)) + ? static::newPendingDispatch(new static(...$arguments)) : new Fluent; } @@ -54,12 +54,12 @@ public static function dispatchUnless($boolean, ...$arguments) $dispatchable = new static(...$arguments); return ! value($boolean, $dispatchable) - ? new PendingDispatch($dispatchable) + ? static::newPendingDispatch($dispatchable) : new Fluent; } return ! value($boolean) - ? new PendingDispatch(new static(...$arguments)) + ? static::newPendingDispatch(new static(...$arguments)) : new Fluent; } @@ -97,4 +97,15 @@ public static function withChain($chain) { return new PendingChain(static::class, $chain); } + + /** + * Create a new pending job dispatch instance. + * + * @param mixed $job + * @return \Illuminate\Foundation\Bus\PendingDispatch + */ + protected static function newPendingDispatch($job) + { + return new PendingDispatch($job); + } } diff --git a/src/Illuminate/Foundation/Bus/PendingDispatch.php b/src/Illuminate/Foundation/Bus/PendingDispatch.php index 97a339a0..f7f2d0ed 100644 --- a/src/Illuminate/Foundation/Bus/PendingDispatch.php +++ b/src/Illuminate/Foundation/Bus/PendingDispatch.php @@ -7,9 +7,12 @@ use Illuminate\Contracts\Bus\Dispatcher; use Illuminate\Contracts\Cache\Repository as Cache; use Illuminate\Contracts\Queue\ShouldBeUnique; +use Illuminate\Foundation\Queue\InteractsWithUniqueJobs; class PendingDispatch { + use InteractsWithUniqueJobs; + /** * The job. * @@ -173,7 +176,17 @@ protected function shouldDispatch() } return (new UniqueLock(Container::getInstance()->make(Cache::class))) - ->acquire($this->job); + ->acquire($this->job); + } + + /** + * Get the underlying job instance. + * + * @return mixed + */ + public function getJob() + { + return $this->job; } /** @@ -197,12 +210,18 @@ public function __call($method, $parameters) */ public function __destruct() { + $this->addUniqueJobInformationToContext($this->job); + if (! $this->shouldDispatch()) { + $this->removeUniqueJobInformationFromContext($this->job); + return; } elseif ($this->afterResponse) { app(Dispatcher::class)->dispatchAfterResponse($this->job); } else { app(Dispatcher::class)->dispatch($this->job); } + + $this->removeUniqueJobInformationFromContext($this->job); } } diff --git a/src/Illuminate/Foundation/Concerns/ResolvesDumpSource.php b/src/Illuminate/Foundation/Concerns/ResolvesDumpSource.php index 099a1336..318ec6c5 100644 --- a/src/Illuminate/Foundation/Concerns/ResolvesDumpSource.php +++ b/src/Illuminate/Foundation/Concerns/ResolvesDumpSource.php @@ -13,6 +13,7 @@ trait ResolvesDumpSource */ protected $editorHrefs = [ 'atom' => 'atom://core/open/file?filename={file}&line={line}', + 'cursor' => 'cursor://file/{file}:{line}', 'emacs' => 'emacs://open?url=file://{file}&line={line}', 'idea' => 'idea://open?file={file}&line={line}', 'macvim' => 'mvim://open/?url=file://{file}&line={line}', @@ -165,13 +166,11 @@ protected function resolveSourceHref($file, $line) $file = str_replace($this->basePath, $basePath, $file); } - $href = str_replace( + return str_replace( ['{file}', '{line}'], [$file, is_null($line) ? 1 : $line], $href, ); - - return $href; } /** diff --git a/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php b/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php index db63a095..f8506bc0 100644 --- a/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php +++ b/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php @@ -10,8 +10,10 @@ use Illuminate\Foundation\Application; use Illuminate\Foundation\Bootstrap\RegisterProviders; use Illuminate\Foundation\Events\DiagnosingHealth; +use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance; use Illuminate\Foundation\Support\Providers\EventServiceProvider as AppEventServiceProvider; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as AppRouteServiceProvider; +use Illuminate\Support\Collection; use Illuminate\Support\Facades\Broadcast; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Route; @@ -159,6 +161,10 @@ public function withRouting(?Closure $using = null, { if (is_null($using) && (is_string($web) || is_array($web) || is_string($api) || is_array($api) || is_string($pages) || is_string($health)) || is_callable($then)) { $using = $this->buildRoutingCallback($web, $api, $pages, $health, $apiPrefix, $then); + + if (is_string($health)) { + PreventRequestsDuringMaintenance::except($health); + } } AppRouteServiceProvider::loadRoutesUsing($using); @@ -313,7 +319,7 @@ public function withCommands(array $commands = []) } $this->app->afterResolving(ConsoleKernel::class, function ($kernel) use ($commands) { - [$commands, $paths] = collect($commands)->partition(fn ($command) => class_exists($command)); + [$commands, $paths] = (new Collection($commands))->partition(fn ($command) => class_exists($command)); [$routes, $paths] = $paths->partition(fn ($path) => is_file($path)); $this->app->booted(static function () use ($kernel, $commands, $paths, $routes) { diff --git a/src/Illuminate/Foundation/Configuration/Exceptions.php b/src/Illuminate/Foundation/Configuration/Exceptions.php index 532cb06d..b02753ab 100644 --- a/src/Illuminate/Foundation/Configuration/Exceptions.php +++ b/src/Illuminate/Foundation/Configuration/Exceptions.php @@ -4,6 +4,7 @@ use Closure; use Illuminate\Foundation\Exceptions\Handler; +use Illuminate\Http\Client\RequestException; use Illuminate\Support\Arr; class Exceptions @@ -200,4 +201,29 @@ public function stopIgnoring(array|string $class) return $this; } + + /** + * Set the truncation length for request exception messages. + * + * @param int $length + * @return $this + */ + public function truncateRequestExceptionsAt(int $length) + { + RequestException::truncateAt($length); + + return $this; + } + + /** + * Disable truncation of request exception messages. + * + * @return $this + */ + public function dontTruncateRequestExceptions() + { + RequestException::dontTruncate(); + + return $this; + } } diff --git a/src/Illuminate/Foundation/Configuration/Middleware.php b/src/Illuminate/Foundation/Configuration/Middleware.php index 52cf908d..f6bc12eb 100644 --- a/src/Illuminate/Foundation/Configuration/Middleware.php +++ b/src/Illuminate/Foundation/Configuration/Middleware.php @@ -16,6 +16,7 @@ use Illuminate\Routing\Middleware\ValidateSignature; use Illuminate\Session\Middleware\AuthenticateSession; use Illuminate\Support\Arr; +use Illuminate\Support\Collection; class Middleware { @@ -622,7 +623,7 @@ public function validateSignatures(array $except = []) */ public function convertEmptyStringsToNull(array $except = []) { - collect($except)->each(fn (Closure $callback) => ConvertEmptyStringsToNull::skipWhen($callback)); + (new Collection($except))->each(fn (Closure $callback) => ConvertEmptyStringsToNull::skipWhen($callback)); return $this; } @@ -635,7 +636,7 @@ public function convertEmptyStringsToNull(array $except = []) */ public function trimStrings(array $except = []) { - [$skipWhen, $except] = collect($except)->partition(fn ($value) => $value instanceof Closure); + [$skipWhen, $except] = (new Collection($except))->partition(fn ($value) => $value instanceof Closure); $skipWhen->each(fn (Closure $callback) => TrimStrings::skipWhen($callback)); diff --git a/src/Illuminate/Foundation/Console/AboutCommand.php b/src/Illuminate/Foundation/Console/AboutCommand.php index 29ea48a7..b7d39b77 100644 --- a/src/Illuminate/Foundation/Console/AboutCommand.php +++ b/src/Illuminate/Foundation/Console/AboutCommand.php @@ -4,8 +4,10 @@ use Closure; use Illuminate\Console\Command; +use Illuminate\Support\Collection; use Illuminate\Support\Composer; use Illuminate\Support\Str; +use Illuminate\Support\Stringable; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'about')] @@ -69,8 +71,8 @@ public function handle() { $this->gatherApplicationInformation(); - collect(static::$data) - ->map(fn ($items) => collect($items) + (new Collection(static::$data)) + ->map(fn ($items) => (new Collection($items)) ->map(function ($value) { if (is_array($value)) { return [$value]; @@ -80,7 +82,7 @@ public function handle() $value = $this->laravel->make($value); } - return collect($this->laravel->call($value)) + return (new Collection($this->laravel->call($value))) ->map(fn ($value, $key) => [$key, $value]) ->values() ->all(); @@ -143,7 +145,7 @@ protected function displayJson($data) { $output = $data->flatMap(function ($data, $section) { return [ - (string) Str::of($section)->snake() => $data->mapWithKeys(fn ($item, $key) => [ + (new Stringable($section))->snake()->value() => $data->mapWithKeys(fn ($item, $key) => [ $this->toSearchKeyword($item[0]) => value($item[1], true), ]), ]; @@ -192,7 +194,7 @@ protected function gatherApplicationInformation() $logChannel = config('logging.default'); if (config('logging.channels.'.$logChannel.'.driver') === 'stack') { - $secondary = collect(config('logging.channels.'.$logChannel.'.channels')); + $secondary = new Collection(config('logging.channels.'.$logChannel.'.channels')); return value(static::format( value: $logChannel, @@ -212,7 +214,7 @@ protected function gatherApplicationInformation() 'Session' => config('session.driver'), ])); - collect(static::$customDataResolvers)->each->__invoke(); + (new Collection(static::$customDataResolvers))->each->__invoke(); } /** @@ -267,7 +269,7 @@ protected static function addToSection(string $section, $data, ?string $value = */ protected function sections() { - return collect(explode(',', $this->option('only') ?? '')) + return (new Collection(explode(',', $this->option('only') ?? ''))) ->filter() ->map(fn ($only) => $this->toSearchKeyword($only)) ->all(); @@ -302,7 +304,7 @@ public static function format($value, ?Closure $console = null, ?Closure $json = */ protected function toSearchKeyword(string $value) { - return (string) Str::of($value)->lower()->snake(); + return (new Stringable($value))->lower()->snake()->value(); } /** diff --git a/src/Illuminate/Foundation/Console/ApiInstallCommand.php b/src/Illuminate/Foundation/Console/ApiInstallCommand.php index d8ab378c..aeec5c0c 100644 --- a/src/Illuminate/Foundation/Console/ApiInstallCommand.php +++ b/src/Illuminate/Foundation/Console/ApiInstallCommand.php @@ -4,9 +4,11 @@ use Illuminate\Console\Command; use Illuminate\Filesystem\Filesystem; +use Illuminate\Support\Collection; use Illuminate\Support\Facades\Process; use Symfony\Component\Console\Attribute\AsCommand; +use function Illuminate\Support\artisan_binary; use function Illuminate\Support\php_binary; #[AsCommand(name: 'install:api')] @@ -67,7 +69,7 @@ public function handle() if ($this->option('passport')) { Process::run(array_filter([ php_binary(), - defined('ARTISAN_BINARY') ? ARTISAN_BINARY : 'artisan', + artisan_binary(), 'passport:install', $this->confirm('Would you like to use UUIDs for all client IDs?') ? '--uuids' : null, ])); @@ -125,14 +127,14 @@ protected function installSanctum() 'laravel/sanctum:^4.0', ]); - $migrationPublished = collect(scandir($this->laravel->databasePath('migrations')))->contains(function ($migration) { + $migrationPublished = (new Collection(scandir($this->laravel->databasePath('migrations'))))->contains(function ($migration) { return preg_match('/\d{4}_\d{2}_\d{2}_\d{6}_create_personal_access_tokens_table.php/', $migration); }); if (! $migrationPublished) { Process::run([ php_binary(), - defined('ARTISAN_BINARY') ? ARTISAN_BINARY : 'artisan', + artisan_binary(), 'vendor:publish', '--provider', 'Laravel\\Sanctum\\SanctumServiceProvider', diff --git a/src/Illuminate/Foundation/Console/BroadcastingInstallCommand.php b/src/Illuminate/Foundation/Console/BroadcastingInstallCommand.php index 4dd9cc8d..93a8d6cf 100644 --- a/src/Illuminate/Foundation/Console/BroadcastingInstallCommand.php +++ b/src/Illuminate/Foundation/Console/BroadcastingInstallCommand.php @@ -8,6 +8,7 @@ use Illuminate\Support\Facades\Process; use Symfony\Component\Console\Attribute\AsCommand; +use function Illuminate\Support\artisan_binary; use function Illuminate\Support\php_binary; use function Laravel\Prompts\confirm; @@ -156,7 +157,7 @@ protected function installReverb() Process::run([ php_binary(), - defined('ARTISAN_BINARY') ? ARTISAN_BINARY : 'artisan', + artisan_binary(), 'reverb:install', ]); @@ -199,7 +200,7 @@ protected function installNodeDependencies() } $command = Process::command(implode(' && ', $commands)) - ->path(base_path()); + ->path(base_path()); if (! windows_os()) { $command->tty(true); diff --git a/src/Illuminate/Foundation/Console/ConfigPublishCommand.php b/src/Illuminate/Foundation/Console/ConfigPublishCommand.php index 8e87f064..7053830a 100644 --- a/src/Illuminate/Foundation/Console/ConfigPublishCommand.php +++ b/src/Illuminate/Foundation/Console/ConfigPublishCommand.php @@ -3,6 +3,7 @@ namespace Illuminate\Foundation\Console; use Illuminate\Console\Command; +use Illuminate\Support\Collection; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Finder\Finder; @@ -47,7 +48,7 @@ public function handle() $name = (string) (is_null($this->argument('name')) ? select( label: 'Which configuration file would you like to publish?', - options: collect($config)->map(function (string $path) { + options: (new Collection($config))->map(function (string $path) { return basename($path, '.php'); }), ) : $this->argument('name')); @@ -101,6 +102,6 @@ protected function getBaseConfigurationFiles() : $file->getRealPath(); } - return collect($config)->sortKeys()->all(); + return (new Collection($config))->sortKeys()->all(); } } diff --git a/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php b/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php index d4e28645..89629c5b 100644 --- a/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php @@ -4,7 +4,7 @@ use Illuminate\Console\Concerns\CreatesMatchingTest; use Illuminate\Console\GeneratorCommand; -use Illuminate\Support\Str; +use Illuminate\Support\Stringable; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; @@ -46,7 +46,7 @@ protected function replaceClass($stub, $name) { $stub = parent::replaceClass($stub, $name); - $command = $this->option('command') ?: 'app:'.Str::of($name)->classBasename()->kebab()->value(); + $command = $this->option('command') ?: 'app:'.(new Stringable($name))->classBasename()->kebab()->value(); return str_replace(['dummy:command', '{{ command }}'], $command, $stub); } diff --git a/src/Illuminate/Foundation/Console/DocsCommand.php b/src/Illuminate/Foundation/Console/DocsCommand.php index b8a36749..1eea4907 100644 --- a/src/Illuminate/Foundation/Console/DocsCommand.php +++ b/src/Illuminate/Foundation/Console/DocsCommand.php @@ -381,10 +381,10 @@ protected function openViaBuiltInStrategy($url) return; } - $binary = Collection::make(match ($this->systemOsFamily) { + $binary = (new Collection(match ($this->systemOsFamily) { 'Darwin' => ['open'], 'Linux' => ['xdg-open', 'wslview'], - })->first(fn ($binary) => (new ExecutableFinder)->find($binary) !== null); + }))->first(fn ($binary) => (new ExecutableFinder)->find($binary) !== null); if ($binary === null) { $this->components->warn('Unable to open the URL on your system. You will need to open it yourself or create a custom opener for your system.'); @@ -475,7 +475,7 @@ protected function version() */ protected function searchQuery() { - return Collection::make($_SERVER['argv'])->skip(3)->implode(' '); + return (new Collection($_SERVER['argv']))->skip(3)->implode(' '); } /** diff --git a/src/Illuminate/Foundation/Console/EventListCommand.php b/src/Illuminate/Foundation/Console/EventListCommand.php index f97a1c16..d9e5c8f8 100644 --- a/src/Illuminate/Foundation/Console/EventListCommand.php +++ b/src/Illuminate/Foundation/Console/EventListCommand.php @@ -6,6 +6,7 @@ use Illuminate\Console\Command; use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Support\Collection; use ReflectionFunction; use Symfony\Component\Console\Attribute\AsCommand; @@ -65,7 +66,7 @@ public function handle() */ protected function getEvents() { - $events = collect($this->getListenersOnDispatcher()); + $events = new Collection($this->getListenersOnDispatcher()); if ($this->filteringByEvent()) { $events = $this->filterEvents($events); diff --git a/src/Illuminate/Foundation/Console/Kernel.php b/src/Illuminate/Foundation/Console/Kernel.php index eb9405ba..0ec8e312 100644 --- a/src/Illuminate/Foundation/Console/Kernel.php +++ b/src/Illuminate/Foundation/Console/Kernel.php @@ -17,6 +17,7 @@ use Illuminate\Foundation\Events\Terminating; use Illuminate\Support\Arr; use Illuminate\Support\Carbon; +use Illuminate\Support\Collection; use Illuminate\Support\Env; use Illuminate\Support\InteractsWithTime; use Illuminate\Support\Str; @@ -512,9 +513,9 @@ protected function discoverCommands() public function bootstrapWithoutBootingProviders() { $this->app->bootstrapWith( - collect($this->bootstrappers())->reject(function ($bootstrapper) { - return $bootstrapper === \Illuminate\Foundation\Bootstrap\BootProviders::class; - })->all() + (new Collection($this->bootstrappers())) + ->reject(fn ($bootstrapper) => $bootstrapper === \Illuminate\Foundation\Bootstrap\BootProviders::class) + ->all() ); } @@ -537,8 +538,8 @@ protected function getArtisan() { if (is_null($this->artisan)) { $this->artisan = (new Artisan($this->app, $this->events, $this->app->version())) - ->resolveCommands($this->commands) - ->setContainerCommandLoader(); + ->resolveCommands($this->commands) + ->setContainerCommandLoader(); if ($this->symfonyDispatcher instanceof EventDispatcher) { $this->artisan->setDispatcher($this->symfonyDispatcher); diff --git a/src/Illuminate/Foundation/Console/MailMakeCommand.php b/src/Illuminate/Foundation/Console/MailMakeCommand.php index d6bf70f7..daa46d9e 100644 --- a/src/Illuminate/Foundation/Console/MailMakeCommand.php +++ b/src/Illuminate/Foundation/Console/MailMakeCommand.php @@ -5,6 +5,7 @@ use Illuminate\Console\Concerns\CreatesMatchingTest; use Illuminate\Console\GeneratorCommand; use Illuminate\Foundation\Inspiring; +use Illuminate\Support\Collection; use Illuminate\Support\Str; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputInterface; @@ -142,7 +143,7 @@ protected function getView() if (! $view) { $name = str_replace('\\', '/', $this->argument('name')); - $view = 'mail.'.collect(explode('/', $name)) + $view = 'mail.'.(new Collection(explode('/', $name))) ->map(fn ($part) => Str::kebab($part)) ->implode('.'); } diff --git a/src/Illuminate/Foundation/Console/ModelMakeCommand.php b/src/Illuminate/Foundation/Console/ModelMakeCommand.php index 146332ab..743fd170 100644 --- a/src/Illuminate/Foundation/Console/ModelMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ModelMakeCommand.php @@ -4,6 +4,7 @@ use Illuminate\Console\Concerns\CreatesMatchingTest; use Illuminate\Console\GeneratorCommand; +use Illuminate\Support\Collection; use Illuminate\Support\Str; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputInterface; @@ -252,7 +253,7 @@ protected function buildFactoryReplacements() $replacements = []; if ($this->option('factory') || $this->option('all')) { - $modelPath = str($this->argument('name'))->studly()->replace('/', '\\')->toString(); + $modelPath = Str::of($this->argument('name'))->studly()->replace('/', '\\')->toString(); $factoryNamespace = '\\Database\\Factories\\'.$modelPath.'Factory'; @@ -308,13 +309,13 @@ protected function afterPromptingForMissingArguments(InputInterface $input, Outp return; } - collect(multiselect('Would you like any of the following?', [ + (new Collection(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)); + ])))->each(fn ($option) => $input->setOption($option, true)); } } diff --git a/src/Illuminate/Foundation/Console/NotificationMakeCommand.php b/src/Illuminate/Foundation/Console/NotificationMakeCommand.php index d6105af9..3156131b 100644 --- a/src/Illuminate/Foundation/Console/NotificationMakeCommand.php +++ b/src/Illuminate/Foundation/Console/NotificationMakeCommand.php @@ -4,6 +4,7 @@ use Illuminate\Console\Concerns\CreatesMatchingTest; use Illuminate\Console\GeneratorCommand; +use Illuminate\Support\Collection; use Illuminate\Support\Str; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputInterface; @@ -144,7 +145,7 @@ protected function afterPromptingForMissingArguments(InputInterface $input, Outp $wantsMarkdownView = confirm('Would you like to create a markdown view?'); if ($wantsMarkdownView) { - $defaultMarkdownView = collect(explode('/', str_replace('\\', '/', $this->argument('name')))) + $defaultMarkdownView = (new Collection(explode('/', str_replace('\\', '/', $this->argument('name'))))) ->map(fn ($path) => Str::kebab($path)) ->prepend('mail') ->implode('.'); diff --git a/src/Illuminate/Foundation/Console/OptimizeClearCommand.php b/src/Illuminate/Foundation/Console/OptimizeClearCommand.php index ea90627b..974af84f 100644 --- a/src/Illuminate/Foundation/Console/OptimizeClearCommand.php +++ b/src/Illuminate/Foundation/Console/OptimizeClearCommand.php @@ -3,8 +3,10 @@ namespace Illuminate\Foundation\Console; use Illuminate\Console\Command; +use Illuminate\Support\Collection; use Illuminate\Support\ServiceProvider; use Symfony\Component\Console\Attribute\AsCommand; +use Symfony\Component\Console\Input\InputOption; #[AsCommand(name: 'optimize:clear')] class OptimizeClearCommand extends Command @@ -32,7 +34,17 @@ public function handle() { $this->components->info('Clearing cached bootstrap files.'); - foreach ($this->getOptimizeClearTasks() as $description => $command) { + $exceptions = Collection::wrap(explode(',', $this->option('except') ?? '')) + ->map(fn ($except) => trim($except)) + ->filter() + ->unique() + ->flip(); + + $tasks = Collection::wrap($this->getOptimizeClearTasks()) + ->reject(fn ($command, $key) => $exceptions->hasAny([$command, $key])) + ->toArray(); + + foreach ($tasks as $description => $command) { $this->components->task($description, fn () => $this->callSilently($command) == 0); } @@ -56,4 +68,16 @@ public function getOptimizeClearTasks() ...ServiceProvider::$optimizeClearCommands, ]; } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getOptions() + { + return [ + ['except', 'e', InputOption::VALUE_OPTIONAL, 'The commands to skip'], + ]; + } } diff --git a/src/Illuminate/Foundation/Console/OptimizeCommand.php b/src/Illuminate/Foundation/Console/OptimizeCommand.php index 60c97621..ef78e8c0 100644 --- a/src/Illuminate/Foundation/Console/OptimizeCommand.php +++ b/src/Illuminate/Foundation/Console/OptimizeCommand.php @@ -3,8 +3,10 @@ namespace Illuminate\Foundation\Console; use Illuminate\Console\Command; +use Illuminate\Support\Collection; use Illuminate\Support\ServiceProvider; use Symfony\Component\Console\Attribute\AsCommand; +use Symfony\Component\Console\Input\InputOption; #[AsCommand(name: 'optimize')] class OptimizeCommand extends Command @@ -32,7 +34,17 @@ public function handle() { $this->components->info('Caching framework bootstrap, configuration, and metadata.'); - foreach ($this->getOptimizeTasks() as $description => $command) { + $exceptions = Collection::wrap(explode(',', $this->option('except') ?? '')) + ->map(fn ($except) => trim($except)) + ->filter() + ->unique() + ->flip(); + + $tasks = Collection::wrap($this->getOptimizeTasks()) + ->reject(fn ($command, $key) => $exceptions->hasAny([$command, $key])) + ->toArray(); + + foreach ($tasks as $description => $command) { $this->components->task($description, fn () => $this->callSilently($command) == 0); } @@ -54,4 +66,16 @@ protected function getOptimizeTasks() ...ServiceProvider::$optimizeCommands, ]; } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getOptions() + { + return [ + ['except', 'e', InputOption::VALUE_OPTIONAL, 'Do not run the commands matching the key or name'], + ]; + } } diff --git a/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php b/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php index 86f069b8..2cf4a5f5 100644 --- a/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php +++ b/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php @@ -4,6 +4,7 @@ use Illuminate\Console\Command; use Illuminate\Foundation\PackageManifest; +use Illuminate\Support\Collection; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'package:discover')] @@ -35,7 +36,7 @@ public function handle(PackageManifest $manifest) $manifest->build(); - collect($manifest->manifest) + (new Collection($manifest->manifest)) ->keys() ->each(fn ($description) => $this->components->task($description)) ->whenNotEmpty(fn () => $this->newLine()); diff --git a/src/Illuminate/Foundation/Console/RouteListCommand.php b/src/Illuminate/Foundation/Console/RouteListCommand.php index df3126fc..104bff78 100644 --- a/src/Illuminate/Foundation/Console/RouteListCommand.php +++ b/src/Illuminate/Foundation/Console/RouteListCommand.php @@ -9,7 +9,9 @@ use Illuminate\Routing\Router; use Illuminate\Routing\ViewController; use Illuminate\Support\Arr; +use Illuminate\Support\Collection; use Illuminate\Support\Str; +use Illuminate\Support\Stringable; use ReflectionClass; use ReflectionFunction; use Symfony\Component\Console\Attribute\AsCommand; @@ -112,7 +114,7 @@ public function handle() */ protected function getRoutes() { - $routes = collect($this->router->getRoutes())->map(function ($route) { + $routes = (new Collection($this->router->getRoutes()))->map(function ($route) { return $this->getRouteInformation($route); })->filter()->all(); @@ -157,11 +159,15 @@ protected function getRouteInformation(Route $route) */ protected function sortRoutes($sort, array $routes) { + if ($sort === 'definition') { + return $routes; + } + if (Str::contains($sort, ',')) { $sort = explode(',', $sort); } - return collect($routes) + return (new Collection($routes)) ->sortBy($sort) ->toArray(); } @@ -187,7 +193,7 @@ protected function pluckColumns(array $routes) */ protected function displayRoutes(array $routes) { - $routes = collect($routes); + $routes = new Collection($routes); $this->output->writeln( $this->option('json') ? $this->asJson($routes) : $this->forCli($routes) @@ -202,7 +208,7 @@ protected function displayRoutes(array $routes) */ protected function getMiddleware($route) { - return collect($this->router->gatherRouteMiddleware($route))->map(function ($middleware) { + return (new Collection($this->router->gatherRouteMiddleware($route)))->map(function ($middleware) { return $middleware instanceof Closure ? 'Closure' : $middleware; })->implode("\n"); } @@ -217,7 +223,7 @@ protected function isVendorRoute(Route $route) { if ($route->action['uses'] instanceof Closure) { $path = (new ReflectionFunction($route->action['uses'])) - ->getFileName(); + ->getFileName(); } elseif (is_string($route->action['uses']) && str_contains($route->action['uses'], 'SerializableClosure')) { return false; @@ -227,7 +233,7 @@ protected function isVendorRoute(Route $route) } $path = (new ReflectionClass($route->getControllerClass())) - ->getFileName(); + ->getFileName(); } else { return false; } @@ -258,6 +264,7 @@ protected function isFrameworkController(Route $route) protected function filterRoute(array $route) { if (($this->option('name') && ! Str::contains((string) $route['name'], $this->option('name'))) || + ($this->option('action') && isset($route['action']) && is_string($route['action']) && ! Str::contains($route['action'], $this->option('action'))) || ($this->option('path') && ! Str::contains($route['uri'], $this->option('path'))) || ($this->option('method') && ! Str::contains($route['method'], strtoupper($this->option('method')))) || ($this->option('domain') && ! Str::contains((string) $route['domain'], $this->option('domain'))) || @@ -367,7 +374,7 @@ protected function forCli($routes) 'uri' => $uri, ] = $route; - $middleware = Str::of($middleware)->explode("\n")->filter()->whenNotEmpty( + $middleware = (new Stringable($middleware))->explode("\n")->filter()->whenNotEmpty( fn ($collection) => $collection->map( fn ($middleware) => sprintf(' %s⇂ %s', str_repeat(' ', $maxMethod), $middleware) ) @@ -385,7 +392,7 @@ protected function forCli($routes) $action = substr($action, 0, $terminalWidth - 7 - mb_strlen($method.$spaces.$uri.$dots)).'…'; } - $method = Str::of($method)->explode('|')->map( + $method = (new Stringable($method))->explode('|')->map( fn ($method) => sprintf('%s', $this->verbColors[$method] ?? 'default', $method), )->implode('|'); @@ -431,7 +438,7 @@ protected function formatActionForCli($route) $actionClass = explode('@', $action)[0]; if (class_exists($actionClass) && str_starts_with((new ReflectionClass($actionClass))->getFilename(), base_path('vendor'))) { - $actionCollection = collect(explode('\\', $action)); + $actionCollection = new Collection(explode('\\', $action)); return $name.$actionCollection->take(2)->implode('\\').' '.$actionCollection->last(); } @@ -490,12 +497,13 @@ protected function getOptions() return [ ['json', null, InputOption::VALUE_NONE, 'Output the route list as JSON'], ['method', null, InputOption::VALUE_OPTIONAL, 'Filter the routes by method'], + ['action', null, InputOption::VALUE_OPTIONAL, 'Filter the routes by action'], ['name', null, InputOption::VALUE_OPTIONAL, 'Filter the routes by name'], ['domain', null, InputOption::VALUE_OPTIONAL, 'Filter the routes by domain'], ['path', null, InputOption::VALUE_OPTIONAL, 'Only show routes matching the given path pattern'], ['except-path', null, InputOption::VALUE_OPTIONAL, 'Do not display the routes matching the given path pattern'], ['reverse', 'r', InputOption::VALUE_NONE, 'Reverse the ordering of the routes'], - ['sort', null, InputOption::VALUE_OPTIONAL, 'The column (domain, method, uri, name, action, middleware) to sort by', 'uri'], + ['sort', null, InputOption::VALUE_OPTIONAL, 'The column (domain, method, uri, name, action, middleware, definition) to sort by', 'uri'], ['except-vendor', null, InputOption::VALUE_NONE, 'Do not display routes defined by vendor packages'], ['only-vendor', null, InputOption::VALUE_NONE, 'Only display routes defined by vendor packages'], ]; diff --git a/src/Illuminate/Foundation/Console/ServeCommand.php b/src/Illuminate/Foundation/Console/ServeCommand.php index a0ca24f0..fc40abc7 100644 --- a/src/Illuminate/Foundation/Console/ServeCommand.php +++ b/src/Illuminate/Foundation/Console/ServeCommand.php @@ -4,8 +4,10 @@ use Illuminate\Console\Command; use Illuminate\Support\Carbon; +use Illuminate\Support\Collection; use Illuminate\Support\Env; use Illuminate\Support\InteractsWithTime; +use Illuminate\Support\Stringable; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Process\Process; @@ -70,6 +72,7 @@ class ServeCommand extends Command 'HERD_PHP_81_INI_SCAN_DIR', 'HERD_PHP_82_INI_SCAN_DIR', 'HERD_PHP_83_INI_SCAN_DIR', + 'HERD_PHP_84_INI_SCAN_DIR', 'IGNITION_LOCAL_SITES_PATH', 'LARAVEL_SAIL', 'PATH', @@ -145,7 +148,7 @@ public function handle() */ protected function startProcess($hasEnvironment) { - $process = new Process($this->serverCommand(), public_path(), collect($_ENV)->mapWithKeys(function ($value, $key) use ($hasEnvironment) { + $process = new Process($this->serverCommand(), public_path(), (new Collection($_ENV))->mapWithKeys(function ($value, $key) use ($hasEnvironment) { if ($this->option('no-reload') || ! $hasEnvironment) { return [$key => $value]; } @@ -269,7 +272,7 @@ protected function handleProcessOutput() */ protected function flushOutputBuffer() { - $lines = str($this->outputBuffer)->explode("\n"); + $lines = (new Stringable($this->outputBuffer))->explode("\n"); $this->outputBuffer = (string) $lines->pop(); @@ -277,7 +280,7 @@ protected function flushOutputBuffer() ->map(fn ($line) => trim($line)) ->filter() ->each(function ($line) { - if (str($line)->contains('Development Server (http')) { + if ((new Stringable($line))->contains('Development Server (http')) { if ($this->serverRunningHasBeenDisplayed === false) { $this->serverRunningHasBeenDisplayed = true; @@ -290,7 +293,7 @@ protected function flushOutputBuffer() return; } - if (str($line)->contains(' Accepted')) { + if ((new Stringable($line))->contains(' Accepted')) { $requestPort = static::getRequestPortFromLine($line); $this->requestsPool[$requestPort] = [ @@ -298,15 +301,15 @@ protected function flushOutputBuffer() $this->requestsPool[$requestPort][1] ?? false, microtime(true), ]; - } elseif (str($line)->contains([' [200]: GET '])) { + } elseif ((new Stringable($line))->contains([' [200]: GET '])) { $requestPort = static::getRequestPortFromLine($line); $this->requestsPool[$requestPort][1] = trim(explode('[200]: GET', $line)[1]); - } elseif (str($line)->contains('URI:')) { + } elseif ((new Stringable($line))->contains('URI:')) { $requestPort = static::getRequestPortFromLine($line); $this->requestsPool[$requestPort][1] = trim(explode('URI: ', $line)[1]); - } elseif (str($line)->contains(' Closing')) { + } elseif ((new Stringable($line))->contains(' Closing')) { $requestPort = static::getRequestPortFromLine($line); if (empty($this->requestsPool[$requestPort])) { @@ -337,11 +340,11 @@ protected function flushOutputBuffer() $this->output->write(' '.str_repeat('.', $dots)); $this->output->writeln(" ~ {$runTime}"); - } elseif (str($line)->contains(['Closed without sending a request', 'Failed to poll event'])) { + } elseif ((new Stringable($line))->contains(['Closed without sending a request', 'Failed to poll event'])) { // ... } elseif (! empty($line)) { - if (str($line)->startsWith('[')) { - $line = str($line)->after('] '); + if ((new Stringable($line))->startsWith('[')) { + $line = (new Stringable($line))->after('] '); } $this->output->writeln(" $line"); diff --git a/src/Illuminate/Foundation/Console/ViewCacheCommand.php b/src/Illuminate/Foundation/Console/ViewCacheCommand.php index b108ea80..3eacc26f 100644 --- a/src/Illuminate/Foundation/Console/ViewCacheCommand.php +++ b/src/Illuminate/Foundation/Console/ViewCacheCommand.php @@ -77,13 +77,13 @@ protected function compileViews(Collection $views) */ protected function bladeFilesIn(array $paths) { - $extensions = collect($this->laravel['view']->getExtensions()) + $extensions = (new Collection($this->laravel['view']->getExtensions())) ->filter(fn ($value) => $value === 'blade') ->keys() ->map(fn ($extension) => "*.{$extension}") ->all(); - return collect( + return new Collection( Finder::create() ->in($paths) ->exclude('vendor') @@ -101,8 +101,8 @@ protected function paths() { $finder = $this->laravel['view']->getFinder(); - return collect($finder->getPaths())->merge( - collect($finder->getHints())->flatten() + return (new Collection($finder->getPaths()))->merge( + (new Collection($finder->getHints()))->flatten() ); } } diff --git a/src/Illuminate/Foundation/Console/ViewMakeCommand.php b/src/Illuminate/Foundation/Console/ViewMakeCommand.php index 8c138a80..afd21e9b 100644 --- a/src/Illuminate/Foundation/Console/ViewMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ViewMakeCommand.php @@ -7,6 +7,7 @@ use Illuminate\Foundation\Inspiring; use Illuminate\Support\Facades\File; use Illuminate\Support\Str; +use Illuminate\Support\Stringable; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputOption; @@ -184,15 +185,15 @@ protected function testClassFullyQualifiedName() $name = Str::of(Str::lower($this->getNameInput()))->replace('.'.$this->option('extension'), ''); $namespacedName = Str::of( - Str::of($name) + (new Stringable($name)) ->replace('/', ' ') ->explode(' ') - ->map(fn ($part) => Str::of($part)->ucfirst()) + ->map(fn ($part) => (new Stringable($part))->ucfirst()) ->implode('\\') ) ->replace(['-', '_'], ' ') ->explode(' ') - ->map(fn ($part) => Str::of($part)->ucfirst()) + ->map(fn ($part) => (new Stringable($part))->ucfirst()) ->implode(''); return 'Tests\\Feature\\View\\'.$namespacedName; diff --git a/src/Illuminate/Foundation/Events/DiscoverEvents.php b/src/Illuminate/Foundation/Events/DiscoverEvents.php index 51e1b1b3..e2933f93 100644 --- a/src/Illuminate/Foundation/Events/DiscoverEvents.php +++ b/src/Illuminate/Foundation/Events/DiscoverEvents.php @@ -2,6 +2,7 @@ namespace Illuminate\Foundation\Events; +use Illuminate\Support\Collection; use Illuminate\Support\Reflector; use Illuminate\Support\Str; use ReflectionClass; @@ -28,7 +29,7 @@ class DiscoverEvents */ public static function within($listenerPath, $basePath) { - $listeners = collect(static::getListenerEvents( + $listeners = new Collection(static::getListenerEvents( Finder::create()->files()->in($listenerPath), $basePath )); diff --git a/src/Illuminate/Foundation/Exceptions/Handler.php b/src/Illuminate/Foundation/Exceptions/Handler.php index ec3ec9c2..2f381d1e 100644 --- a/src/Illuminate/Foundation/Exceptions/Handler.php +++ b/src/Illuminate/Foundation/Exceptions/Handler.php @@ -29,9 +29,11 @@ use Illuminate\Routing\Router; use Illuminate\Session\TokenMismatchException; use Illuminate\Support\Arr; +use Illuminate\Support\Collection; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Lottery; use Illuminate\Support\Reflector; +use Illuminate\Support\Str; use Illuminate\Support\Traits\ReflectsClosures; use Illuminate\Support\ViewErrorBag; use Illuminate\Validation\ValidationException; @@ -480,11 +482,11 @@ public function stopIgnoring(array|string $exceptions) { $exceptions = Arr::wrap($exceptions); - $this->dontReport = collect($this->dontReport) - ->reject(fn ($ignored) => in_array($ignored, $exceptions))->values()->all(); + $this->dontReport = (new Collection($this->dontReport)) + ->reject(fn ($ignored) => in_array($ignored, $exceptions))->values()->all(); - $this->internalDontReport = collect($this->internalDontReport) - ->reject(fn ($ignored) => in_array($ignored, $exceptions))->values()->all(); + $this->internalDontReport = (new Collection($this->internalDontReport)) + ->reject(fn ($ignored) => in_array($ignored, $exceptions))->values()->all(); return $this; } @@ -746,8 +748,8 @@ protected function convertValidationExceptionToResponse(ValidationException $e, protected function invalid($request, ValidationException $exception) { return redirect($exception->redirectTo ?? url()->previous()) - ->withInput(Arr::except($request->input(), $this->dontFlash)) - ->withErrors($exception->errors(), $request->input('_error_bag', $exception->errorBag)); + ->withInput(Arr::except($request->input(), $this->dontFlash)) + ->withErrors($exception->errors(), $request->input('_error_bag', $exception->errorBag)); } /** @@ -988,7 +990,7 @@ protected function convertExceptionToArray(Throwable $e) 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), - 'trace' => collect($e->getTrace())->map(fn ($trace) => Arr::except($trace, ['args']))->all(), + 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; @@ -1006,7 +1008,7 @@ protected function convertExceptionToArray(Throwable $e) public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { - $message = str($e->getMessage())->explode('.')->first(); + $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; diff --git a/src/Illuminate/Foundation/Exceptions/RegisterErrorViewPaths.php b/src/Illuminate/Foundation/Exceptions/RegisterErrorViewPaths.php index c88f3261..f96d231e 100644 --- a/src/Illuminate/Foundation/Exceptions/RegisterErrorViewPaths.php +++ b/src/Illuminate/Foundation/Exceptions/RegisterErrorViewPaths.php @@ -2,6 +2,7 @@ namespace Illuminate\Foundation\Exceptions; +use Illuminate\Support\Collection; use Illuminate\Support\Facades\View; class RegisterErrorViewPaths @@ -13,7 +14,7 @@ class RegisterErrorViewPaths */ public function __invoke() { - View::replaceNamespace('errors', collect(config('view.paths'))->map(function ($path) { + View::replaceNamespace('errors', (new Collection(config('view.paths')))->map(function ($path) { return "{$path}/errors"; })->push(__DIR__.'/views')->all()); } diff --git a/src/Illuminate/Foundation/Exceptions/Renderer/Exception.php b/src/Illuminate/Foundation/Exceptions/Renderer/Exception.php index 4aef4257..3c562e05 100644 --- a/src/Illuminate/Foundation/Exceptions/Renderer/Exception.php +++ b/src/Illuminate/Foundation/Exceptions/Renderer/Exception.php @@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Bootstrap\HandleExceptions; use Illuminate\Http\Request; +use Illuminate\Support\Collection; use Symfony\Component\ErrorHandler\Exception\FlattenException; class Exception @@ -120,7 +121,7 @@ public function frames() array_shift($trace); } - return collect(array_map( + return new Collection(array_map( fn (array $trace) => new Frame($this->exception, $classMap, $trace, $this->basePath), $trace, )); } diff --git a/src/Illuminate/Foundation/Exceptions/Renderer/Mappers/BladeMapper.php b/src/Illuminate/Foundation/Exceptions/Renderer/Mappers/BladeMapper.php index 8a4da94a..25b6b713 100644 --- a/src/Illuminate/Foundation/Exceptions/Renderer/Mappers/BladeMapper.php +++ b/src/Illuminate/Foundation/Exceptions/Renderer/Mappers/BladeMapper.php @@ -87,7 +87,7 @@ public function map(FlattenException $exception) $exception = $previous; } - $trace = Collection::make($exception->getTrace()) + $trace = (new Collection($exception->getTrace())) ->map(function ($frame) { if ($originalPath = $this->findCompiledView((string) Arr::get($frame, 'file', ''))) { $frame['file'] = $originalPath; diff --git a/src/Illuminate/Foundation/Exceptions/Renderer/Renderer.php b/src/Illuminate/Foundation/Exceptions/Renderer/Renderer.php index d6770f2e..6772ae1d 100644 --- a/src/Illuminate/Foundation/Exceptions/Renderer/Renderer.php +++ b/src/Illuminate/Foundation/Exceptions/Renderer/Renderer.php @@ -5,6 +5,7 @@ use Illuminate\Contracts\View\Factory; use Illuminate\Foundation\Exceptions\Renderer\Mappers\BladeMapper; use Illuminate\Http\Request; +use Illuminate\Support\Collection; use Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer; use Throwable; @@ -101,14 +102,14 @@ public function render(Request $request, Throwable $throwable) */ public static function css() { - return collect([ + return (new Collection([ ['styles.css', []], ['light-mode.css', ['data-theme' => 'light']], ['dark-mode.css', ['data-theme' => 'dark']], - ])->map(function ($fileAndAttributes) { + ]))->map(function ($fileAndAttributes) { [$filename, $attributes] = $fileAndAttributes; - return '