diff --git a/bin/sync b/bin/sync index 6c783f3..52f8a91 100755 --- a/bin/sync +++ b/bin/sync @@ -47,9 +47,27 @@ transform([ // Configure `Illuminate\Foundation\Testing\Concerns\InteractsWithTestCaseLifecycle` class transform([ + line('EncryptCookies::flushState();', 2) => PHP_EOL.line('if (class_exists(EncryptCookies::class)) { + EncryptCookies::flushState(); + }'.PHP_EOL, 2), + line('Factory::flushState();', 2) => PHP_EOL.line('if (class_exists(Factory::class)) { + Factory::flushState(); + }'.PHP_EOL, 2), + line('Migrator::withoutMigrations([]);', 2) => PHP_EOL.line('if (class_exists(Migrator::class)) { + Migrator::withoutMigrations([]); + }'.PHP_EOL, 2), line('Queue::createPayloadUsing(null);', 2) => PHP_EOL.line('if (class_exists(Queue::class)) { Queue::createPayloadUsing(null); }'.PHP_EOL, 2), + line('TrustProxies::flushState();', 2) => PHP_EOL.line('if (class_exists(TrustProxies::class)) { + TrustProxies::flushState(); + }'.PHP_EOL, 2), + line('TrustHosts::flushState();', 2) => PHP_EOL.line('if (class_exists(TrustHosts::class)) { + TrustHosts::flushState(); + }'.PHP_EOL, 2), + line('WorkCommand::flushState();', 2) => PHP_EOL.line('if (class_exists(WorkCommand::class)) { + WorkCommand::flushState(); + }'.PHP_EOL, 2), ], fn ($changes) => $files->replaceInFile(array_keys($changes), array_values($changes), "{$workingPath}/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTestCaseLifecycle.php")); // Configure `config/cache.php` file diff --git a/composer.json b/composer.json index b2f7ba2..088165b 100755 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "php": "^8.2" }, "require-dev": { - "laravel/framework": "^11" + "laravel/framework": "^12" }, "autoload": { "files": [ @@ -22,7 +22,7 @@ }, "extra": { "branch-alias": { - "dev-main": "11.x-dev" + "dev-main": "12.x-dev" } }, "scripts": { diff --git a/config-stubs/app.php b/config-stubs/app.php index f467267..324b513 100644 --- a/config-stubs/app.php +++ b/config-stubs/app.php @@ -65,7 +65,7 @@ | */ - 'timezone' => env('APP_TIMEZONE', 'UTC'), + 'timezone' => 'UTC', /* |-------------------------------------------------------------------------- diff --git a/config/app.php b/config/app.php index d4e3180..1607317 100644 --- a/config/app.php +++ b/config/app.php @@ -72,7 +72,7 @@ | */ - 'timezone' => env('APP_TIMEZONE', 'UTC'), + 'timezone' => 'UTC', /* |-------------------------------------------------------------------------- diff --git a/config/database.php b/config/database.php index 8910562..3e827c3 100644 --- a/config/database.php +++ b/config/database.php @@ -36,6 +36,7 @@ 'url' => env('DB_URL'), 'database' => env('DB_DATABASE', database_path('database.sqlite')), 'prefix' => '', + 'prefix_indexes' => null, 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), 'busy_timeout' => null, 'journal_mode' => null, diff --git a/config/filesystems.php b/config/filesystems.php index c9bd1d0..3d671bd 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -32,7 +32,8 @@ 'local' => [ 'driver' => 'local', - 'root' => storage_path('app'), + 'root' => storage_path('app/private'), + 'serve' => true, 'throw' => false, 'report' => false, ], diff --git a/config/hashing.php b/config/hashing.php index 9eb408e..356ec10 100644 --- a/config/hashing.php +++ b/config/hashing.php @@ -31,6 +31,7 @@ 'bcrypt' => [ 'rounds' => env('BCRYPT_ROUNDS', 12), 'verify' => env('HASH_VERIFY', true), + 'limit' => env('BCRYPT_LIMIT', null), ], /* diff --git a/config/logging.php b/config/logging.php index 8d94292..1345f6f 100644 --- a/config/logging.php +++ b/config/logging.php @@ -98,10 +98,10 @@ 'driver' => 'monolog', 'level' => env('LOG_LEVEL', 'debug'), 'handler' => StreamHandler::class, - 'formatter' => env('LOG_STDERR_FORMATTER'), - 'with' => [ + 'handler_with' => [ 'stream' => 'php://stderr', ], + 'formatter' => env('LOG_STDERR_FORMATTER'), 'processors' => [PsrLogMessageProcessor::class], ], diff --git a/src/Illuminate/Foundation/AliasLoader.php b/src/Illuminate/Foundation/AliasLoader.php index 5146e44..9c82245 100644 --- a/src/Illuminate/Foundation/AliasLoader.php +++ b/src/Illuminate/Foundation/AliasLoader.php @@ -36,7 +36,6 @@ class AliasLoader * Create a new AliasLoader instance. * * @param array $aliases - * @return void */ private function __construct($aliases) { @@ -164,7 +163,7 @@ public function register() */ protected function prependToLoaderStack() { - spl_autoload_register([$this, 'load'], true, true); + spl_autoload_register($this->load(...), true, true); } /** diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index 1b45937..9bba316 100644 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -44,7 +44,7 @@ class Application extends Container implements ApplicationContract, CachesConfig * * @var string */ - const VERSION = '11.44.2'; + const VERSION = '12.4.1'; /** * Copied from HttpKernelInterface, which this class no longer extends. @@ -218,7 +218,6 @@ class Application extends Container implements ApplicationContract, CachesConfig * Create a new Illuminate application instance. * * @param string|null $basePath - * @return void */ public function __construct($basePath = null) { @@ -430,14 +429,14 @@ protected function bindPathsInContainer() $this->useBootstrapPath(value(function () { return is_dir($directory = $this->basePath('.laravel')) - ? $directory - : $this->basePath('bootstrap'); + ? $directory + : $this->basePath('bootstrap'); })); $this->useLangPath(value(function () { return is_dir($directory = $this->resourcePath('lang')) - ? $directory - : $this->basePath('lang'); + ? $directory + : $this->basePath('lang'); })); } @@ -1375,8 +1374,8 @@ protected function normalizeCachePath($key, $default) } return Str::startsWith($env, $this->absoluteCachePathPrefixes) - ? $env - : $this->basePath($env); + ? $env + : $this->basePath($env); } /** diff --git a/src/Illuminate/Foundation/Bus/PendingChain.php b/src/Illuminate/Foundation/Bus/PendingChain.php index f1935e2..bcb381e 100644 --- a/src/Illuminate/Foundation/Bus/PendingChain.php +++ b/src/Illuminate/Foundation/Bus/PendingChain.php @@ -61,7 +61,6 @@ class PendingChain * * @param mixed $job * @param array $chain - * @return void */ public function __construct($job, $chain) { @@ -117,8 +116,8 @@ public function delay($delay) public function catch($callback) { $this->catchCallbacks[] = $callback instanceof Closure - ? new SerializableClosure($callback) - : $callback; + ? new SerializableClosure($callback) + : $callback; return $this; } diff --git a/src/Illuminate/Foundation/Bus/PendingDispatch.php b/src/Illuminate/Foundation/Bus/PendingDispatch.php index f7f2d0e..443eb5e 100644 --- a/src/Illuminate/Foundation/Bus/PendingDispatch.php +++ b/src/Illuminate/Foundation/Bus/PendingDispatch.php @@ -31,7 +31,6 @@ class PendingDispatch * Create a new pending job dispatch. * * @param mixed $job - * @return void */ public function __construct($job) { diff --git a/src/Illuminate/Foundation/CacheBasedMaintenanceMode.php b/src/Illuminate/Foundation/CacheBasedMaintenanceMode.php index 01ff30d..630df4f 100644 --- a/src/Illuminate/Foundation/CacheBasedMaintenanceMode.php +++ b/src/Illuminate/Foundation/CacheBasedMaintenanceMode.php @@ -35,7 +35,6 @@ class CacheBasedMaintenanceMode implements MaintenanceMode * @param \Illuminate\Contracts\Cache\Factory $cache * @param string $store * @param string $key - * @return void */ public function __construct(Factory $cache, string $store, string $key) { diff --git a/src/Illuminate/Foundation/Configuration/Exceptions.php b/src/Illuminate/Foundation/Configuration/Exceptions.php index b02753a..1072a14 100644 --- a/src/Illuminate/Foundation/Configuration/Exceptions.php +++ b/src/Illuminate/Foundation/Configuration/Exceptions.php @@ -13,7 +13,6 @@ class Exceptions * Create a new exception handling configuration instance. * * @param \Illuminate\Foundation\Exceptions\Handler $handler - * @return void */ public function __construct(public Handler $handler) { diff --git a/src/Illuminate/Foundation/Configuration/Middleware.php b/src/Illuminate/Foundation/Configuration/Middleware.php index f6bc12e..20b5049 100644 --- a/src/Illuminate/Foundation/Configuration/Middleware.php +++ b/src/Illuminate/Foundation/Configuration/Middleware.php @@ -451,6 +451,7 @@ public function appendToPriorityList($after, $append) public function getGlobalMiddleware() { $middleware = $this->global ?: array_values(array_filter([ + \Illuminate\Http\Middleware\ValidatePathEncoding::class, \Illuminate\Foundation\Http\Middleware\InvokeDeferredCallbacks::class, $this->trustHosts ? \Illuminate\Http\Middleware\TrustHosts::class : null, \Illuminate\Http\Middleware\TrustProxies::class, diff --git a/src/Illuminate/Foundation/Console/AboutCommand.php b/src/Illuminate/Foundation/Console/AboutCommand.php index b7d39b7..c6d61b6 100644 --- a/src/Illuminate/Foundation/Console/AboutCommand.php +++ b/src/Illuminate/Foundation/Console/AboutCommand.php @@ -53,7 +53,6 @@ class AboutCommand extends Command * Create a new command instance. * * @param \Illuminate\Support\Composer $composer - * @return void */ public function __construct(Composer $composer) { @@ -165,6 +164,7 @@ protected function gatherApplicationInformation() $formatEnabledStatus = fn ($value) => $value ? 'ENABLED' : 'OFF'; $formatCachedStatus = fn ($value) => $value ? 'CACHED' : 'NOT CACHED'; + $formatStorageLinkedStatus = fn ($value) => $value ? 'LINKED' : 'NOT LINKED'; static::addToSection('Environment', fn () => [ 'Application Name' => config('app.name'), @@ -214,9 +214,30 @@ protected function gatherApplicationInformation() 'Session' => config('session.driver'), ])); + static::addToSection('Storage', fn () => [ + ...$this->determineStoragePathLinkStatus($formatStorageLinkedStatus), + ]); + (new Collection(static::$customDataResolvers))->each->__invoke(); } + /** + * Determine storage symbolic links status. + * + * @param callable $formatStorageLinkedStatus + * @return array + */ + protected function determineStoragePathLinkStatus(callable $formatStorageLinkedStatus): array + { + return (new Collection(config('filesystems.links', []))) + ->mapWithKeys(function ($target, $link) use ($formatStorageLinkedStatus) { + $path = Str::replace(public_path(), '', $link); + + return [public_path($path) => static::format(file_exists($link), console: $formatStorageLinkedStatus)]; + }) + ->toArray(); + } + /** * Determine whether the given directory has PHP files. * diff --git a/src/Illuminate/Foundation/Console/ApiInstallCommand.php b/src/Illuminate/Foundation/Console/ApiInstallCommand.php index aeec5c0..9c46055 100644 --- a/src/Illuminate/Foundation/Console/ApiInstallCommand.php +++ b/src/Illuminate/Foundation/Console/ApiInstallCommand.php @@ -110,7 +110,7 @@ protected function uncommentApiRoutesFile() $appBootstrapPath, ); } else { - $this->components->warn('Unable to automatically add API route definition to bootstrap file. API route file should be registered manually.'); + $this->components->warn("Unable to automatically add API route definition to [{$appBootstrapPath}]. API route file should be registered manually."); return; } diff --git a/src/Illuminate/Foundation/Console/CastMakeCommand.php b/src/Illuminate/Foundation/Console/CastMakeCommand.php index 9552472..b262b40 100644 --- a/src/Illuminate/Foundation/Console/CastMakeCommand.php +++ b/src/Illuminate/Foundation/Console/CastMakeCommand.php @@ -38,8 +38,8 @@ class CastMakeCommand extends GeneratorCommand protected function getStub() { return $this->option('inbound') - ? $this->resolveStubPath('/stubs/cast.inbound.stub') - : $this->resolveStubPath('/stubs/cast.stub'); + ? $this->resolveStubPath('/stubs/cast.inbound.stub') + : $this->resolveStubPath('/stubs/cast.stub'); } /** diff --git a/src/Illuminate/Foundation/Console/CliDumper.php b/src/Illuminate/Foundation/Console/CliDumper.php index 6f5fd9a..44cddcb 100644 --- a/src/Illuminate/Foundation/Console/CliDumper.php +++ b/src/Illuminate/Foundation/Console/CliDumper.php @@ -48,7 +48,6 @@ class CliDumper extends BaseCliDumper * @param \Symfony\Component\Console\Output\OutputInterface $output * @param string $basePath * @param string $compiledViewPath - * @return void */ public function __construct($output, $basePath, $compiledViewPath) { diff --git a/src/Illuminate/Foundation/Console/ClosureCommand.php b/src/Illuminate/Foundation/Console/ClosureCommand.php index 2c2eaf4..a9817d4 100644 --- a/src/Illuminate/Foundation/Console/ClosureCommand.php +++ b/src/Illuminate/Foundation/Console/ClosureCommand.php @@ -30,7 +30,6 @@ class ClosureCommand extends Command * * @param string $signature * @param \Closure $callback - * @return void */ public function __construct($signature, Closure $callback) { diff --git a/src/Illuminate/Foundation/Console/ComponentMakeCommand.php b/src/Illuminate/Foundation/Console/ComponentMakeCommand.php index 4c2f2ea..221ef95 100644 --- a/src/Illuminate/Foundation/Console/ComponentMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ComponentMakeCommand.php @@ -154,8 +154,8 @@ protected function getStub() protected function resolveStubPath($stub) { return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) - ? $customPath - : __DIR__.$stub; + ? $customPath + : __DIR__.$stub; } /** diff --git a/src/Illuminate/Foundation/Console/ConfigCacheCommand.php b/src/Illuminate/Foundation/Console/ConfigCacheCommand.php index 1de90e9..6cef338 100644 --- a/src/Illuminate/Foundation/Console/ConfigCacheCommand.php +++ b/src/Illuminate/Foundation/Console/ConfigCacheCommand.php @@ -37,7 +37,6 @@ class ConfigCacheCommand extends Command * Create a new config cache command instance. * * @param \Illuminate\Filesystem\Filesystem $files - * @return void */ public function __construct(Filesystem $files) { diff --git a/src/Illuminate/Foundation/Console/ConfigClearCommand.php b/src/Illuminate/Foundation/Console/ConfigClearCommand.php index 47a9782..e88e243 100644 --- a/src/Illuminate/Foundation/Console/ConfigClearCommand.php +++ b/src/Illuminate/Foundation/Console/ConfigClearCommand.php @@ -34,7 +34,6 @@ class ConfigClearCommand extends Command * Create a new config clear command instance. * * @param \Illuminate\Filesystem\Filesystem $files - * @return void */ public function __construct(Filesystem $files) { diff --git a/src/Illuminate/Foundation/Console/EnumMakeCommand.php b/src/Illuminate/Foundation/Console/EnumMakeCommand.php index a7cfb87..fab08bb 100644 --- a/src/Illuminate/Foundation/Console/EnumMakeCommand.php +++ b/src/Illuminate/Foundation/Console/EnumMakeCommand.php @@ -57,8 +57,8 @@ protected function getStub() protected function resolveStubPath($stub) { return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) - ? $customPath - : __DIR__.$stub; + ? $customPath + : __DIR__.$stub; } /** diff --git a/src/Illuminate/Foundation/Console/EnvironmentDecryptCommand.php b/src/Illuminate/Foundation/Console/EnvironmentDecryptCommand.php index 37829f0..1146489 100644 --- a/src/Illuminate/Foundation/Console/EnvironmentDecryptCommand.php +++ b/src/Illuminate/Foundation/Console/EnvironmentDecryptCommand.php @@ -46,7 +46,6 @@ class EnvironmentDecryptCommand extends Command * Create a new command instance. * * @param \Illuminate\Filesystem\Filesystem $files - * @return void */ public function __construct(Filesystem $files) { @@ -77,8 +76,8 @@ public function handle() $key = $this->parseKey($key); $encryptedFile = ($this->option('env') - ? Str::finish(dirname($this->laravel->environmentFilePath()), DIRECTORY_SEPARATOR).'.env.'.$this->option('env') - : $this->laravel->environmentFilePath()).'.encrypted'; + ? Str::finish(dirname($this->laravel->environmentFilePath()), DIRECTORY_SEPARATOR).'.env.'.$this->option('env') + : $this->laravel->environmentFilePath()).'.encrypted'; $outputFile = $this->outputFilePath(); diff --git a/src/Illuminate/Foundation/Console/EnvironmentEncryptCommand.php b/src/Illuminate/Foundation/Console/EnvironmentEncryptCommand.php index 03cafa9..a66d18f 100644 --- a/src/Illuminate/Foundation/Console/EnvironmentEncryptCommand.php +++ b/src/Illuminate/Foundation/Console/EnvironmentEncryptCommand.php @@ -45,7 +45,6 @@ class EnvironmentEncryptCommand extends Command * Create a new command instance. * * @param \Illuminate\Filesystem\Filesystem $files - * @return void */ public function __construct(Filesystem $files) { @@ -83,8 +82,8 @@ public function handle() $keyPassed = $key !== null; $environmentFile = $this->option('env') - ? Str::finish(dirname($this->laravel->environmentFilePath()), DIRECTORY_SEPARATOR).'.env.'.$this->option('env') - : $this->laravel->environmentFilePath(); + ? Str::finish(dirname($this->laravel->environmentFilePath()), DIRECTORY_SEPARATOR).'.env.'.$this->option('env') + : $this->laravel->environmentFilePath(); $encryptedFile = $environmentFile.'.encrypted'; diff --git a/src/Illuminate/Foundation/Console/EventClearCommand.php b/src/Illuminate/Foundation/Console/EventClearCommand.php index 966a18b..61c5033 100644 --- a/src/Illuminate/Foundation/Console/EventClearCommand.php +++ b/src/Illuminate/Foundation/Console/EventClearCommand.php @@ -34,7 +34,6 @@ class EventClearCommand extends Command * Create a new config clear command instance. * * @param \Illuminate\Filesystem\Filesystem $files - * @return void */ public function __construct(Filesystem $files) { diff --git a/src/Illuminate/Foundation/Console/EventMakeCommand.php b/src/Illuminate/Foundation/Console/EventMakeCommand.php index cdecc89..515c6fb 100644 --- a/src/Illuminate/Foundation/Console/EventMakeCommand.php +++ b/src/Illuminate/Foundation/Console/EventMakeCommand.php @@ -61,8 +61,8 @@ protected function getStub() protected function resolveStubPath($stub) { return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) - ? $customPath - : __DIR__.$stub; + ? $customPath + : __DIR__.$stub; } /** diff --git a/src/Illuminate/Foundation/Console/JobMakeCommand.php b/src/Illuminate/Foundation/Console/JobMakeCommand.php index 39236c8..9f0f1b0 100644 --- a/src/Illuminate/Foundation/Console/JobMakeCommand.php +++ b/src/Illuminate/Foundation/Console/JobMakeCommand.php @@ -41,8 +41,8 @@ class JobMakeCommand extends GeneratorCommand protected function getStub() { return $this->option('sync') - ? $this->resolveStubPath('/stubs/job.stub') - : $this->resolveStubPath('/stubs/job.queued.stub'); + ? $this->resolveStubPath('/stubs/job.stub') + : $this->resolveStubPath('/stubs/job.queued.stub'); } /** @@ -54,8 +54,8 @@ protected function getStub() protected function resolveStubPath($stub) { return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) - ? $customPath - : __DIR__.$stub; + ? $customPath + : __DIR__.$stub; } /** diff --git a/src/Illuminate/Foundation/Console/JobMiddlewareMakeCommand.php b/src/Illuminate/Foundation/Console/JobMiddlewareMakeCommand.php index b3ccf8e..5f94b83 100644 --- a/src/Illuminate/Foundation/Console/JobMiddlewareMakeCommand.php +++ b/src/Illuminate/Foundation/Console/JobMiddlewareMakeCommand.php @@ -52,8 +52,8 @@ protected function getStub() protected function resolveStubPath($stub) { return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) - ? $customPath - : __DIR__.$stub; + ? $customPath + : __DIR__.$stub; } /** diff --git a/src/Illuminate/Foundation/Console/Kernel.php b/src/Illuminate/Foundation/Console/Kernel.php index b23dd9d..a6710f3 100644 --- a/src/Illuminate/Foundation/Console/Kernel.php +++ b/src/Illuminate/Foundation/Console/Kernel.php @@ -131,7 +131,6 @@ class Kernel implements KernelContract * * @param \Illuminate\Contracts\Foundation\Application $app * @param \Illuminate\Contracts\Events\Dispatcher $events - * @return void */ public function __construct(Application $app, Dispatcher $events) { @@ -163,13 +162,13 @@ public function rerouteSymfonyCommandEvents() $this->symfonyDispatcher->addListener(ConsoleEvents::COMMAND, function (ConsoleCommandEvent $event) { $this->events->dispatch( - new CommandStarting($event->getCommand()->getName(), $event->getInput(), $event->getOutput()) + 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()) + new CommandFinished($event->getCommand()?->getName() ?? '', $event->getInput(), $event->getOutput(), $event->getExitCode()) ); }); } diff --git a/src/Illuminate/Foundation/Console/ListenerMakeCommand.php b/src/Illuminate/Foundation/Console/ListenerMakeCommand.php index d5589ec..a2d2dfa 100644 --- a/src/Illuminate/Foundation/Console/ListenerMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ListenerMakeCommand.php @@ -74,8 +74,8 @@ protected function buildClass($name) protected function resolveStubPath($stub) { return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) - ? $customPath - : __DIR__.$stub; + ? $customPath + : __DIR__.$stub; } /** @@ -87,13 +87,13 @@ protected function getStub() { if ($this->option('queued')) { return $this->option('event') - ? $this->resolveStubPath('/stubs/listener.typed.queued.stub') - : $this->resolveStubPath('/stubs/listener.queued.stub'); + ? $this->resolveStubPath('/stubs/listener.typed.queued.stub') + : $this->resolveStubPath('/stubs/listener.queued.stub'); } return $this->option('event') - ? $this->resolveStubPath('/stubs/listener.typed.stub') - : $this->resolveStubPath('/stubs/listener.stub'); + ? $this->resolveStubPath('/stubs/listener.typed.stub') + : $this->resolveStubPath('/stubs/listener.stub'); } /** diff --git a/src/Illuminate/Foundation/Console/ModelMakeCommand.php b/src/Illuminate/Foundation/Console/ModelMakeCommand.php index 743fd17..5fd029b 100644 --- a/src/Illuminate/Foundation/Console/ModelMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ModelMakeCommand.php @@ -211,8 +211,8 @@ protected function getStub() protected function resolveStubPath($stub) { return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) - ? $customPath - : __DIR__.$stub; + ? $customPath + : __DIR__.$stub; } /** diff --git a/src/Illuminate/Foundation/Console/PolicyMakeCommand.php b/src/Illuminate/Foundation/Console/PolicyMakeCommand.php index a48eefe..521c135 100644 --- a/src/Illuminate/Foundation/Console/PolicyMakeCommand.php +++ b/src/Illuminate/Foundation/Console/PolicyMakeCommand.php @@ -161,8 +161,8 @@ protected function replaceModel($stub, $model) protected function getStub() { return $this->option('model') - ? $this->resolveStubPath('/stubs/policy.stub') - : $this->resolveStubPath('/stubs/policy.plain.stub'); + ? $this->resolveStubPath('/stubs/policy.stub') + : $this->resolveStubPath('/stubs/policy.plain.stub'); } /** @@ -174,8 +174,8 @@ protected function getStub() protected function resolveStubPath($stub) { return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) - ? $customPath - : __DIR__.$stub; + ? $customPath + : __DIR__.$stub; } /** diff --git a/src/Illuminate/Foundation/Console/QueuedCommand.php b/src/Illuminate/Foundation/Console/QueuedCommand.php index 43848cc..eef9cac 100644 --- a/src/Illuminate/Foundation/Console/QueuedCommand.php +++ b/src/Illuminate/Foundation/Console/QueuedCommand.php @@ -22,7 +22,6 @@ class QueuedCommand implements ShouldQueue * Create a new job instance. * * @param array $data - * @return void */ public function __construct($data) { diff --git a/src/Illuminate/Foundation/Console/RequestMakeCommand.php b/src/Illuminate/Foundation/Console/RequestMakeCommand.php index ad02e29..a60b0c6 100644 --- a/src/Illuminate/Foundation/Console/RequestMakeCommand.php +++ b/src/Illuminate/Foundation/Console/RequestMakeCommand.php @@ -49,8 +49,8 @@ protected function getStub() protected function resolveStubPath($stub) { return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) - ? $customPath - : __DIR__.$stub; + ? $customPath + : __DIR__.$stub; } /** diff --git a/src/Illuminate/Foundation/Console/ResourceMakeCommand.php b/src/Illuminate/Foundation/Console/ResourceMakeCommand.php index e8fd022..51d9612 100644 --- a/src/Illuminate/Foundation/Console/ResourceMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ResourceMakeCommand.php @@ -52,8 +52,8 @@ public function handle() protected function getStub() { return $this->collection() - ? $this->resolveStubPath('/stubs/resource-collection.stub') - : $this->resolveStubPath('/stubs/resource.stub'); + ? $this->resolveStubPath('/stubs/resource-collection.stub') + : $this->resolveStubPath('/stubs/resource.stub'); } /** @@ -76,8 +76,8 @@ protected function collection() protected function resolveStubPath($stub) { return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) - ? $customPath - : __DIR__.$stub; + ? $customPath + : __DIR__.$stub; } /** diff --git a/src/Illuminate/Foundation/Console/RouteCacheCommand.php b/src/Illuminate/Foundation/Console/RouteCacheCommand.php index 0aa2194..9b8632a 100644 --- a/src/Illuminate/Foundation/Console/RouteCacheCommand.php +++ b/src/Illuminate/Foundation/Console/RouteCacheCommand.php @@ -36,7 +36,6 @@ class RouteCacheCommand extends Command * Create a new route command instance. * * @param \Illuminate\Filesystem\Filesystem $files - * @return void */ public function __construct(Filesystem $files) { diff --git a/src/Illuminate/Foundation/Console/RouteClearCommand.php b/src/Illuminate/Foundation/Console/RouteClearCommand.php index c496b10..b077f82 100644 --- a/src/Illuminate/Foundation/Console/RouteClearCommand.php +++ b/src/Illuminate/Foundation/Console/RouteClearCommand.php @@ -34,7 +34,6 @@ class RouteClearCommand extends Command * Create a new route clear command instance. * * @param \Illuminate\Filesystem\Filesystem $files - * @return void */ public function __construct(Filesystem $files) { diff --git a/src/Illuminate/Foundation/Console/RouteListCommand.php b/src/Illuminate/Foundation/Console/RouteListCommand.php index 104bff7..36813d8 100644 --- a/src/Illuminate/Foundation/Console/RouteListCommand.php +++ b/src/Illuminate/Foundation/Console/RouteListCommand.php @@ -76,7 +76,6 @@ class RouteListCommand extends Command * Create a new route command instance. * * @param \Illuminate\Routing\Router $router - * @return void */ public function __construct(Router $router) { @@ -114,9 +113,10 @@ public function handle() */ protected function getRoutes() { - $routes = (new Collection($this->router->getRoutes()))->map(function ($route) { - return $this->getRouteInformation($route); - })->filter()->all(); + $routes = (new Collection($this->router->getRoutes())) + ->map(fn ($route) => $this->getRouteInformation($route)) + ->filter() + ->all(); if (($sort = $this->option('sort')) !== null) { $routes = $this->sortRoutes($sort, $routes); @@ -208,9 +208,9 @@ protected function displayRoutes(array $routes) */ protected function getMiddleware($route) { - return (new Collection($this->router->gatherRouteMiddleware($route)))->map(function ($middleware) { - return $middleware instanceof Closure ? 'Closure' : $middleware; - })->implode("\n"); + return (new Collection($this->router->gatherRouteMiddleware($route))) + ->map(fn ($middleware) => $middleware instanceof Closure ? 'Closure' : $middleware) + ->implode("\n"); } /** @@ -301,7 +301,7 @@ protected function getHeaders() */ protected function getColumns() { - return array_map('strtolower', $this->headers); + return array_map(strtolower(...), $this->headers); } /** @@ -322,7 +322,7 @@ protected function parseColumns(array $columns) } } - return array_map('strtolower', $results); + return array_map(strtolower(...), $results); } /** diff --git a/src/Illuminate/Foundation/Console/TestMakeCommand.php b/src/Illuminate/Foundation/Console/TestMakeCommand.php index 8544058..e24766a 100644 --- a/src/Illuminate/Foundation/Console/TestMakeCommand.php +++ b/src/Illuminate/Foundation/Console/TestMakeCommand.php @@ -58,8 +58,8 @@ protected function getStub() protected function resolveStubPath($stub) { return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) - ? $customPath - : __DIR__.$stub; + ? $customPath + : __DIR__.$stub; } /** diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index 3921c9c..1ccab52 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -79,7 +79,6 @@ class VendorPublishCommand extends Command * Create a new command instance. * * @param \Illuminate\Filesystem\Filesystem $files - * @return void */ public function __construct(Filesystem $files) { diff --git a/src/Illuminate/Foundation/Console/ViewClearCommand.php b/src/Illuminate/Foundation/Console/ViewClearCommand.php index 9cb58e2..ec942bd 100644 --- a/src/Illuminate/Foundation/Console/ViewClearCommand.php +++ b/src/Illuminate/Foundation/Console/ViewClearCommand.php @@ -35,7 +35,6 @@ class ViewClearCommand extends Command * Create a new config clear command instance. * * @param \Illuminate\Filesystem\Filesystem $files - * @return void */ public function __construct(Filesystem $files) { diff --git a/src/Illuminate/Foundation/Console/ViewMakeCommand.php b/src/Illuminate/Foundation/Console/ViewMakeCommand.php index afd21e9..c066750 100644 --- a/src/Illuminate/Foundation/Console/ViewMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ViewMakeCommand.php @@ -104,8 +104,8 @@ protected function getStub() protected function resolveStubPath($stub) { return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) - ? $customPath - : __DIR__.$stub; + ? $customPath + : __DIR__.$stub; } /** diff --git a/src/Illuminate/Foundation/Console/stubs/class.invokable.stub b/src/Illuminate/Foundation/Console/stubs/class.invokable.stub index c55610c..b1e93cb 100644 --- a/src/Illuminate/Foundation/Console/stubs/class.invokable.stub +++ b/src/Illuminate/Foundation/Console/stubs/class.invokable.stub @@ -17,6 +17,6 @@ class {{ class }} */ public function __invoke(): void { - + // } } diff --git a/src/Illuminate/Foundation/Console/stubs/notification.stub b/src/Illuminate/Foundation/Console/stubs/notification.stub index e573dcd..ee32826 100644 --- a/src/Illuminate/Foundation/Console/stubs/notification.stub +++ b/src/Illuminate/Foundation/Console/stubs/notification.stub @@ -35,9 +35,9 @@ class {{ class }} extends Notification public function toMail(object $notifiable): MailMessage { return (new MailMessage) - ->line('The introduction to the notification.') - ->action('Notification Action', url('/')) - ->line('Thank you for using our application!'); + ->line('The introduction to the notification.') + ->action('Notification Action', url('/')) + ->line('Thank you for using our application!'); } /** diff --git a/src/Illuminate/Foundation/Events/LocaleUpdated.php b/src/Illuminate/Foundation/Events/LocaleUpdated.php index 0a932be..c46d33c 100644 --- a/src/Illuminate/Foundation/Events/LocaleUpdated.php +++ b/src/Illuminate/Foundation/Events/LocaleUpdated.php @@ -15,7 +15,6 @@ class LocaleUpdated * Create a new event instance. * * @param string $locale - * @return void */ public function __construct($locale) { diff --git a/src/Illuminate/Foundation/Events/PublishingStubs.php b/src/Illuminate/Foundation/Events/PublishingStubs.php index 914ff1e..8543279 100644 --- a/src/Illuminate/Foundation/Events/PublishingStubs.php +++ b/src/Illuminate/Foundation/Events/PublishingStubs.php @@ -17,7 +17,6 @@ class PublishingStubs * Create a new event instance. * * @param array $stubs - * @return void */ public function __construct(array $stubs) { diff --git a/src/Illuminate/Foundation/Events/VendorTagPublished.php b/src/Illuminate/Foundation/Events/VendorTagPublished.php index 084c129..05acc79 100644 --- a/src/Illuminate/Foundation/Events/VendorTagPublished.php +++ b/src/Illuminate/Foundation/Events/VendorTagPublished.php @@ -23,7 +23,6 @@ class VendorTagPublished * * @param string $tag * @param array $paths - * @return void */ public function __construct($tag, $paths) { diff --git a/src/Illuminate/Foundation/Exceptions/Handler.php b/src/Illuminate/Foundation/Exceptions/Handler.php index 2f381d1..00a6926 100644 --- a/src/Illuminate/Foundation/Exceptions/Handler.php +++ b/src/Illuminate/Foundation/Exceptions/Handler.php @@ -184,7 +184,6 @@ class Handler implements ExceptionHandlerContract * Create a new exception handler instance. * * @param \Illuminate\Contracts\Container\Container $container - * @return void */ public function __construct(Container $container) { @@ -424,7 +423,7 @@ protected function shouldntReport(Throwable $e) } return ! $this->container->make(RateLimiter::class)->attempt( - with($throttle->key ?: 'illuminate:foundation:exceptions:'.$e::class, fn ($key) => $this->hashThrottleKeys ? md5($key) : $key), + with($throttle->key ?: 'illuminate:foundation:exceptions:'.$e::class, fn ($key) => $this->hashThrottleKeys ? hash('xxh128', $key) : $key), $throttle->maxAttempts, fn () => true, $throttle->decaySeconds @@ -483,10 +482,14 @@ public function stopIgnoring(array|string $exceptions) $exceptions = Arr::wrap($exceptions); $this->dontReport = (new Collection($this->dontReport)) - ->reject(fn ($ignored) => in_array($ignored, $exceptions))->values()->all(); + ->reject(fn ($ignored) => in_array($ignored, $exceptions)) + ->values() + ->all(); $this->internalDontReport = (new Collection($this->internalDontReport)) - ->reject(fn ($ignored) => in_array($ignored, $exceptions))->values()->all(); + ->reject(fn ($ignored) => in_array($ignored, $exceptions)) + ->values() + ->all(); return $this; } @@ -702,8 +705,8 @@ protected function renderViaCallbacks($request, Throwable $e) protected function renderExceptionResponse($request, Throwable $e) { return $this->shouldReturnJson($request, $e) - ? $this->prepareJsonResponse($request, $e) - : $this->prepareResponse($request, $e); + ? $this->prepareJsonResponse($request, $e) + : $this->prepareResponse($request, $e); } /** @@ -716,8 +719,8 @@ protected function renderExceptionResponse($request, Throwable $e) protected function unauthenticated($request, AuthenticationException $exception) { return $this->shouldReturnJson($request, $exception) - ? response()->json(['message' => $exception->getMessage()], 401) - : redirect()->guest($exception->redirectTo($request) ?? route('login')); + ? response()->json(['message' => $exception->getMessage()], 401) + : redirect()->guest($exception->redirectTo($request) ?? route('login')); } /** @@ -734,8 +737,8 @@ protected function convertValidationExceptionToResponse(ValidationException $e, } return $this->shouldReturnJson($request, $e) - ? $this->invalidJson($request, $e) - : $this->invalid($request, $e); + ? $this->invalidJson($request, $e) + : $this->invalid($request, $e); } /** diff --git a/src/Illuminate/Foundation/Exceptions/Renderer/Exception.php b/src/Illuminate/Foundation/Exceptions/Renderer/Exception.php index 3c562e0..eb65929 100644 --- a/src/Illuminate/Foundation/Exceptions/Renderer/Exception.php +++ b/src/Illuminate/Foundation/Exceptions/Renderer/Exception.php @@ -47,7 +47,6 @@ class Exception * @param \Illuminate\Http\Request $request * @param \Illuminate\Foundation\Exceptions\Renderer\Listener $listener * @param string $basePath - * @return void */ public function __construct(FlattenException $exception, Request $request, Listener $listener, string $basePath) { diff --git a/src/Illuminate/Foundation/Exceptions/Renderer/Frame.php b/src/Illuminate/Foundation/Exceptions/Renderer/Frame.php index ac331d7..efd6d7a 100644 --- a/src/Illuminate/Foundation/Exceptions/Renderer/Frame.php +++ b/src/Illuminate/Foundation/Exceptions/Renderer/Frame.php @@ -44,7 +44,6 @@ class Frame * @param array $classMap * @param array{file: string, line: int, class?: string, type?: string, function?: string} $frame * @param string $basePath - * @return void */ public function __construct(FlattenException $exception, array $classMap, array $frame, string $basePath) { diff --git a/src/Illuminate/Foundation/Exceptions/Renderer/Listener.php b/src/Illuminate/Foundation/Exceptions/Renderer/Listener.php index 325fad4..d5a71b7 100644 --- a/src/Illuminate/Foundation/Exceptions/Renderer/Listener.php +++ b/src/Illuminate/Foundation/Exceptions/Renderer/Listener.php @@ -28,7 +28,7 @@ class Listener */ public function registerListeners(Dispatcher $events) { - $events->listen(QueryExecuted::class, [$this, 'onQueryExecuted']); + $events->listen(QueryExecuted::class, $this->onQueryExecuted(...)); $events->listen([JobProcessing::class, JobProcessed::class], function () { $this->queries = []; diff --git a/src/Illuminate/Foundation/Exceptions/Renderer/Mappers/BladeMapper.php b/src/Illuminate/Foundation/Exceptions/Renderer/Mappers/BladeMapper.php index 25b6b71..a235812 100644 --- a/src/Illuminate/Foundation/Exceptions/Renderer/Mappers/BladeMapper.php +++ b/src/Illuminate/Foundation/Exceptions/Renderer/Mappers/BladeMapper.php @@ -63,7 +63,6 @@ class BladeMapper * * @param \Illuminate\Contracts\View\Factory $factory * @param \Illuminate\View\Compilers\BladeCompiler $bladeCompiler - * @return void */ public function __construct(Factory $factory, BladeCompiler $bladeCompiler) { diff --git a/src/Illuminate/Foundation/Exceptions/Renderer/Renderer.php b/src/Illuminate/Foundation/Exceptions/Renderer/Renderer.php index 6772ae1..514be71 100644 --- a/src/Illuminate/Foundation/Exceptions/Renderer/Renderer.php +++ b/src/Illuminate/Foundation/Exceptions/Renderer/Renderer.php @@ -61,7 +61,6 @@ class Renderer * @param \Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer $htmlErrorRenderer * @param \Illuminate\Foundation\Exceptions\Renderer\Mappers\BladeMapper $bladeMapper * @param string $basePath - * @return void */ public function __construct( Factory $viewFactory, diff --git a/src/Illuminate/Foundation/Exceptions/ReportableHandler.php b/src/Illuminate/Foundation/Exceptions/ReportableHandler.php index 06a6172..f719365 100644 --- a/src/Illuminate/Foundation/Exceptions/ReportableHandler.php +++ b/src/Illuminate/Foundation/Exceptions/ReportableHandler.php @@ -27,7 +27,6 @@ class ReportableHandler * Create a new reportable handler instance. * * @param callable $callback - * @return void */ public function __construct(callable $callback) { diff --git a/src/Illuminate/Foundation/Http/Events/RequestHandled.php b/src/Illuminate/Foundation/Http/Events/RequestHandled.php index d6f71e0..3e99cb8 100644 --- a/src/Illuminate/Foundation/Http/Events/RequestHandled.php +++ b/src/Illuminate/Foundation/Http/Events/RequestHandled.php @@ -23,7 +23,6 @@ class RequestHandled * * @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Response $response - * @return void */ public function __construct($request, $response) { diff --git a/src/Illuminate/Foundation/Http/FormRequest.php b/src/Illuminate/Foundation/Http/FormRequest.php index edff303..b5beb3a 100644 --- a/src/Illuminate/Foundation/Http/FormRequest.php +++ b/src/Illuminate/Foundation/Http/FormRequest.php @@ -86,7 +86,7 @@ protected function getValidatorInstance() $factory = $this->container->make(ValidationFactory::class); if (method_exists($this, 'validator')) { - $validator = $this->container->call([$this, 'validator'], compact('factory')); + $validator = $this->container->call($this->validator(...), compact('factory')); } else { $validator = $this->createDefaultValidator($factory); } @@ -229,8 +229,8 @@ protected function failedAuthorization() public function safe(?array $keys = null) { return is_array($keys) - ? $this->validator->safe()->only($keys) - : $this->validator->safe(); + ? $this->validator->safe()->only($keys) + : $this->validator->safe(); } /** diff --git a/src/Illuminate/Foundation/Http/HtmlDumper.php b/src/Illuminate/Foundation/Http/HtmlDumper.php index 2df0901..72663f0 100644 --- a/src/Illuminate/Foundation/Http/HtmlDumper.php +++ b/src/Illuminate/Foundation/Http/HtmlDumper.php @@ -53,7 +53,6 @@ class HtmlDumper extends BaseHtmlDumper * * @param string $basePath * @param string $compiledViewPath - * @return void */ public function __construct($basePath, $compiledViewPath) { diff --git a/src/Illuminate/Foundation/Http/Kernel.php b/src/Illuminate/Foundation/Http/Kernel.php index 02c0f3f..83a5ae4 100644 --- a/src/Illuminate/Foundation/Http/Kernel.php +++ b/src/Illuminate/Foundation/Http/Kernel.php @@ -119,7 +119,6 @@ class Kernel implements KernelContract * * @param \Illuminate\Contracts\Foundation\Application $app * @param \Illuminate\Routing\Router $router - * @return void */ public function __construct(Application $app, Router $router) { diff --git a/src/Illuminate/Foundation/Http/Middleware/HandlePrecognitiveRequests.php b/src/Illuminate/Foundation/Http/Middleware/HandlePrecognitiveRequests.php index 32819c4..c13e2bf 100644 --- a/src/Illuminate/Foundation/Http/Middleware/HandlePrecognitiveRequests.php +++ b/src/Illuminate/Foundation/Http/Middleware/HandlePrecognitiveRequests.php @@ -21,7 +21,6 @@ class HandlePrecognitiveRequests * Create a new middleware instance. * * @param \Illuminate\Container\Container $container - * @return void */ public function __construct(Container $container) { diff --git a/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php b/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php index 6adb87d..1c20d22 100644 --- a/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php +++ b/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php @@ -39,7 +39,6 @@ class PreventRequestsDuringMaintenance * Create a new middleware instance. * * @param \Illuminate\Contracts\Foundation\Application $app - * @return void */ public function __construct(Application $app) { @@ -83,8 +82,8 @@ public function handle($request, Closure $next) if (isset($data['redirect'])) { $path = $data['redirect'] === '/' - ? $data['redirect'] - : trim($data['redirect'], '/'); + ? $data['redirect'] + : trim($data['redirect'], '/'); if ($request->path() !== $path) { return redirect($path); diff --git a/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php b/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php index 5edc53d..7a47b4f 100644 --- a/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php +++ b/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php @@ -60,7 +60,6 @@ class VerifyCsrfToken * * @param \Illuminate\Contracts\Foundation\Application $app * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter - * @return void */ public function __construct(Application $app, Encrypter $encrypter) { diff --git a/src/Illuminate/Foundation/Inspiring.php b/src/Illuminate/Foundation/Inspiring.php index 6b44751..5989149 100644 --- a/src/Illuminate/Foundation/Inspiring.php +++ b/src/Illuminate/Foundation/Inspiring.php @@ -56,9 +56,7 @@ class Inspiring */ public static function quote() { - return static::quotes() - ->map(fn ($quote) => static::formatForConsole($quote)) - ->random(); + return static::formatForConsole(static::quotes()->random()); } /** diff --git a/src/Illuminate/Foundation/PackageManifest.php b/src/Illuminate/Foundation/PackageManifest.php index c569b77..d2494db 100644 --- a/src/Illuminate/Foundation/PackageManifest.php +++ b/src/Illuminate/Foundation/PackageManifest.php @@ -50,7 +50,6 @@ class PackageManifest * @param \Illuminate\Filesystem\Filesystem $files * @param string $basePath * @param string $manifestPath - * @return void */ public function __construct(Filesystem $files, $basePath, $manifestPath) { @@ -88,9 +87,10 @@ public function aliases() */ public function config($key) { - return (new Collection($this->getManifest()))->flatMap(function ($configuration) use ($key) { - return (array) ($configuration[$key] ?? []); - })->filter()->all(); + return (new Collection($this->getManifest())) + ->flatMap(fn ($configuration) => (array) ($configuration[$key] ?? [])) + ->filter() + ->all(); } /** diff --git a/src/Illuminate/Foundation/ProviderRepository.php b/src/Illuminate/Foundation/ProviderRepository.php index 75d382d..df76e05 100644 --- a/src/Illuminate/Foundation/ProviderRepository.php +++ b/src/Illuminate/Foundation/ProviderRepository.php @@ -35,7 +35,6 @@ class ProviderRepository * @param \Illuminate\Contracts\Foundation\Application $app * @param \Illuminate\Filesystem\Filesystem $files * @param string $manifestPath - * @return void */ public function __construct(ApplicationContract $app, Filesystem $files, $manifestPath) { diff --git a/src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php b/src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php index 788d6ed..d507450 100644 --- a/src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php +++ b/src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php @@ -124,8 +124,8 @@ public function getEvents() protected function discoveredEvents() { return $this->shouldDiscoverEvents() - ? $this->discoverEvents() - : []; + ? $this->discoverEvents() + : []; } /** diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithExceptionHandling.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithExceptionHandling.php index d6bcf8f..af1739d 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithExceptionHandling.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithExceptionHandling.php @@ -213,4 +213,31 @@ protected function assertThrows(Closure $test, string|Closure $expectedClass = T return $this; } + + /** + * Assert that the given callback does not throw an exception. + * + * @param \Closure $test + * @return $this + */ + protected function assertDoesntThrow(Closure $test) + { + try { + $test(); + + $thrown = false; + } catch (Throwable $exception) { + $thrown = true; + + $exceptionClass = get_class($exception); + $exceptionMessage = $exception->getMessage(); + } + + Assert::assertTrue( + ! $thrown, + sprintf('Unexpected exception of type %s with message %s was thrown.', $exceptionClass ?? null, $exceptionMessage ?? null) + ); + + return $this; + } } diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTestCaseLifecycle.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTestCaseLifecycle.php index 8191e3f..aad2011 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTestCaseLifecycle.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTestCaseLifecycle.php @@ -170,10 +170,22 @@ protected function tearDownTheTestEnvironment(): void Component::forgetComponentsResolver(); Component::forgetFactory(); ConvertEmptyStringsToNull::flushState(); - Factory::flushState(); - EncryptCookies::flushState(); + + if (class_exists(Factory::class)) { + Factory::flushState(); + } + + + if (class_exists(EncryptCookies::class)) { + EncryptCookies::flushState(); + } + HandleExceptions::flushState(); - Migrator::withoutMigrations([]); + + if (class_exists(Migrator::class)) { + Migrator::withoutMigrations([]); + } + Once::flush(); PreventRequestsDuringMaintenance::flushState(); @@ -184,10 +196,22 @@ protected function tearDownTheTestEnvironment(): void RegisterProviders::flushState(); Sleep::fake(false); TrimStrings::flushState(); - TrustProxies::flushState(); - TrustHosts::flushState(); + + if (class_exists(TrustProxies::class)) { + TrustProxies::flushState(); + } + + + if (class_exists(TrustHosts::class)) { + TrustHosts::flushState(); + } + ValidateCsrfToken::flushState(); - WorkCommand::flushState(); + + if (class_exists(WorkCommand::class)) { + WorkCommand::flushState(); + } + if ($this->callbackException) { throw $this->callbackException; diff --git a/src/Illuminate/Foundation/Testing/DatabaseTransactions.php b/src/Illuminate/Foundation/Testing/DatabaseTransactions.php index f84a23f..0eaa2f0 100644 --- a/src/Illuminate/Foundation/Testing/DatabaseTransactions.php +++ b/src/Illuminate/Foundation/Testing/DatabaseTransactions.php @@ -48,6 +48,7 @@ public function beginDatabaseTransaction() protected function connectionsToTransact() { return property_exists($this, 'connectionsToTransact') - ? $this->connectionsToTransact : [null]; + ? $this->connectionsToTransact + : [null]; } } diff --git a/src/Illuminate/Foundation/Testing/DatabaseTransactionsManager.php b/src/Illuminate/Foundation/Testing/DatabaseTransactionsManager.php index 7ee71d7..4fea491 100644 --- a/src/Illuminate/Foundation/Testing/DatabaseTransactionsManager.php +++ b/src/Illuminate/Foundation/Testing/DatabaseTransactionsManager.php @@ -15,7 +15,6 @@ class DatabaseTransactionsManager extends BaseManager * Create a new database transaction manager instance. * * @param array $connectionsTransacting - * @return void */ public function __construct(array $connectionsTransacting) { diff --git a/src/Illuminate/Foundation/Testing/DatabaseTruncation.php b/src/Illuminate/Foundation/Testing/DatabaseTruncation.php index 2ef1701..9ed0632 100644 --- a/src/Illuminate/Foundation/Testing/DatabaseTruncation.php +++ b/src/Illuminate/Foundation/Testing/DatabaseTruncation.php @@ -4,7 +4,6 @@ use Illuminate\Contracts\Console\Kernel; use Illuminate\Database\ConnectionInterface; -use Illuminate\Database\Schema\PostgresBuilder; use Illuminate\Foundation\Testing\Traits\CanConfigureMigrationCommands; use Illuminate\Support\Collection; @@ -94,14 +93,12 @@ function (Collection $tables, array $tablesToTruncate) { function (Collection $tables) use ($connection, $name) { $exceptTables = $this->exceptTables($connection, $name); - return $tables->filter(fn (array $table) => ! $this->tableExistsIn($table, $exceptTables)); + return $tables->reject(fn (array $table) => $this->tableExistsIn($table, $exceptTables)); } ) ->each(function (array $table) use ($connection) { $connection->withoutTablePrefix(function ($connection) use ($table) { - $table = $connection->table( - $table['schema'] ? $table['schema'].'.'.$table['name'] : $table['name'] - ); + $table = $connection->table($table['schema_qualified_name']); if ($table->exists()) { $table->truncate(); @@ -123,12 +120,7 @@ protected function getAllTablesForConnection(ConnectionInterface $connection, ?s $schema = $connection->getSchemaBuilder(); - return static::$allTables[$name] = (new Collection($schema->getTables()))->when( - $schema instanceof PostgresBuilder ? $schema->getSchemas() : null, - fn (Collection $tables, array $schemas) => $tables->filter( - fn (array $table) => in_array($table['schema'], $schemas) - ) - )->all(); + return static::$allTables[$name] = (new Collection($schema->getTables($schema->getCurrentSchemaListing())))->all(); } /** @@ -137,7 +129,7 @@ protected function getAllTablesForConnection(ConnectionInterface $connection, ?s protected function tableExistsIn(array $table, array $tables): bool { return $table['schema'] - ? ! empty(array_intersect([$table['name'], $table['schema'].'.'.$table['name']], $tables)) + ? ! empty(array_intersect([$table['name'], $table['schema_qualified_name']], $tables)) : in_array($table['name'], $tables); } @@ -149,7 +141,8 @@ protected function tableExistsIn(array $table, array $tables): bool protected function connectionsToTruncate(): array { return property_exists($this, 'connectionsToTruncate') - ? $this->connectionsToTruncate : [null]; + ? $this->connectionsToTruncate + : [null]; } /** diff --git a/src/Illuminate/Foundation/Testing/RefreshDatabase.php b/src/Illuminate/Foundation/Testing/RefreshDatabase.php index 2ef1fd0..f039c51 100644 --- a/src/Illuminate/Foundation/Testing/RefreshDatabase.php +++ b/src/Illuminate/Foundation/Testing/RefreshDatabase.php @@ -18,7 +18,7 @@ public function refreshDatabase() { $this->beforeRefreshingDatabase(); - if ($this->usingInMemoryDatabase()) { + if ($this->usingInMemoryDatabases()) { $this->restoreInMemoryDatabase(); } @@ -28,15 +28,33 @@ public function refreshDatabase() } /** - * Determine if an in-memory database is being used. + * Determine if any of the connections transacting is using in-memory databases. * * @return bool */ - protected function usingInMemoryDatabase() + protected function usingInMemoryDatabases() { - $default = config('database.default'); + foreach ($this->connectionsToTransact() as $name) { + if ($this->usingInMemoryDatabase($name)) { + return true; + } + } - return config("database.connections.$default.database") === ':memory:'; + return false; + } + + /** + * Determine if a given database connection is an in-memory database. + * + * @return bool + */ + protected function usingInMemoryDatabase(?string $name = null) + { + if (is_null($name)) { + $name = config('database.default'); + } + + return config("database.connections.{$name}.database") === ':memory:'; } /** @@ -63,7 +81,7 @@ protected function restoreInMemoryDatabase() protected function refreshTestDatabase() { if (! RefreshDatabaseState::$migrated) { - $this->artisan('migrate:fresh', $this->migrateFreshUsing()); + $this->migrateDatabases(); $this->app[Kernel::class]->setArtisan(null); @@ -73,6 +91,16 @@ protected function refreshTestDatabase() $this->beginDatabaseTransaction(); } + /** + * Migrate the database. + * + * @return void + */ + protected function migrateDatabases() + { + $this->artisan('migrate:fresh', $this->migrateFreshUsing()); + } + /** * Begin a database transaction on the testing database. * @@ -91,7 +119,7 @@ public function beginDatabaseTransaction() $connection->setTransactionManager($transactionsManager); - if ($this->usingInMemoryDatabase()) { + if ($this->usingInMemoryDatabase($name)) { RefreshDatabaseState::$inMemoryConnections[$name] ??= $connection->getPdo(); } @@ -128,7 +156,8 @@ public function beginDatabaseTransaction() protected function connectionsToTransact() { return property_exists($this, 'connectionsToTransact') - ? $this->connectionsToTransact : [null]; + ? $this->connectionsToTransact + : [config('database.default')]; } /** diff --git a/src/Illuminate/Foundation/Testing/Wormhole.php b/src/Illuminate/Foundation/Testing/Wormhole.php index beac013..3bf5d2e 100644 --- a/src/Illuminate/Foundation/Testing/Wormhole.php +++ b/src/Illuminate/Foundation/Testing/Wormhole.php @@ -17,7 +17,6 @@ class Wormhole * Create a new wormhole instance. * * @param int $value - * @return void */ public function __construct($value) { diff --git a/src/Illuminate/Foundation/helpers.php b/src/Illuminate/Foundation/helpers.php index 90fd06f..590ea00 100644 --- a/src/Illuminate/Foundation/helpers.php +++ b/src/Illuminate/Foundation/helpers.php @@ -424,8 +424,8 @@ function defer(?callable $callback = null, ?string $name = null, bool $always = function dispatch($job) { return $job instanceof Closure - ? new PendingClosureDispatch(CallQueuedClosure::create($job)) - : new PendingDispatch($job); + ? new PendingClosureDispatch(CallQueuedClosure::create($job)) + : new PendingDispatch($job); } } diff --git a/src/Illuminate/Foundation/resources/exceptions/renderer/components/trace.blade.php b/src/Illuminate/Foundation/resources/exceptions/renderer/components/trace.blade.php index 1930737..3c0b2dd 100644 --- a/src/Illuminate/Foundation/resources/exceptions/renderer/components/trace.blade.php +++ b/src/Illuminate/Foundation/resources/exceptions/renderer/components/trace.blade.php @@ -69,7 +69,7 @@ class="w-full text-left dark:border-gray-900" - @if (! $frame->isFromVendor() && $exception->frames()->slice($loop->index + 1)->filter(fn ($frame) => ! $frame->isFromVendor())->isEmpty()) + @if (! $frame->isFromVendor() && $exception->frames()->slice($loop->index + 1)->reject(fn ($frame) => $frame->isFromVendor())->isEmpty()) @if ($exception->frames()->slice($loop->index + 1)->count())