Skip to content

Commit 3a8888c

Browse files
committed
Merge branch '8.x'
# Conflicts: # composer.json # src/Illuminate/Foundation/Application.php # src/Illuminate/Mail/composer.json # src/Illuminate/Queue/composer.json
2 parents 0ec3e78 + b0eca38 commit 3a8888c

File tree

26 files changed

+740
-32
lines changed

26 files changed

+740
-32
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"illuminate/view": "self.version"
7878
},
7979
"require-dev": {
80-
"aws/aws-sdk-php": "^3.186.4",
80+
"aws/aws-sdk-php": "^3.189.0",
8181
"doctrine/dbal": "^2.12|^3.0",
8282
"fakerphp/faker": "^1.9.2",
8383
"guzzlehttp/guzzle": "^7.2",
@@ -129,7 +129,7 @@
129129
"ext-pcntl": "Required to use all features of the queue worker.",
130130
"ext-posix": "Required to use all features of the queue worker.",
131131
"ext-redis": "Required to use the Redis cache and queue drivers (^4.0|^5.0).",
132-
"aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage and SES mail driver (^3.186.4).",
132+
"aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage and SES mail driver (^3.189.0).",
133133
"brianium/paratest": "Required to run tests in parallel (^6.0).",
134134
"doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.12|^3.0).",
135135
"filp/whoops": "Required for friendly error pages in development (^2.8).",

src/Illuminate/Bus/Batch.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function fresh()
156156
/**
157157
* Add additional jobs to the batch.
158158
*
159-
* @param \Illuminate\Support\Collection|array $jobs
159+
* @param \Illuminate\Support\Enumerable|array $jobs
160160
* @return self
161161
*/
162162
public function add($jobs)
@@ -427,9 +427,15 @@ public function delete()
427427
*/
428428
protected function invokeHandlerCallback($handler, Batch $batch, Throwable $e = null)
429429
{
430-
return $handler instanceof SerializableClosure
431-
? $handler->__invoke($batch, $e)
432-
: call_user_func($handler, $batch, $e);
430+
try {
431+
return $handler instanceof SerializableClosure
432+
? $handler->__invoke($batch, $e)
433+
: call_user_func($handler, $batch, $e);
434+
} catch (Throwable $e) {
435+
if (function_exists('report')) {
436+
report($e);
437+
}
438+
}
433439
}
434440

435441
/**

src/Illuminate/Cache/RateLimiter.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,26 @@ public function limiter(string $name)
6060
return $this->limiters[$name] ?? null;
6161
}
6262

63+
/**
64+
* Attempts to execute a callback if it's not limited.
65+
*
66+
* @param string $key
67+
* @param int $maxAttempts
68+
* @param \Closure $callback
69+
* @param int $decaySeconds
70+
* @return mixed
71+
*/
72+
public function attempt($key, $maxAttempts, Closure $callback, $decaySeconds = 60)
73+
{
74+
if ($this->tooManyAttempts($key, $maxAttempts)) {
75+
return false;
76+
}
77+
78+
return tap($callback() ?: true, function () use ($key, $decaySeconds) {
79+
$this->hit($key, $decaySeconds);
80+
});
81+
}
82+
6383
/**
6484
* Determine if the given key has been "accessed" too many times.
6585
*

src/Illuminate/Collections/Collection.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,9 +797,15 @@ public function pop($count = 1)
797797
return array_pop($this->items);
798798
}
799799

800+
if ($this->isEmpty()) {
801+
return new static;
802+
}
803+
800804
$results = [];
801805

802-
foreach (range(1, $count) as $item) {
806+
$collectionCount = $this->count();
807+
808+
foreach (range(1, min($count, $collectionCount)) as $item) {
803809
array_push($results, array_pop($this->items));
804810
}
805811

@@ -961,9 +967,15 @@ public function shift($count = 1)
961967
return array_shift($this->items);
962968
}
963969

970+
if ($this->isEmpty()) {
971+
return new static;
972+
}
973+
964974
$results = [];
965975

966-
foreach (range(1, $count) as $item) {
976+
$collectionCount = $this->count();
977+
978+
foreach (range(1, min($count, $collectionCount)) as $item) {
967979
array_push($results, array_shift($this->items));
968980
}
969981

src/Illuminate/Database/Concerns/BuildsQueries.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ protected function cursorPaginator($items, $perPage, $cursor, $options)
422422
* Pass the query to a given callback.
423423
*
424424
* @param callable $callback
425-
* @return $this
425+
* @return $this|mixed
426426
*/
427427
public function tap($callback)
428428
{

src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,7 @@ protected function addCastAttributesToArray(array $attributes, array $mutatedAtt
244244
// If the attribute cast was a date or a datetime, we will serialize the date as
245245
// a string. This allows the developers to customize how dates are serialized
246246
// into an array without affecting how they are persisted into the storage.
247-
if ($attributes[$key] &&
248-
($value === 'date' || $value === 'datetime' ||
249-
$value === 'immutable_date' || $value === 'immutable_datetime')) {
247+
if ($attributes[$key] && in_array($value, ['date', 'datetime', 'immutable_date', 'immutable_datetime'])) {
250248
$attributes[$key] = $this->serializeDate($attributes[$key]);
251249
}
252250

@@ -1219,7 +1217,7 @@ public function getCasts()
12191217
*/
12201218
protected function isDateCastable($key)
12211219
{
1222-
return $this->hasCast($key, ['date', 'datetime']);
1220+
return $this->hasCast($key, ['date', 'datetime', 'immutable_date', 'immutable_datetime']);
12231221
}
12241222

12251223
/**

src/Illuminate/Database/Eloquent/Factories/Factory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ public function createOne($attributes = [])
211211
public function createMany(iterable $records)
212212
{
213213
return new EloquentCollection(
214-
array_map(function ($record) {
214+
collect($records)->map(function ($record) {
215215
return $this->state($record)->create();
216-
}, $records)
216+
})
217217
);
218218
}
219219

src/Illuminate/Database/Query/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class Builder implements BuilderContract
196196
public $operators = [
197197
'=', '<', '>', '<=', '>=', '<>', '!=', '<=>',
198198
'like', 'like binary', 'not like', 'ilike',
199-
'&', '|', '^', '<<', '>>',
199+
'&', '|', '^', '<<', '>>', '&~',
200200
'rlike', 'not rlike', 'regexp', 'not regexp',
201201
'~', '~*', '!~', '!~*', 'similar to',
202202
'not similar to', 'not ilike', '~~*', '!~~*',

src/Illuminate/Database/Query/JoinClause.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function on($first, $operator = null, $second = null, $boolean = 'and')
104104
*
105105
* @param \Closure|string $first
106106
* @param string|null $operator
107-
* @param string|null $second
107+
* @param \Illuminate\Database\Query\Expression|string|null $second
108108
* @return \Illuminate\Database\Query\JoinClause
109109
*/
110110
public function orOn($first, $operator = null, $second = null)

src/Illuminate/Events/Dispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ protected function prepareListeners(string $eventName)
387387
/**
388388
* Register an event listener with the dispatcher.
389389
*
390-
* @param \Closure|string $listener
390+
* @param \Closure|string|array $listener
391391
* @param bool $wildcard
392392
* @return \Closure
393393
*/

0 commit comments

Comments
 (0)