Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⬆ Upgrade Foundation to v11.15.0 #384

Merged
merged 4 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"illuminate/queue": "^11.0",
"illuminate/routing": "^11.0",
"illuminate/support": "^11.0",
"illuminate/testing": "^11.0",
"illuminate/validation": "^11.0",
"illuminate/view": "^11.0",
"laravel/prompts": "^0.1.17",
Expand Down
56 changes: 49 additions & 7 deletions src/Illuminate/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Application extends Container implements ApplicationContract, CachesConfig
*
* @var string
*/
const VERSION = '11.1.1';
const VERSION = '11.15.0';

/**
* The base path for the Laravel installation.
Expand Down Expand Up @@ -99,7 +99,7 @@ class Application extends Container implements ApplicationContract, CachesConfig
/**
* All of the registered service providers.
*
* @var \Illuminate\Support\ServiceProvider[]
* @var array<string, \Illuminate\Support\ServiceProvider>
*/
protected $serviceProviders = [];

Expand Down Expand Up @@ -194,6 +194,13 @@ class Application extends Container implements ApplicationContract, CachesConfig
*/
protected $namespace;

/**
* Indicates if the framework's base configuration should be merged.
*
* @var bool
*/
protected $mergeFrameworkConfiguration = true;

/**
* The prefixes of absolute cache paths for use during normalization.
*
Expand Down Expand Up @@ -224,7 +231,7 @@ public function __construct($basePath = null)
* @param string|null $basePath
* @return \Illuminate\Foundation\Configuration\ApplicationBuilder
*/
public static function configure(string $basePath = null)
public static function configure(?string $basePath = null)
{
$basePath = match (true) {
is_string($basePath) => $basePath,
Expand Down Expand Up @@ -591,6 +598,10 @@ public function storagePath($path = '')
return $this->joinPaths($this->storagePath ?: $_ENV['LARAVEL_STORAGE_PATH'], $path);
}

if (isset($_SERVER['LARAVEL_STORAGE_PATH'])) {
return $this->joinPaths($this->storagePath ?: $_SERVER['LARAVEL_STORAGE_PATH'], $path);
}

return $this->joinPaths($this->storagePath ?: $this->basePath('storage'), $path);
}

Expand Down Expand Up @@ -893,7 +904,9 @@ public function register($provider, $force = false)
*/
public function getProvider($provider)
{
return array_values($this->getProviders($provider))[0] ?? null;
$name = is_string($provider) ? $provider : get_class($provider);

return $this->serviceProviders[$name] ?? null;
}

/**
Expand Down Expand Up @@ -928,9 +941,11 @@ public function resolveProvider($provider)
*/
protected function markAsRegistered($provider)
{
$this->serviceProviders[] = $provider;
$class = get_class($provider);

$this->serviceProviders[$class] = $provider;

$this->loadedProviders[get_class($provider)] = true;
$this->loadedProviders[$class] = true;
}

/**
Expand Down Expand Up @@ -1003,6 +1018,8 @@ public function registerDeferredProvider($provider, $service = null)
* @param string $abstract
* @param array $parameters
* @return mixed
*
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
public function make($abstract, array $parameters = [])
{
Expand All @@ -1018,6 +1035,9 @@ public function make($abstract, array $parameters = [])
* @param array $parameters
* @param bool $raiseEvents
* @return mixed
*
* @throws \Illuminate\Contracts\Container\BindingResolutionException
* @throws \Illuminate\Contracts\Container\CircularDependencyException
*/
protected function resolve($abstract, $parameters = [], $raiseEvents = true)
{
Expand Down Expand Up @@ -1190,6 +1210,28 @@ public function handleCommand(InputInterface $input)
return $status;
}

/**
* Determine if the framework's base configuration should be merged.
*
* @return bool
*/
public function shouldMergeFrameworkConfiguration()
{
return $this->mergeFrameworkConfiguration;
}

/**
* Indicate that the framework's base configuration should not be merged.
*
* @return $this
*/
public function dontMergeFrameworkConfiguration()
{
$this->mergeFrameworkConfiguration = false;

return $this;
}

