Skip to content

Commit

Permalink
Merge tag 'v11.36.1'
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Dec 19, 2024
2 parents bf16f38 + df06f51 commit cf340a4
Show file tree
Hide file tree
Showing 112 changed files with 1,048 additions and 208 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"guzzlehttp/uri-template": "^1.0",
"laravel/prompts": "^0.3.0",
"laravel/serializable-closure": "^1.3|^2.0",
"league/commonmark": "^2.2.1",
"league/commonmark": "^2.6",
"league/flysystem": "^3.25.1",
"league/flysystem-local": "^3.25.1",
"league/uri": "^7.5.1",
Expand All @@ -47,7 +47,7 @@
"symfony/console": "^7.0.3",
"symfony/error-handler": "^7.0.3",
"symfony/finder": "^7.0.3",
"symfony/http-foundation": "^7.0.3",
"symfony/http-foundation": "^7.2.0",
"symfony/http-kernel": "^7.0.3",
"symfony/mailer": "^7.0.3",
"symfony/mime": "^7.0.3",
Expand Down
2 changes: 1 addition & 1 deletion config/mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@

'smtp' => [
'transport' => 'smtp',
'scheme' => env('MAIL_SCHEME'),
'url' => env('MAIL_URL'),
'host' => env('MAIL_HOST', '127.0.0.1'),
'port' => env('MAIL_PORT', 2525),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
Expand Down
2 changes: 1 addition & 1 deletion config/session.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
|
*/

'lifetime' => env('SESSION_LIFETIME', 120),
'lifetime' => (int) env('SESSION_LIFETIME', 120),

'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),

Expand Down
20 changes: 17 additions & 3 deletions src/Illuminate/Cache/RedisStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@

use Illuminate\Contracts\Cache\LockProvider;
use Illuminate\Contracts\Redis\Factory as Redis;
use Illuminate\Redis\Connections\PhpRedisClusterConnection;
use Illuminate\Redis\Connections\PhpRedisConnection;
use Illuminate\Redis\Connections\PredisClusterConnection;
use Illuminate\Redis\Connections\PredisConnection;
use Illuminate\Support\LazyCollection;
use Illuminate\Support\Str;

class RedisStore extends TaggableStore implements LockProvider
{
use RetrievesMultipleKeys {
putMany as private putManyAlias;
}

/**
* The Redis factory implementation.
*
Expand Down Expand Up @@ -118,25 +124,33 @@ public function put($key, $value, $seconds)
*/
public function putMany(array $values, $seconds)
{
$connection = $this->connection();

// Cluster connections do not support writing multiple values if the keys hash differently...
if ($connection instanceof PhpRedisClusterConnection ||
$connection instanceof PredisClusterConnection) {
return $this->putManyAlias($values, $seconds);
}

$serializedValues = [];

foreach ($values as $key => $value) {
$serializedValues[$this->prefix.$key] = $this->serialize($value);
}

$this->connection()->multi();
$connection->multi();

$manyResult = null;

foreach ($serializedValues as $key => $value) {
$result = (bool) $this->connection()->setex(
$result = (bool) $connection->setex(
$key, (int) max(1, $seconds), $value
);

$manyResult = is_null($manyResult) ? $result : $result && $manyResult;
}

$this->connection()->exec();
$connection->exec();

return $manyResult ?: false;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Collections/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
*/
function enum_value($value, $default = null)
{
return transform($value, fn ($value) => match (true) {
return match (true) {
$value instanceof \BackedEnum => $value->value,
$value instanceof \UnitEnum => $value->name,

default => $value,
}, $default ?? $value);
default => $value ?? value($default),
};
}
}
5 changes: 2 additions & 3 deletions src/Illuminate/Concurrency/SyncDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Closure;
use Illuminate\Contracts\Concurrency\Driver;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\Defer\DeferredCallback;

Expand All @@ -17,7 +16,7 @@ class SyncDriver implements Driver
*/
public function run(Closure|array $tasks): array
{
return (new Collection(Arr::wrap($tasks)))->map(
return Collection::wrap($tasks)->map(
fn ($task) => $task()
)->all();
}
Expand All @@ -27,6 +26,6 @@ public function run(Closure|array $tasks): array
*/
public function defer(Closure|array $tasks): DeferredCallback
{
return defer(fn () => (new Collection(Arr::wrap($tasks)))->each(fn ($task) => $task()));
return defer(fn () => Collection::wrap($tasks)->each(fn ($task) => $task()));
}
}
4 changes: 2 additions & 2 deletions src/Illuminate/Console/Concerns/CreatesMatchingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Illuminate\Console\Concerns;

use Illuminate\Support\Str;
use Illuminate\Support\Stringable;
use Symfony\Component\Console\Input\InputOption;

trait CreatesMatchingTest
Expand Down Expand Up @@ -37,7 +37,7 @@ protected function handleTestCreation($path)
}

return $this->call('make:test', [
'name' => Str::of($path)->after($this->laravel['path'])->beforeLast('.php')->append('Test')->replace('\\', '/'),
'name' => (new Stringable($path))->after($this->laravel['path'])->beforeLast('.php')->append('Test')->replace('\\', '/'),
'--pest' => $this->option('pest'),
'--phpunit' => $this->option('phpunit'),
]) == 0;
Expand Down
3 changes: 1 addition & 2 deletions src/Illuminate/Console/Concerns/InteractsWithSignals.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Illuminate\Console\Concerns;

use Illuminate\Console\Signals;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;

trait InteractsWithSignals
Expand Down Expand Up @@ -31,7 +30,7 @@ public function trap($signals, $callback)
$this->getApplication()->getSignalRegistry(),
);

(new Collection(Arr::wrap(value($signals))))
Collection::wrap(value($signals))
->each(fn ($signal) => $this->signals->register($signal, $callback));
});
}
Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/Console/QuestionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Illuminate\Console;

