From 4f3c4121d501ce4fdf7b51a0f99ab856050febba Mon Sep 17 00:00:00 2001 From: Caleb White Date: Wed, 8 Jan 2025 12:38:10 -0600 Subject: [PATCH] fix: filter vendor paths from registered loaders in Application::inferBasePath --- src/Illuminate/Foundation/Application.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index c061c731ce69..0188a8c82694 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.37.0'; + public const VERSION = '11.37.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]), }; } @@ -283,7 +286,9 @@ protected function registerBaseBindings() $this->singleton(Mix::class); $this->singleton(PackageManifest::class, fn () => new PackageManifest( - new Filesystem, $this->basePath(), $this->getCachedPackagesPath() + new Filesystem(), + $this->basePath(), + $this->getCachedPackagesPath() )); } @@ -328,7 +333,8 @@ public function bootstrapWith(array $bootstrappers) public function afterLoadingEnvironment(Closure $callback) { $this->afterBootstrapping( - LoadEnvironmentVariables::class, $callback + LoadEnvironmentVariables::class, + $callback ); } @@ -763,7 +769,7 @@ public function detectEnvironment(Closure $callback) ? $_SERVER['argv'] : null; - return $this['env'] = (new EnvironmentDetector)->detect($callback, $args); + return $this['env'] = (new EnvironmentDetector())->detect($callback, $args); } /** @@ -841,7 +847,7 @@ public function registerConfiguredProviders() $providers->splice(1, 0, [$this->make(PackageManifest::class)->providers()]); - (new ProviderRepository($this, new Filesystem, $this->getCachedServicesPath())) + (new ProviderRepository($this, new Filesystem(), $this->getCachedServicesPath())) ->load($providers->collapse()->toArray()); $this->fireAppCallbacks($this->registeredCallbacks); @@ -1204,7 +1210,7 @@ public function handleCommand(InputInterface $input) $status = $kernel->handle( $input, - new ConsoleOutput + new ConsoleOutput() ); $kernel->terminate($input, $status);