/**
* Determine if middleware has been disabled for the application.
*
Expand Down Expand Up @@ -1384,7 +1426,7 @@ public function terminate()
/**
* Get the service providers that have been loaded.
*
* @return array
* @return array<string, boolean>
*/
public function getLoadedProviders()
{
Expand Down
15 changes: 10 additions & 5 deletions src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Illuminate\Foundation\Bootstrap;

use Exception;
use Illuminate\Config\Repository;
use Illuminate\Contracts\Config\Repository as RepositoryContract;
use Illuminate\Contracts\Foundation\Application;
Expand Down Expand Up @@ -62,11 +61,17 @@ protected function loadConfigurationFiles(Application $app, RepositoryContract $
{
$files = $this->getConfigurationFiles($app);

// if (! isset($files['app'])) {
// throw new Exception('Unable to load the "app" configuration file.');
// }
$shouldMerge = method_exists($app, 'shouldMergeFrameworkConfiguration')
? $app->shouldMergeFrameworkConfiguration()
: true;

$base = $this->getBaseConfiguration();
$base = $shouldMerge
? $this->getBaseConfiguration()
: [];

foreach (array_diff(array_keys($base), array_keys($files)) as $name => $config) {
$repository->set($name, $config);
}

foreach ($files as $name => $path) {
$base = $this->loadConfigurationFile($repository, $name, $path, $base);
Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/Foundation/Bootstrap/RegisterProviders.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Illuminate\Foundation\Bootstrap;

use Illuminate\Contracts\Foundation\Application;
use Illuminate\Support\ServiceProvider;

class RegisterProviders
{
Expand Down Expand Up @@ -57,7 +58,7 @@ protected function mergeAdditionalProviders(Application $app)
$app->make('config')->set(
'app.providers',
array_merge(
$app->make('config')->get('app.providers'),
$app->make('config')->get('app.providers') ?? ServiceProvider::defaultProviders()->toArray(),
static::$merge,
array_values($packageProviders ?? []),
),
Expand Down
56 changes: 38 additions & 18 deletions src/Illuminate/Foundation/Configuration/ApplicationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,19 @@ public function withProviders(array $providers = [], bool $withBootstrapProvider
/**
* Register the core event service provider for the application.
*
* @param array $discover
* @param array|bool $discover
* @return $this
*/
public function withEvents(array $discover = [])
public function withEvents(array|bool $discover = [])
{
if (count($discover) > 0) {
if (is_array($discover) && count($discover) > 0) {
AppEventServiceProvider::setEventDiscoveryPaths($discover);
}

if ($discover === false) {
AppEventServiceProvider::disableEventDiscovery();
}

if (! isset($this->pendingProviders[AppEventServiceProvider::class])) {
$this->app->booting(function () {
$this->app->register(AppEventServiceProvider::class);
Expand All @@ -104,7 +108,7 @@ public function withEvents(array $discover = [])
}

/**
* Register the braodcasting services for the application.
* Register the broadcasting services for the application.
*
* @param string $channels
* @param array $attributes
Expand All @@ -127,8 +131,8 @@ public function withBroadcasting(string $channels, array $attributes = [])
* Register the routing services for the application.
*
* @param \Closure|null $using
* @param string|null $web
* @param string|null $api
* @param array|string|null $web
* @param array|string|null $api
* @param string|null $commands
* @param string|null $channels
* @param string|null $pages
Expand All @@ -137,16 +141,16 @@ public function withBroadcasting(string $channels, array $attributes = [])
* @return $this
*/
public function withRouting(?Closure $using = null,
?string $web = null,
?string $api = null,
array|string|null $web = null,
array|string|null $api = null,
?string $commands = null,
?string $channels = null,
?string $pages = null,
?string $health = null,
string $apiPrefix = 'api',
?callable $then = null)
{
if (is_null($using) && (is_string($web) || is_string($api) || is_string($pages) || is_string($health)) || is_callable($then)) {
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);
}

Expand All @@ -170,24 +174,32 @@ public function withRouting(?Closure $using = null,
/**
* Create the routing callback for the application.
*
* @param string|null $web
* @param string|null $api
* @param array|string|null $web
* @param array|string|null $api
* @param string|null $pages
* @param string|null $health
* @param string $apiPrefix
* @param callable|null $then
* @return \Closure
*/
protected function buildRoutingCallback(?string $web,
?string $api,
protected function buildRoutingCallback(array|string|null $web,
array|string|null $api,
?string $pages,
?string $health,
string $apiPrefix,
?callable $then)
{
return function () use ($web, $api, $pages, $health, $apiPrefix, $then) {
if (is_string($api) && realpath($api) !== false) {
Route::middleware('api')->prefix($apiPrefix)->group($api);
if (is_string($api) || is_array($api)) {
if (is_array($api)) {
foreach ($api as $apiRoute) {
if (realpath($apiRoute) !== false) {
Route::middleware('api')->prefix($apiPrefix)->group($apiRoute);
}
}
} else {
Route::middleware('api')->prefix($apiPrefix)->group($api);
}
}

if (is_string($health)) {
Expand All @@ -198,8 +210,16 @@ protected function buildRoutingCallback(?string $web,
});
}

if (is_string($web) && realpath($web) !== false) {
Route::middleware('web')->group($web);
if (is_string($web) || is_array($web)) {
if (is_array($web)) {
foreach ($web as $webRoute) {
if (realpath($webRoute) !== false) {
Route::middleware('web')->group($webRoute);
}
}
} else {
Route::middleware('web')->group($web);
}
}

if (is_string($pages) &&
Expand Down Expand Up @@ -285,7 +305,7 @@ protected function withCommandRouting(array $paths)
/**
* Register the scheduled tasks for the application.
*
* @param callable(Schedule $schedule): void $callback
* @param callable(\Illuminate\Console\Scheduling\Schedule $schedule): void $callback
* @return $this
*/
public function withSchedule(callable $callback)
Expand Down
16 changes: 6 additions & 10 deletions src/Illuminate/Foundation/Configuration/Middleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ public function replaceInGroup(string $group, string $search, string $replace)
/**
* Modify the middleware in the "web" group.
*
* @param string $group
* @param array|string $append
* @param array|string $prepend
* @param array|string $remove
Expand All @@ -318,7 +317,6 @@ public function web(array|string $append = [], array|string $prepend = [], array
/**
* Modify the middleware in the "api" group.
*
* @param string $group
* @param array|string $append
* @param array|string $prepend
* @param array|string $remove
Expand Down Expand Up @@ -420,9 +418,7 @@ public function getGlobalMiddleware()
]));

$middleware = array_map(function ($middleware) {
return isset($this->replacements[$middleware])
? $this->replacements[$middleware]
: $middleware;
return $this->replacements[$middleware] ?? $middleware;
}, $middleware);

return array_values(array_filter(
Expand Down Expand Up @@ -518,7 +514,7 @@ public function redirectUsersTo(callable|string $redirect)
* @param callable|string $users
* @return $this
*/
public function redirectTo(callable|string $guests = null, callable|string $users = null)
public function redirectTo(callable|string|null $guests = null, callable|string|null $users = null)
{
$guests = is_string($guests) ? fn () => $guests : $guests;
$users = is_string($users) ? fn () => $users : $users;
Expand Down Expand Up @@ -608,15 +604,15 @@ public function trimStrings(array $except = [])
/**
* Indicate that the trusted host middleware should be enabled.
*
* @param array<int, string>|null $at
* @param array<int, string>|(callable(): array<int, string>)|null $at
* @param bool $subdomains
* @return $this
*/
public function trustHosts(array $at = null, bool $subdomains = true)
public function trustHosts(array|callable|null $at = null, bool $subdomains = true)
{
$this->trustHosts = true;

if (is_array($at)) {
if (! is_null($at)) {
TrustHosts::at($at, $subdomains);
}

Expand All @@ -630,7 +626,7 @@ public function trustHosts(array $at = null, bool $subdomains = true)
* @param int|null $headers
* @return $this
*/
public function trustProxies(array|string $at = null, int $headers = null)
public function trustProxies(array|string|null $at = null, ?int $headers = null)
{
if (! is_null($at)) {
TrustProxies::at($at);
Expand Down
Loading
Loading