Skip to content

Commit bef2e12

Browse files
committed
Merge branch '11.x'
# Conflicts: # CHANGELOG.md # src/Illuminate/Foundation/Application.php
2 parents fb14d43 + fd9fa89 commit bef2e12

File tree

241 files changed

+2884
-661
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

241 files changed

+2884
-661
lines changed

config/hashing.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
'bcrypt' => [
3232
'rounds' => env('BCRYPT_ROUNDS', 12),
33-
'verify' => true,
33+
'verify' => env('HASH_VERIFY', true),
3434
],
3535

3636
/*
@@ -48,7 +48,7 @@
4848
'memory' => env('ARGON_MEMORY', 65536),
4949
'threads' => env('ARGON_THREADS', 1),
5050
'time' => env('ARGON_TIME', 4),
51-
'verify' => true,
51+
'verify' => env('HASH_VERIFY', true),
5252
],
5353

5454
/*

src/Illuminate/Auth/Access/AuthorizationException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class AuthorizationException extends Exception
2929
* @param \Throwable|null $previous
3030
* @return void
3131
*/
32-
public function __construct($message = null, $code = null, Throwable $previous = null)
32+
public function __construct($message = null, $code = null, ?Throwable $previous = null)
3333
{
3434
parent::__construct($message ?? 'This action is unauthorized.', 0, $previous);
3535

src/Illuminate/Auth/Access/Gate.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function __construct(Container $container,
100100
array $policies = [],
101101
array $beforeCallbacks = [],
102102
array $afterCallbacks = [],
103-
callable $guessPolicyNamesUsingCallback = null)
103+
?callable $guessPolicyNamesUsingCallback = null)
104104
{
105105
$this->policies = $policies;
106106
$this->container = $container;
@@ -224,7 +224,7 @@ public function define($ability, $callback)
224224
* @param array|null $abilities
225225
* @return $this
226226
*/
227-
public function resource($name, $class, array $abilities = null)
227+
public function resource($name, $class, ?array $abilities = null)
228228
{
229229
$abilities = $abilities ?: [
230230
'viewAny' => 'viewAny',

src/Illuminate/Auth/Middleware/Authorize.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function handle($request, Closure $next, $ability, ...$models)
6262
*
6363
* @param \Illuminate\Http\Request $request
6464
* @param array|null $models
65-
* @return \Illuminate\Database\Eloquent\Model|array|string
65+
* @return array
6666
*/
6767
protected function getGateArguments($request, $models)
6868
{

src/Illuminate/Auth/Passwords/PasswordBroker.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct(TokenRepositoryInterface $tokens, UserProvider $user
4545
* @param \Closure|null $callback
4646
* @return string
4747
*/
48-
public function sendResetLink(array $credentials, Closure $callback = null)
48+
public function sendResetLink(array $credentials, ?Closure $callback = null)
4949
{
5050
// First we will check to see if we found a user at the given credentials and
5151
// if we did not we will redirect back to this current URI with a piece of

src/Illuminate/Auth/RequestGuard.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class RequestGuard implements Guard
3333
* @param \Illuminate\Contracts\Auth\UserProvider|null $provider
3434
* @return void
3535
*/
36-
public function __construct(callable $callback, Request $request, UserProvider $provider = null)
36+
public function __construct(callable $callback, Request $request, ?UserProvider $provider = null)
3737
{
3838
$this->request = $request;
3939
$this->callback = $callback;

src/Illuminate/Auth/SessionGuard.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
131131
public function __construct($name,
132132
UserProvider $provider,
133133
Session $session,
134-
Request $request = null,
135-
Timebox $timebox = null,
134+
?Request $request = null,
135+
?Timebox $timebox = null,
136136
bool $rehashOnLogin = true)
137137
{
138138
$this->name = $name;
@@ -253,6 +253,8 @@ public function once(array $credentials = [])
253253
$this->fireAttemptEvent($credentials);
254254

255255
if ($this->validate($credentials)) {
256+
$this->rehashPasswordIfRequired($this->lastAttempted, $credentials);
257+
256258
$this->setUser($this->lastAttempted);
257259

258260
return true;

src/Illuminate/Broadcasting/BroadcastManager.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function __construct($app)
6464
* @param array|null $attributes
6565
* @return void
6666
*/
67-
public function routes(array $attributes = null)
67+
public function routes(?array $attributes = null)
6868
{
6969
if ($this->app instanceof CachesRoutes && $this->app->routesAreCached()) {
7070
return;
@@ -86,7 +86,7 @@ public function routes(array $attributes = null)
8686
* @param array|null $attributes
8787
* @return void
8888
*/
89-
public function userRoutes(array $attributes = null)
89+
public function userRoutes(?array $attributes = null)
9090
{
9191
if ($this->app instanceof CachesRoutes && $this->app->routesAreCached()) {
9292
return;
@@ -110,7 +110,7 @@ public function userRoutes(array $attributes = null)
110110
* @param array|null $attributes
111111
* @return void
112112
*/
113-
public function channelRoutes(array $attributes = null)
113+
public function channelRoutes(?array $attributes = null)
114114
{
115115
$this->routes($attributes);
116116
}

src/Illuminate/Bus/Batch.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ public function delete()
450450
* @param \Throwable|null $e
451451
* @return void
452452
*/
453-
protected function invokeHandlerCallback($handler, Batch $batch, Throwable $e = null)
453+
protected function invokeHandlerCallback($handler, Batch $batch, ?Throwable $e = null)
454454
{
455455
try {
456456
return $handler($batch, $e);

src/Illuminate/Bus/DatabaseBatchRepository.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,9 @@ protected function toBatch($batch)
374374
(int) $batch->failed_jobs,
375375
(array) json_decode($batch->failed_job_ids, true),
376376
$this->unserialize($batch->options),
377-
CarbonImmutable::createFromTimestamp($batch->created_at),
378-
$batch->cancelled_at ? CarbonImmutable::createFromTimestamp($batch->cancelled_at) : $batch->cancelled_at,
379-
$batch->finished_at ? CarbonImmutable::createFromTimestamp($batch->finished_at) : $batch->finished_at
377+
CarbonImmutable::createFromTimestamp($batch->created_at, date_default_timezone_get()),
378+
$batch->cancelled_at ? CarbonImmutable::createFromTimestamp($batch->cancelled_at, date_default_timezone_get()) : $batch->cancelled_at,
379+
$batch->finished_at ? CarbonImmutable::createFromTimestamp($batch->finished_at, date_default_timezone_get()) : $batch->finished_at
380380
);
381381
}
382382

src/Illuminate/Bus/Dispatcher.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Dispatcher implements QueueingDispatcher
5858
* @param \Closure|null $queueResolver
5959
* @return void
6060
*/
61-
public function __construct(Container $container, Closure $queueResolver = null)
61+
public function __construct(Container $container, ?Closure $queueResolver = null)
6262
{
6363
$this->container = $container;
6464
$this->queueResolver = $queueResolver;

src/Illuminate/Bus/DynamoBatchRepository.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,9 @@ protected function toBatch($batch)
411411
(int) $batch->failed_jobs,
412412
$batch->failed_job_ids,
413413
$this->unserialize($batch->options) ?? [],
414-
CarbonImmutable::createFromTimestamp($batch->created_at),
415-
$batch->cancelled_at ? CarbonImmutable::createFromTimestamp($batch->cancelled_at) : $batch->cancelled_at,
416-
$batch->finished_at ? CarbonImmutable::createFromTimestamp($batch->finished_at) : $batch->finished_at
414+
CarbonImmutable::createFromTimestamp($batch->created_at, date_default_timezone_get()),
415+
$batch->cancelled_at ? CarbonImmutable::createFromTimestamp($batch->cancelled_at, date_default_timezone_get()) : $batch->cancelled_at,
416+
$batch->finished_at ? CarbonImmutable::createFromTimestamp($batch->finished_at, date_default_timezone_get()) : $batch->finished_at
417417
);
418418
}
419419

@@ -525,7 +525,7 @@ public function getDynamoClient(): DynamoDbClient
525525
}
526526

527527
/**
528-
* The the name of the table that contains the batch records.
528+
* The name of the table that contains the batch records.
529529
*
530530
* @return string
531531
*/

src/Illuminate/Bus/Queueable.php

+57-21
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Closure;
66
use Illuminate\Queue\CallQueuedClosure;
77
use Illuminate\Support\Arr;
8+
use PHPUnit\Framework\Assert as PHPUnit;
89
use RuntimeException;
910

1011
trait Queueable
@@ -23,27 +24,6 @@ trait Queueable
2324
*/
2425
public $queue;
2526

26-
/**
27-
* The name of the connection the chain should be sent to.
28-
*
29-
* @var string|null
30-
*/
31-
public $chainConnection;
32-
33-
/**
34-
* The name of the queue the chain should be sent to.
35-
*
36-
* @var string|null
37-
*/
38-
public $chainQueue;
39-
40-
/**
41-
* The callbacks to be executed on chain failure.
42-
*
43-
* @var array|null
44-
*/
45-
public $chainCatchCallbacks;
46-
4727
/**
4828
* The number of seconds before the job should be made available.
4929
*
@@ -72,6 +52,27 @@ trait Queueable
7252
*/
7353
public $chained = [];
7454

55+
/**
56+
* The name of the connection the chain should be sent to.
57+
*
58+
* @var string|null
59+
*/
60+
public $chainConnection;
61+
62+
/**
63+
* The name of the queue the chain should be sent to.
64+
*
65+
* @var string|null
66+
*/
67+
public $chainQueue;
68+
69+
/**
70+
* The callbacks to be executed on chain failure.
71+
*
72+
* @var array|null
73+
*/
74+
public $chainCatchCallbacks;
75+
7576
/**
7677
* Set the desired connection for the job.
7778
*
@@ -273,4 +274,39 @@ public function invokeChainCatchCallbacks($e)
273274
$callback($e);
274275
});
275276
}
277+
278+
/**
279+
* Assert that the job has the given chain of jobs attached to it.
280+
*
281+
* @param array $expectedChain
282+
* @return void
283+
*/
284+
public function assertHasChain($expectedChain)
285+
{
286+
PHPUnit::assertTrue(
287+
collect($expectedChain)->isNotEmpty(),
288+
'The expected chain can not be empty.'
289+
);
290+
291+
if (collect($expectedChain)->contains(fn ($job) => is_object($job))) {
292+
$expectedChain = collect($expectedChain)->map(fn ($job) => serialize($job))->all();
293+
} else {
294+
$chain = collect($this->chained)->map(fn ($job) => get_class(unserialize($job)))->all();
295+
}
296+
297+
PHPUnit::assertTrue(
298+
$expectedChain === ($chain ?? $this->chained),
299+
'The job does not have the expected chain.'
300+
);
301+
}
302+
303+
/**
304+
* Assert that the job has no remaining chained jobs.
305+
*
306+
* @return void
307+
*/
308+
public function assertDoesntHaveChain()
309+
{
310+
PHPUnit::assertEmpty($this->chained, 'The job has chained jobs.');
311+
}
276312
}

src/Illuminate/Cache/ApcStore.php

+11
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,15 @@ public function getPrefix()
123123
{
124124
return $this->prefix;
125125
}
126+
127+
/**
128+
* Set the cache key prefix.
129+
*
130+
* @param string $prefix
131+
* @return void
132+
*/
133+
public function setPrefix($prefix)
134+
{
135+
$this->prefix = $prefix;
136+
}
126137
}

src/Illuminate/Cache/DatabaseLock.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function acquire()
7575
$updated = $this->connection->table($this->table)
7676
->where('key', $this->name)
7777
->where(function ($query) {
78-
return $query->where('owner', $this->owner)->orWhere('expiration', '<=', time());
78+
return $query->where('owner', $this->owner)->orWhere('expiration', '<=', $this->currentTime());
7979
})->update([
8080
'owner' => $this->owner,
8181
'expiration' => $this->expiresAt(),
@@ -85,7 +85,7 @@ public function acquire()
8585
}
8686

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

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

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

106106
/**

src/Illuminate/Cache/DatabaseStore.php

+11
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,17 @@ public function getPrefix()
387387
return $this->prefix;
388388
}
389389

390+
/**
391+
* Set the cache key prefix.
392+
*
393+
* @param string $prefix
394+
* @return void
395+
*/
396+
public function setPrefix($prefix)
397+
{
398+
$this->prefix = $prefix;
399+
}
400+
390401
/**
391402
* Serialize the given value.
392403
*

src/Illuminate/Cache/FileStore.php

+13
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,19 @@ public function getDirectory()
380380
return $this->directory;
381381
}
382382

383+
/**
384+
* Set the working directory of the cache.
385+
*
386+
* @param string $directory
387+
* @return $this
388+
*/
389+
public function setDirectory($directory)
390+
{
391+
$this->directory = $directory;
392+
393+
return $this;
394+
}
395+
383396
/**
384397
* Set the cache directory where locks should be stored.
385398
*

src/Illuminate/Cache/RedisTagSet.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class RedisTagSet extends TagSet
1515
* @param string $updateWhen
1616
* @return void
1717
*/
18-
public function addEntry(string $key, int $ttl = null, $updateWhen = null)
18+
public function addEntry(string $key, ?int $ttl = null, $updateWhen = null)
1919
{
2020
$ttl = is_null($ttl) ? -1 : Carbon::now()->addSeconds($ttl)->getTimestamp();
2121

src/Illuminate/Cache/Repository.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ protected function getSeconds($ttl)
548548
$duration = $this->parseDateInterval($ttl);
549549

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

554554
return (int) ($duration > 0 ? $duration : 0);

src/Illuminate/Collections/Arr.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public static function exists($array, $key)
190190
* @param TFirstDefault|(\Closure(): TFirstDefault) $default
191191
* @return TValue|TFirstDefault
192192
*/
193-
public static function first($array, callable $callback = null, $default = null)
193+
public static function first($array, ?callable $callback = null, $default = null)
194194
{
195195
if (is_null($callback)) {
196196
if (empty($array)) {
@@ -221,7 +221,7 @@ public static function first($array, callable $callback = null, $default = null)
221221
* @param mixed $default
222222
* @return mixed
223223
*/
224-
public static function last($array, callable $callback = null, $default = null)
224+
public static function last($array, ?callable $callback = null, $default = null)
225225
{
226226
if (is_null($callback)) {
227227
return empty($array) ? value($default) : end($array);

0 commit comments

Comments
 (0)