Skip to content

Commit

Permalink
Merge branch '11.x'
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	src/Illuminate/Foundation/Application.php
  • Loading branch information
driesvints committed Apr 10, 2024
2 parents fb14d43 + fd9fa89 commit bef2e12
Show file tree
Hide file tree
Showing 241 changed files with 2,884 additions and 661 deletions.
4 changes: 2 additions & 2 deletions config/hashing.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

'bcrypt' => [
'rounds' => env('BCRYPT_ROUNDS', 12),
'verify' => true,
'verify' => env('HASH_VERIFY', true),
],

/*
Expand All @@ -48,7 +48,7 @@
'memory' => env('ARGON_MEMORY', 65536),
'threads' => env('ARGON_THREADS', 1),
'time' => env('ARGON_TIME', 4),
'verify' => true,
'verify' => env('HASH_VERIFY', true),
],

/*
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Auth/Access/AuthorizationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AuthorizationException extends Exception
* @param \Throwable|null $previous
* @return void
*/
public function __construct($message = null, $code = null, Throwable $previous = null)
public function __construct($message = null, $code = null, ?Throwable $previous = null)
{
parent::__construct($message ?? 'This action is unauthorized.', 0, $previous);

Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Auth/Access/Gate.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function __construct(Container $container,
array $policies = [],
array $beforeCallbacks = [],
array $afterCallbacks = [],
callable $guessPolicyNamesUsingCallback = null)
?callable $guessPolicyNamesUsingCallback = null)
{
$this->policies = $policies;
$this->container = $container;
Expand Down Expand Up @@ -224,7 +224,7 @@ public function define($ability, $callback)
* @param array|null $abilities
* @return $this
*/
public function resource($name, $class, array $abilities = null)
public function resource($name, $class, ?array $abilities = null)
{
$abilities = $abilities ?: [
'viewAny' => 'viewAny',
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Auth/Middleware/Authorize.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function handle($request, Closure $next, $ability, ...$models)
*
* @param \Illuminate\Http\Request $request
* @param array|null $models
* @return \Illuminate\Database\Eloquent\Model|array|string
* @return array
*/
protected function getGateArguments($request, $models)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Auth/Passwords/PasswordBroker.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(TokenRepositoryInterface $tokens, UserProvider $user
* @param \Closure|null $callback
* @return string
*/
public function sendResetLink(array $credentials, Closure $callback = null)
public function sendResetLink(array $credentials, ?Closure $callback = null)
{
// First we will check to see if we found a user at the given credentials and
// if we did not we will redirect back to this current URI with a piece of
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Auth/RequestGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class RequestGuard implements Guard
* @param \Illuminate\Contracts\Auth\UserProvider|null $provider
* @return void
*/
public function __construct(callable $callback, Request $request, UserProvider $provider = null)
public function __construct(callable $callback, Request $request, ?UserProvider $provider = null)
{
$this->request = $request;
$this->callback = $callback;
Expand Down
6 changes: 4 additions & 2 deletions src/Illuminate/Auth/SessionGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
public function __construct($name,
UserProvider $provider,
Session $session,
Request $request = null,
Timebox $timebox = null,
?Request $request = null,
?Timebox $timebox = null,
bool $rehashOnLogin = true)
{
$this->name = $name;
Expand Down Expand Up @@ -253,6 +253,8 @@ public function once(array $credentials = [])
$this->fireAttemptEvent($credentials);

if ($this->validate($credentials)) {
$this->rehashPasswordIfRequired($this->lastAttempted, $credentials);

$this->setUser($this->lastAttempted);

return true;
Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Broadcasting/BroadcastManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function __construct($app)
* @param array|null $attributes
* @return void
*/
public function routes(array $attributes = null)
public function routes(?array $attributes = null)
{
if ($this->app instanceof CachesRoutes && $this->app->routesAreCached()) {
return;
Expand All @@ -86,7 +86,7 @@ public function routes(array $attributes = null)
* @param array|null $attributes
* @return void
*/
public function userRoutes(array $attributes = null)
public function userRoutes(?array $attributes = null)
{
if ($this->app instanceof CachesRoutes && $this->app->routesAreCached()) {
return;
Expand All @@ -110,7 +110,7 @@ public function userRoutes(array $attributes = null)
* @param array|null $attributes
* @return void
*/
public function channelRoutes(array $attributes = null)
public function channelRoutes(?array $attributes = null)
{
$this->routes($attributes);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Bus/Batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ public function delete()
* @param \Throwable|null $e
* @return void
*/
protected function invokeHandlerCallback($handler, Batch $batch, Throwable $e = null)
protected function invokeHandlerCallback($handler, Batch $batch, ?Throwable $e = null)
{
try {
return $handler($batch, $e);
Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Bus/DatabaseBatchRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,9 @@ protected function toBatch($batch)
(int) $batch->failed_jobs,
(array) json_decode($batch->failed_job_ids, true),
$this->unserialize($batch->options),
CarbonImmutable::createFromTimestamp($batch->created_at),
$batch->cancelled_at ? CarbonImmutable::createFromTimestamp($batch->cancelled_at) : $batch->cancelled_at,
$batch->finished_at ? CarbonImmutable::createFromTimestamp($batch->finished_at) : $batch->finished_at
CarbonImmutable::createFromTimestamp($batch->created_at, date_default_timezone_get()),
$batch->cancelled_at ? CarbonImmutable::createFromTimestamp($batch->cancelled_at, date_default_timezone_get()) : $batch->cancelled_at,
$batch->finished_at ? CarbonImmutable::createFromTimestamp($batch->finished_at, date_default_timezone_get()) : $batch->finished_at
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Bus/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Dispatcher implements QueueingDispatcher
* @param \Closure|null $queueResolver
* @return void
*/
public function __construct(Container $container, Closure $queueResolver = null)
public function __construct(Container $container, ?Closure $queueResolver = null)
{
$this->container = $container;
$this->queueResolver = $queueResolver;
Expand Down
8 changes: 4 additions & 4 deletions src/Illuminate/Bus/DynamoBatchRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,9 @@ protected function toBatch($batch)
(int) $batch->failed_jobs,
$batch->failed_job_ids,
$this->unserialize($batch->options) ?? [],
CarbonImmutable::createFromTimestamp($batch->created_at),
$batch->cancelled_at ? CarbonImmutable::createFromTimestamp($batch->cancelled_at) : $batch->cancelled_at,
$batch->finished_at ? CarbonImmutable::createFromTimestamp($batch->finished_at) : $batch->finished_at
CarbonImmutable::createFromTimestamp($batch->created_at, date_default_timezone_get()),
$batch->cancelled_at ? CarbonImmutable::createFromTimestamp($batch->cancelled_at, date_default_timezone_get()) : $batch->cancelled_at,
$batch->finished_at ? CarbonImmutable::createFromTimestamp($batch->finished_at, date_default_timezone_get()) : $batch->finished_at
);
}

Expand Down Expand Up @@ -525,7 +525,7 @@ public function getDynamoClient(): DynamoDbClient
}

/**
* The the name of the table that contains the batch records.
* The name of the table that contains the batch records.
*
* @return string
*/
Expand Down
78 changes: 57 additions & 21 deletions src/Illuminate/Bus/Queueable.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Closure;
use Illuminate\Queue\CallQueuedClosure;
use Illuminate\Support\Arr;
use PHPUnit\Framework\Assert as PHPUnit;
use RuntimeException;

trait Queueable
Expand All @@ -23,27 +24,6 @@ trait Queueable
*/
public $queue;

/**
* The name of the connection the chain should be sent to.
*
* @var string|null
*/
public $chainConnection;

/**
* The name of the queue the chain should be sent to.
*
* @var string|null
*/
public $chainQueue;

/**
* The callbacks to be executed on chain failure.
*
* @var array|null
*/
public $chainCatchCallbacks;

/**
* The number of seconds before the job should be made available.
*
Expand Down Expand Up @@ -72,6 +52,27 @@ trait Queueable
*/
public $chained = [];

/**
* The name of the connection the chain should be sent to.
*
* @var string|null
*/
public $chainConnection;

/**
* The name of the queue the chain should be sent to.
*
* @var string|null
*/
public $chainQueue;

/**
* The callbacks to be executed on chain failure.
*
* @var array|null
*/
public $chainCatchCallbacks;

/**
* Set the desired connection for the job.
*
Expand Down Expand Up @@ -273,4 +274,39 @@ public function invokeChainCatchCallbacks($e)
$callback($e);
});
}

/**
* Assert that the job has the given chain of jobs attached to it.
*
* @param array $expectedChain
* @return void
*/
public function assertHasChain($expectedChain)
{
PHPUnit::assertTrue(
collect($expectedChain)->isNotEmpty(),
'The expected chain can not be empty.'
);

if (collect($expectedChain)->contains(fn ($job) => is_object($job))) {
$expectedChain = collect($expectedChain)->map(fn ($job) => serialize($job))->all();
} else {
$chain = collect($this->chained)->map(fn ($job) => get_class(unserialize($job)))->all();
}

PHPUnit::assertTrue(
$expectedChain === ($chain ?? $this->chained),
'The job does not have the expected chain.'
);
}

/**
* Assert that the job has no remaining chained jobs.
*
* @return void
*/
public function assertDoesntHaveChain()
{
PHPUnit::assertEmpty($this->chained, 'The job has chained jobs.');
}
}
11 changes: 11 additions & 0 deletions src/Illuminate/Cache/ApcStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,15 @@ public function getPrefix()
{
return $this->prefix;
}

/**
* Set the cache key prefix.
*
* @param string $prefix
* @return void
*/
public function setPrefix($prefix)
{
$this->prefix = $prefix;
}
}
6 changes: 3 additions & 3 deletions src/Illuminate/Cache/DatabaseLock.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function acquire()
$updated = $this->connection->table($this->table)
->where('key', $this->name)
->where(function ($query) {
return $query->where('owner', $this->owner)->orWhere('expiration', '<=', time());
return $query->where('owner', $this->owner)->orWhere('expiration', '<=', $this->currentTime());
})->update([
'owner' => $this->owner,
'expiration' => $this->expiresAt(),
Expand All @@ -85,7 +85,7 @@ public function acquire()
}

if (random_int(1, $this->lottery[1]) <= $this->lottery[0]) {
$this->connection->table($this->table)->where('expiration', '<=', time())->delete();
$this->connection->table($this->table)->where('expiration', '<=', $this->currentTime())->delete();
}

return $acquired;
Expand All @@ -100,7 +100,7 @@ protected function expiresAt()
{
$lockTimeout = $this->seconds > 0 ? $this->seconds : $this->defaultTimeoutInSeconds;

return time() + $lockTimeout;
return $this->currentTime() + $lockTimeout;
}

/**
Expand Down
11 changes: 11 additions & 0 deletions src/Illuminate/Cache/DatabaseStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,17 @@ public function getPrefix()
return $this->prefix;
}

/**
* Set the cache key prefix.
*
* @param string $prefix
* @return void
*/
public function setPrefix($prefix)
{
$this->prefix = $prefix;
}

/**
* Serialize the given value.
*
Expand Down
13 changes: 13 additions & 0 deletions src/Illuminate/Cache/FileStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,19 @@ public function getDirectory()
return $this->directory;
}

/**
* Set the working directory of the cache.
*
* @param string $directory
* @return $this
*/
public function setDirectory($directory)
{
$this->directory = $directory;

return $this;
}

/**
* Set the cache directory where locks should be stored.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Cache/RedisTagSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class RedisTagSet extends TagSet
* @param string $updateWhen
* @return void
*/
public function addEntry(string $key, int $ttl = null, $updateWhen = null)
public function addEntry(string $key, ?int $ttl = null, $updateWhen = null)
{
$ttl = is_null($ttl) ? -1 : Carbon::now()->addSeconds($ttl)->getTimestamp();

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Cache/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ protected function getSeconds($ttl)
$duration = $this->parseDateInterval($ttl);

if ($duration instanceof DateTimeInterface) {
$duration = Carbon::now()->diffInRealSeconds($duration, false);
$duration = Carbon::now()->diffInSeconds($duration, false);
}

return (int) ($duration > 0 ? $duration : 0);
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Collections/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public static function exists($array, $key)
* @param TFirstDefault|(\Closure(): TFirstDefault) $default
* @return TValue|TFirstDefault
*/
public static function first($array, callable $callback = null, $default = null)
public static function first($array, ?callable $callback = null, $default = null)
{
if (is_null($callback)) {
if (empty($array)) {
Expand Down Expand Up @@ -221,7 +221,7 @@ public static function first($array, callable $callback = null, $default = null)
* @param mixed $default
* @return mixed
*/
public static function last($array, callable $callback = null, $default = null)
public static function last($array, ?callable $callback = null, $default = null)
{
if (is_null($callback)) {
return empty($array) ? value($default) : end($array);
Expand Down
Loading

0 comments on commit bef2e12

Please sign in to comment.