use Illuminate\Console\View\Components\TwoColumnDetail;
use Illuminate\Support\Stringable;
use Symfony\Component\Console\Formatter\OutputFormatter;
use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -76,7 +77,7 @@ protected function writePrompt(OutputInterface $output, Question $question): voi
*/
protected function ensureEndsWithPunctuation($string)
{
if (! str($string)->endsWith(['?', ':', '!', '.'])) {
if (! (new Stringable($string))->endsWith(['?', ':', '!', '.'])) {
return "$string:";
}

Expand Down
21 changes: 20 additions & 1 deletion src/Illuminate/Console/Scheduling/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use GuzzleHttp\Client as HttpClient;
use GuzzleHttp\ClientInterface as HttpClientInterface;
use GuzzleHttp\Exception\TransferException;
use Illuminate\Console\Application;
use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Debug\ExceptionHandler;
use Illuminate\Contracts\Mail\Mailer;
Expand Down Expand Up @@ -811,7 +812,8 @@ public function mutexName()
return $mutexNameResolver($this);
}

return 'framework'.DIRECTORY_SEPARATOR.'schedule-'.sha1($this->expression.$this->command);
return 'framework'.DIRECTORY_SEPARATOR.'schedule-'.
sha1($this->expression.$this->normalizeCommand($this->command ?? ''));
}

