Skip to content

Commit b134b79

Browse files
committed
Merge branch '9.x'
2 parents 59767b0 + 26c476d commit b134b79

File tree

13 files changed

+257
-35
lines changed

13 files changed

+257
-35
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public function isGuarded($key)
202202
}
203203

204204
return $this->getGuarded() == ['*'] ||
205-
! empty(preg_grep('/^'.preg_quote($key).'$/i', $this->getGuarded())) ||
205+
! empty(preg_grep('/^'.preg_quote($key, '/').'$/i', $this->getGuarded())) ||
206206
! $this->isGuardableColumn($key);
207207
}
208208

src/Illuminate/Filesystem/Filesystem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ public function hasSameHash($firstFile, $secondFile)
536536
*/
537537
public function isFile($file)
538538
{
539-
return is_string($file) && is_file($file);
539+
return is_file($file);
540540
}
541541

542542
/**

src/Illuminate/Foundation/Bootstrap/LoadEnvironmentVariables.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ protected function writeErrorAndDie(InvalidFileException $e)
103103
$output->writeln('The environment file is invalid!');
104104
$output->writeln($e->getMessage());
105105

106+
http_response_code(500);
107+
106108
exit(1);
107109
}
108110
}

src/Illuminate/Http/Client/PendingRequest.php

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ class PendingRequest
105105
*/
106106
protected $throwCallback;
107107

108+
/**
109+
* A callback to check if an exception should be thrown when a server or client error occurs.
110+
*
111+
* @var \Closure
112+
*/
113+
protected $throwIfCallback;
114+
108115
/**
109116
* The number of times to try the request.
110117
*
@@ -599,12 +606,17 @@ public function throw(callable $callback = null)
599606
/**
600607
* Throw an exception if a server or client error occurred and the given condition evaluates to true.
601608
*
602-
* @param bool $condition
609+
* @param callable|bool $condition
610+
* @param callable|null $throwCallback
603611
* @return $this
604612
*/
605613
public function throwIf($condition)
606614
{
607-
return $condition ? $this->throw() : $this;
615+
if (is_callable($condition)) {
616+
$this->throwIfCallback = $condition;
617+
}
618+
619+
return $condition ? $this->throw(func_get_args()[1] ?? null) : $this;
608620
}
609621

