Skip to content

Commit

Permalink
⬆ Bump illuminate/foundation to the latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
Log1x committed Jan 28, 2025
1 parent 79a6d3e commit 0cf8c39
Show file tree
Hide file tree
Showing 46 changed files with 602 additions and 307 deletions.
13 changes: 8 additions & 5 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.34.2';
const VERSION = '11.40.0';

/**
* The base path for the Laravel installation.
Expand Down Expand Up @@ -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]),
};
}

Expand Down Expand Up @@ -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);
}
Expand Down
17 changes: 13 additions & 4 deletions src/Illuminate/Foundation/Bootstrap/HandleExceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function bootstrap(Application $app)
}

if (laravel_cloud()) {
$this->configureCloudSocketLogChannel($app);
$this->configureCloudLogging($app);
}
}

Expand Down Expand Up @@ -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,
],
]);
Expand Down
21 changes: 16 additions & 5 deletions src/Illuminate/Foundation/Bus/Dispatchable.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ trait Dispatchable
*/
public static function dispatch(...$arguments)
{
return new PendingDispatch(new static(...$arguments));
return static::newPendingDispatch(new static(...$arguments));
}

/**
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
}
}
21 changes: 20 additions & 1 deletion src/Illuminate/Foundation/Bus/PendingDispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;
}

/**
Expand All @@ -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);
}
}
5 changes: 2 additions & 3 deletions src/Illuminate/Foundation/Concerns/ResolvesDumpSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}',
Expand Down Expand Up @@ -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;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
26 changes: 26 additions & 0 deletions src/Illuminate/Foundation/Configuration/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Closure;
use Illuminate\Foundation\Exceptions\Handler;
use Illuminate\Http\Client\RequestException;
use Illuminate\Support\Arr;

class Exceptions
Expand Down Expand Up @@ -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;
}
}
5 changes: 3 additions & 2 deletions src/Illuminate/Foundation/Configuration/Middleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Illuminate\Routing\Middleware\ValidateSignature;
use Illuminate\Session\Middleware\AuthenticateSession;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;

class Middleware
{
Expand Down Expand Up @@ -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;
}
Expand All @@ -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));

Expand Down
18 changes: 10 additions & 8 deletions src/Illuminate/Foundation/Console/AboutCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')]
Expand Down Expand Up @@ -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];
Expand All @@ -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();
Expand Down Expand Up @@ -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),
]),
];
Expand Down Expand Up @@ -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,
Expand All @@ -212,7 +214,7 @@ protected function gatherApplicationInformation()
'Session' => config('session.driver'),
]));

collect(static::$customDataResolvers)->each->__invoke();
(new Collection(static::$customDataResolvers))->each->__invoke();
}

/**
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}

/**
Expand Down
Loading

0 comments on commit 0cf8c39

Please sign in to comment.