/**
Expand All @@ -838,4 +840,21 @@ protected function removeMutex()
$this->mutex->forget($this);
}
}

/**
* Format the given command string with a normalized PHP binary path.
*
* @param string $command
* @return string
*/
public static function normalizeCommand($command)
{
return str_replace([
Application::phpBinary(),
Application::artisanBinary(),
], [
'php',
preg_replace("#['\"]#", '', Application::artisanBinary()),
], $command);
}
}
6 changes: 1 addition & 5 deletions src/Illuminate/Console/Scheduling/ScheduleListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Closure;
use Cron\CronExpression;
use DateTimeZone;
use Illuminate\Console\Application;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use Illuminate\Support\Collection;
Expand Down Expand Up @@ -123,10 +122,7 @@ private function listEvent($event, $terminalWidth, $expressionSpacing, $repeatEx
$description = $event->description ?? '';

if (! $this->output->isVerbose()) {
$command = str_replace([Application::phpBinary(), Application::artisanBinary()], [
'php',
preg_replace("#['\"]#", '', Application::artisanBinary()),
], $command);
$command = $event->normalizeCommand($command);
}

if ($event instanceof CallbackEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Illuminate\Console\View\Components\Mutators;

use Illuminate\Support\Stringable;

class EnsureNoPunctuation
{
/**
Expand All @@ -12,7 +14,7 @@ class EnsureNoPunctuation
*/
public function __invoke($string)
{
if (str($string)->endsWith(['.', '?', '!', ':'])) {
if ((new Stringable($string))->endsWith(['.', '?', '!', ':'])) {
return substr_replace($string, '', -1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Illuminate\Console\View\Components\Mutators;

use Illuminate\Support\Stringable;

class EnsurePunctuation
{
/**
Expand All @@ -12,7 +14,7 @@ class EnsurePunctuation
*/
public function __invoke($string)
{
if (! str($string)->endsWith(['.', '?', '!', ':'])) {
if (! (new Stringable($string))->endsWith(['.', '?', '!', ':'])) {
return "$string.";
}

Expand Down
17 changes: 17 additions & 0 deletions src/Illuminate/Database/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,23 @@ public function withTablePrefix(Grammar $grammar)
return $grammar;
}

/**
* Execute the given callback without table prefix.
*
* @param \Closure $callback
* @return void
*/
public function withoutTablePrefix(Closure $callback): void
{
$tablePrefix = $this->getTablePrefix();

$this->setTablePrefix('');

$callback($this);

$this->setTablePrefix($tablePrefix);
}

/**
* Get the server version for the connection.
*
Expand Down
5 changes: 4 additions & 1 deletion src/Illuminate/Database/Console/DumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Database\Connection;
use Illuminate\Database\ConnectionResolverInterface;
use Illuminate\Database\Events\MigrationsPruned;
use Illuminate\Database\Events\SchemaDumped;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Config;
Expand Down Expand Up @@ -52,10 +53,12 @@ public function handle(ConnectionResolverInterface $connections, Dispatcher $dis

if ($this->option('prune')) {
(new Filesystem)->deleteDirectory(
database_path('migrations'), $preserve = false
$path = database_path('migrations'), $preserve = false
);

$info .= ' and pruned';

$dispatcher->dispatch(new MigrationsPruned($connection, $path));
}

$this->components->info($info.' successfully.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Console\GeneratorCommand;
use Illuminate\Support\Str;
use Illuminate\Support\Stringable;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputOption;

Expand Down Expand Up @@ -99,7 +100,7 @@ protected function buildClass($name)
*/
protected function getPath($name)
{
$name = (string) Str::of($name)->replaceFirst($this->rootNamespace(), '')->finish('Factory');
$name = (new Stringable($name))->replaceFirst($this->rootNamespace(), '')->finish('Factory')->value();

return $this->laravel->databasePath().'/factories/'.str_replace('\\', '/', $name).'.php';
}
Expand Down
5 changes: 3 additions & 2 deletions src/Illuminate/Database/Console/Migrations/StatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Database\Migrations\Migrator;
use Illuminate\Support\Collection;
use Illuminate\Support\Stringable;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputOption;

Expand Down Expand Up @@ -64,7 +65,7 @@ public function handle()

$migrations = $this->getStatusFor($ran, $batches)
->when($this->option('pending') !== false, fn ($collection) => $collection->filter(function ($migration) {
return str($migration[1])->contains('Pending');
return (new Stringable($migration[1]))->contains('Pending');
}));

if (count($migrations) > 0) {
Expand All @@ -84,7 +85,7 @@ public function handle()
$this->components->info('No migrations found');
}

if ($this->option('pending') && $migrations->some(fn ($m) => str($m[1])->contains('Pending'))) {
if ($this->option('pending') && $migrations->some(fn ($m) => (new Stringable($m[1]))->contains('Pending'))) {
return $this->option('pending');
}
});
Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/Database/Console/ShowCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\Number;
use Illuminate\Support\Stringable;
use Symfony\Component\Console\Attribute\AsCommand;

#[AsCommand(name: 'db:show')]
Expand Down Expand Up @@ -99,7 +100,7 @@ protected function tables(ConnectionInterface $connection, Builder $schema)
protected function views(ConnectionInterface $connection, Builder $schema)
{
return (new Collection($schema->getViews()))
->reject(fn ($view) => str($view['name'])->startsWith(['pg_catalog', 'information_schema', 'spt_']))
->reject(fn ($view) => (new Stringable($view['name']))->startsWith(['pg_catalog', 'information_schema', 'spt_']))
->map(fn ($view) => [
'view' => $view['name'],
'schema' => $view['schema'],
Expand Down
Loading

0 comments on commit cf340a4

Please sign in to comment.