610622
/**
@@ -657,7 +669,7 @@ public function dd()
657669
*
658670
* @param string $url
659671
* @param array|string|null $query
660-
* @return \Illuminate\Http\Client\Response
672+
* @return \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface
661673
*/
662674
public function get(string $url, $query = null)
663675
{
@@ -671,7 +683,7 @@ public function get(string $url, $query = null)
671683
*
672684
* @param string $url
673685
* @param array|string|null $query
674-
* @return \Illuminate\Http\Client\Response
686+
* @return \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface
675687
*/
676688
public function head(string $url, $query = null)
677689
{
@@ -685,7 +697,7 @@ public function head(string $url, $query = null)
685697
*
686698
* @param string $url
687699
* @param array $data
688-
* @return \Illuminate\Http\Client\Response
700+
* @return \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface
689701
*/
690702
public function post(string $url, $data = [])
691703
{
@@ -699,7 +711,7 @@ public function post(string $url, $data = [])
699711
*
700712
* @param string $url
701713
* @param array $data
702-
* @return \Illuminate\Http\Client\Response
714+
* @return \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface
703715
*/
704716
public function patch($url, $data = [])
705717
{
@@ -713,7 +725,7 @@ public function patch($url, $data = [])
713725
*
714726
* @param string $url
715727
* @param array $data
716-
* @return \Illuminate\Http\Client\Response
728+
* @return \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface
717729
*/
718730
public function put($url, $data = [])
719731
{
@@ -727,7 +739,7 @@ public function put($url, $data = [])
727739
*
728740
* @param string $url
729741
* @param array $data
730-
* @return \Illuminate\Http\Client\Response
742+
* @return \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface
731743
*/
732744
public function delete($url, $data = [])
733745
{
@@ -761,7 +773,7 @@ public function pool(callable $callback)
761773
* @param string $method
762774
* @param string $url
763775
* @param array $options
764-
* @return \Illuminate\Http\Client\Response
776+
* @return \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface
765777
*
766778
* @throws \Exception
767779
*/
@@ -797,7 +809,9 @@ public function send(string $method, string $url, array $options = [])
797809
throw $exception;
798810
}
799811

800-
if ($this->throwCallback) {
812+
if ($this->throwCallback &&
813+
($this->throwIfCallback === null ||
814+
call_user_func($this->throwIfCallback, $response))) {
801815
$response->throw($this->throwCallback);
802816
}
803817

src/Illuminate/Http/Client/Response.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Response implements ArrayAccess
3737
/**
3838
* The transfer stats for the request.
3939
*
40-
* \GuzzleHttp\TransferStats|null
40+
* @var \GuzzleHttp\TransferStats|null
4141
*/
4242
public $transferStats;
4343

@@ -329,14 +329,15 @@ public function throw()
329329
/**
330330
* Throw an exception if a server or client error occurred and the given condition evaluates to true.
331331
*
332-
* @param bool $condition
332+
* @param \Closure|bool $condition
333+
* @param \Closure|null $throwCallback
333334
* @return $this
334335
*
335336
* @throws \Illuminate\Http\Client\RequestException
336337
*/
337338
public function throwIf($condition)
338339
{
339-
return $condition ? $this->throw() : $this;
340+
return value($condition, $this) ? $this->throw(func_get_args()[1] ?? null) : $this;
340341
}
341342

342343
/**

src/Illuminate/Notifications/NotificationSender.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,12 @@ protected function queueNotification($notifiables, $notification)
199199
$notification->locale = $this->locale;
200200
}
201201

202+
$connection = $notification->connection;
203+
204+
if (method_exists($notification, 'viaConnections')) {
205+
$connection = $notification->viaConnections()[$channel] ?? null;
206+
}
207+
202208
$queue = $notification->queue;
203209

204210
if (method_exists($notification, 'viaQueues')) {
@@ -222,7 +228,7 @@ protected function queueNotification($notifiables, $notification)
222228

223229
$this->bus->dispatch(
224230
(new SendQueuedNotifications($notifiable, $notification, [$channel]))
225-
->onConnection($notification->connection)
231+
->onConnection($connection)
226232
->onQueue($queue)
227233
->delay(is_array($delay) ? ($delay[$channel] ?? null) : $delay)
228234
->through($middleware)

src/Illuminate/Queue/Console/stubs/batches.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ return new class extends Migration
1919
$table->integer('total_jobs');
2020
$table->integer('pending_jobs');
2121
$table->integer('failed_jobs');
22-
$table->text('failed_job_ids');
22+
$table->longText('failed_job_ids');
2323
$table->mediumText('options')->nullable();
2424
$table->integer('cancelled_at')->nullable();
2525
$table->integer('created_at');

src/Illuminate/Support/Facades/Http.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,18 @@
4949
* @method static \Illuminate\Http\Client\PendingRequest withMiddleware(callable $middleware)
5050
* @method static \Illuminate\Http\Client\PendingRequest beforeSending(callable $callback)
5151
* @method static \Illuminate\Http\Client\PendingRequest throw(callable|null $callback = null)
52-
* @method static \Illuminate\Http\Client\PendingRequest throwIf(bool $condition)
52+
* @method static \Illuminate\Http\Client\PendingRequest throwIf(callable|bool $condition, callable|null $throwCallback)
5353
* @method static \Illuminate\Http\Client\PendingRequest throwUnless(bool $condition)
5454
* @method static \Illuminate\Http\Client\PendingRequest dump()
5555
* @method static \Illuminate\Http\Client\PendingRequest dd()
56-
* @method static \Illuminate\Http\Client\Response get(string $url, array|string|null $query = null)
57-
* @method static \Illuminate\Http\Client\Response head(string $url, array|string|null $query = null)
58-
* @method static \Illuminate\Http\Client\Response post(string $url, array $data = [])
59-
* @method static \Illuminate\Http\Client\Response patch(string $url, array $data = [])
60-
* @method static \Illuminate\Http\Client\Response put(string $url, array $data = [])
61-
* @method static \Illuminate\Http\Client\Response delete(string $url, array $data = [])
56+
* @method static \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface get(string $url, array|string|null $query = null)
57+
* @method static \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface head(string $url, array|string|null $query = null)
58+
* @method static \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface post(string $url, array $data = [])
59+
* @method static \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface patch(string $url, array $data = [])
60+
* @method static \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface put(string $url, array $data = [])
61+
* @method static \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface delete(string $url, array $data = [])
6262
* @method static array pool(callable $callback)
63-
* @method static \Illuminate\Http\Client\Response send(string $method, string $url, array $options = [])
63+
* @method static \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface send(string $method, string $url, array $options = [])
6464
* @method static \GuzzleHttp\Client buildClient()
6565
* @method static \GuzzleHttp\Client createClient(\GuzzleHttp\HandlerStack $handlerStack)
6666
* @method static \GuzzleHttp\HandlerStack buildHandlerStack()

src/Illuminate/Testing/TestResponse.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -621,11 +621,11 @@ public function assertSeeText($value, $escape = true)
621621

622622
$values = $escape ? array_map('e', ($value)) : $value;
623623

624-
tap(strip_tags($this->getContent()), function ($content) use ($values) {
625-
foreach ($values as $value) {
626-
PHPUnit::assertStringContainsString((string) $value, $content);
627-
}
628-
});
624+
$content = strip_tags($this->getContent());
625+
626+
foreach ($values as $value) {
627+
PHPUnit::assertStringContainsString((string) $value, $content);
628+
}
629629

630630
return $this;
631631
}
@@ -679,11 +679,11 @@ public function assertDontSeeText($value, $escape = true)
679679

680680
$values = $escape ? array_map('e', ($value)) : $value;
681681

682-
tap(strip_tags($this->getContent()), function ($content) use ($values) {
683-
foreach ($values as $value) {
684-
PHPUnit::assertStringNotContainsString((string) $value, $content);
685-
}
686-
});
682+
$content = strip_tags($this->getContent());
683+
684+
foreach ($values as $value) {
685+
PHPUnit::assertStringNotContainsString((string) $value, $content);
686+
}
687687

688688
return $this;
689689
}

src/Illuminate/Validation/Concerns/ValidatesAttributes.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,18 @@ protected function getDnsRecords($hostname, $type)
142142
return dns_get_record($hostname, $type);
143143
}
144144

145+
/**
146+
* Validate that an attribute is 7 bit ASCII.
147+
*
148+
* @param string $attribute
149+
* @param mixed $value
150+
* @return bool
151+
*/
152+
public function validateAscii($attribute, $value)
153+
{
154+
return Str::isAscii($value);
155+
}
156+
145157
/**
146158
* "Break" on first validation fail.
147159
*
@@ -2139,6 +2151,18 @@ public function validateUrl($attribute, $value)
21392151
return preg_match($pattern, $value) > 0;
21402152
}
21412153

2154+
/**
2155+
* Validate that an attribute is a valid ULID.
2156+
*
2157+
* @param string $attribute
2158+
* @param mixed $value
2159+
* @return bool
2160+
*/
2161+
public function validateUlid($attribute, $value)
2162+
{
2163+
return Str::isUlid($value);
2164+
}
2165+
21422166
/**
21432167
* Validate that an attribute is a valid UUID.
21442168
*

0 commit comments

Comments
 (0)