🔧
This commit is contained in:
@@ -84,7 +84,7 @@ class Factory
|
||||
* @param \Illuminate\Contracts\Events\Dispatcher|null $dispatcher
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Dispatcher $dispatcher = null)
|
||||
public function __construct(?Dispatcher $dispatcher = null)
|
||||
{
|
||||
$this->dispatcher = $dispatcher;
|
||||
|
||||
|
||||
@@ -222,7 +222,7 @@ class PendingRequest
|
||||
* @param array $middleware
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Factory $factory = null, $middleware = [])
|
||||
public function __construct(?Factory $factory = null, $middleware = [])
|
||||
{
|
||||
$this->factory = $factory;
|
||||
$this->middleware = new Collection($middleware);
|
||||
@@ -600,13 +600,13 @@ class PendingRequest
|
||||
/**
|
||||
* Specify the number of times the request should be attempted.
|
||||
*
|
||||
* @param int $times
|
||||
* @param array|int $times
|
||||
* @param Closure|int $sleepMilliseconds
|
||||
* @param callable|null $when
|
||||
* @param bool $throw
|
||||
* @return $this
|
||||
*/
|
||||
public function retry(int $times, Closure|int $sleepMilliseconds = 0, ?callable $when = null, bool $throw = true)
|
||||
public function retry(array|int $times, Closure|int $sleepMilliseconds = 0, ?callable $when = null, bool $throw = true)
|
||||
{
|
||||
$this->tries = $times;
|
||||
$this->retryDelay = $sleepMilliseconds;
|
||||
@@ -690,7 +690,7 @@ class PendingRequest
|
||||
* @param callable|null $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function throw(callable $callback = null)
|
||||
public function throw(?callable $callback = null)
|
||||
{
|
||||
$this->throwCallback = $callback ?: fn () => null;
|
||||
|
||||
@@ -911,17 +911,21 @@ class PendingRequest
|
||||
$response->throw($this->throwCallback);
|
||||
}
|
||||
|
||||
if ($attempt < $this->tries && $shouldRetry) {
|
||||
$potentialTries = is_array($this->tries)
|
||||
? count($this->tries) + 1
|
||||
: $this->tries;
|
||||
|
||||
if ($attempt < $potentialTries && $shouldRetry) {
|
||||
$response->throw();
|
||||
}
|
||||
|
||||
if ($this->tries > 1 && $this->retryThrow) {
|
||||
if ($potentialTries > 1 && $this->retryThrow) {
|
||||
$response->throw();
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (ConnectException $e) {
|
||||
$this->dispatchConnectionFailedEvent();
|
||||
$this->dispatchConnectionFailedEvent(new Request($e->getRequest()));
|
||||
|
||||
throw new ConnectionException($e->getMessage(), 0, $e);
|
||||
}
|
||||
@@ -1010,7 +1014,7 @@ class PendingRequest
|
||||
})
|
||||
->otherwise(function (OutOfBoundsException|TransferException $e) {
|
||||
if ($e instanceof ConnectException) {
|
||||
$this->dispatchConnectionFailedEvent();
|
||||
$this->dispatchConnectionFailedEvent(new Request($e->getRequest()));
|
||||
}
|
||||
|
||||
return $e instanceof RequestException && $e->hasResponse() ? $this->populateResponse($this->newResponse($e->getResponse())) : $e;
|
||||
@@ -1405,8 +1409,7 @@ class PendingRequest
|
||||
*/
|
||||
protected function dispatchResponseReceivedEvent(Response $response)
|
||||
{
|
||||
if (! ($dispatcher = $this->factory?->getDispatcher()) ||
|
||||
! $this->request) {
|
||||
if (! ($dispatcher = $this->factory?->getDispatcher()) || ! $this->request) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1416,12 +1419,13 @@ class PendingRequest
|
||||
/**
|
||||
* Dispatch the ConnectionFailed event if a dispatcher is available.
|
||||
*
|
||||
* @param \Illuminate\Http\Client\Request $request
|
||||
* @return void
|
||||
*/
|
||||
protected function dispatchConnectionFailedEvent()
|
||||
protected function dispatchConnectionFailedEvent(Request $request)
|
||||
{
|
||||
if ($dispatcher = $this->factory?->getDispatcher()) {
|
||||
$dispatcher->dispatch(new ConnectionFailed($this->request));
|
||||
$dispatcher->dispatch(new ConnectionFailed($request));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class Pool
|
||||
* @param \Illuminate\Http\Client\Factory|null $factory
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Factory $factory = null)
|
||||
public function __construct(?Factory $factory = null)
|
||||
{
|
||||
$this->factory = $factory ?: new Factory();
|
||||
$this->handler = Utils::chooseHandler();
|
||||
|
||||
@@ -120,7 +120,7 @@ trait InteractsWithInput
|
||||
* @param callable|null $default
|
||||
* @return $this|mixed
|
||||
*/
|
||||
public function whenHas($key, callable $callback, callable $default = null)
|
||||
public function whenHas($key, callable $callback, ?callable $default = null)
|
||||
{
|
||||
if ($this->has($key)) {
|
||||
return $callback(data_get($this->all(), $key)) ?: $this;
|
||||
@@ -198,7 +198,7 @@ trait InteractsWithInput
|
||||
* @param callable|null $default
|
||||
* @return $this|mixed
|
||||
*/
|
||||
public function whenFilled($key, callable $callback, callable $default = null)
|
||||
public function whenFilled($key, callable $callback, ?callable $default = null)
|
||||
{
|
||||
if ($this->filled($key)) {
|
||||
return $callback(data_get($this->all(), $key)) ?: $this;
|
||||
@@ -232,7 +232,7 @@ trait InteractsWithInput
|
||||
* @param callable|null $default
|
||||
* @return $this|mixed
|
||||
*/
|
||||
public function whenMissing($key, callable $callback, callable $default = null)
|
||||
public function whenMissing($key, callable $callback, ?callable $default = null)
|
||||
{
|
||||
if ($this->missing($key)) {
|
||||
return $callback(data_get($this->all(), $key)) ?: $this;
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Illuminate\Http\Exceptions;
|
||||
|
||||
use RuntimeException;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Throwable;
|
||||
|
||||
class HttpResponseException extends RuntimeException
|
||||
{
|
||||
@@ -18,10 +19,13 @@ class HttpResponseException extends RuntimeException
|
||||
* Create a new HTTP response exception instance.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Response $response
|
||||
* @param \Throwable $previous
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Response $response)
|
||||
public function __construct(Response $response, ?Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($previous?->getMessage() ?? '', $previous?->getCode() ?? 0, $previous);
|
||||
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class PostTooLargeException extends HttpException
|
||||
* @param int $code
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($message = '', Throwable $previous = null, array $headers = [], $code = 0)
|
||||
public function __construct($message = '', ?Throwable $previous = null, array $headers = [], $code = 0)
|
||||
{
|
||||
parent::__construct(413, $message, $previous, $headers, $code);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ class ThrottleRequestsException extends TooManyRequestsHttpException
|
||||
* @param int $code
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($message = '', Throwable $previous = null, array $headers = [], $code = 0)
|
||||
public function __construct($message = '', ?Throwable $previous = null, array $headers = [], $code = 0)
|
||||
{
|
||||
parent::__construct(null, $message, $previous, $code, $headers);
|
||||
}
|
||||
|
||||
0
vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php
vendored
Normal file → Executable file
0
vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php
vendored
Normal file → Executable file
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Illuminate\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Vite;
|
||||
|
||||
@@ -17,7 +18,7 @@ class AddLinkHeadersForPreloadedAssets
|
||||
public function handle($request, $next)
|
||||
{
|
||||
return tap($next($request), function ($response) {
|
||||
if (Vite::preloadedAssets() !== []) {
|
||||
if ($response instanceof Response && Vite::preloadedAssets() !== []) {
|
||||
$response->header('Link', Collection::make(Vite::preloadedAssets())
|
||||
->map(fn ($attributes, $url) => "<{$url}>; ".implode('; ', $attributes))
|
||||
->join(', '));
|
||||
|
||||
@@ -49,6 +49,10 @@ class TrustProxies
|
||||
{
|
||||
$trustedIps = $this->proxies() ?: config('trustedproxy.proxies');
|
||||
|
||||
if (is_null($trustedIps) && laravel_cloud()) {
|
||||
$trustedIps = '*';
|
||||
}
|
||||
|
||||
if ($trustedIps === '*' || $trustedIps === '**') {
|
||||
return $this->setTrustedProxyIpAddressesToTheCallingIp($request);
|
||||
}
|
||||
|
||||
2
vendor/laravel/framework/src/Illuminate/Http/RedirectResponse.php
vendored
Normal file → Executable file
2
vendor/laravel/framework/src/Illuminate/Http/RedirectResponse.php
vendored
Normal file → Executable file
@@ -71,7 +71,7 @@ class RedirectResponse extends BaseRedirectResponse
|
||||
* @param array|null $input
|
||||
* @return $this
|
||||
*/
|
||||
public function withInput(array $input = null)
|
||||
public function withInput(?array $input = null)
|
||||
{
|
||||
$this->session->flashInput($this->removeFilesFromInput(
|
||||
! is_null($input) ? $input : $this->request->input()
|
||||
|
||||
@@ -404,7 +404,7 @@ class Request extends SymfonyRequest implements Arrayable, ArrayAccess
|
||||
public function json($key = null, $default = null)
|
||||
{
|
||||
if (! isset($this->json)) {
|
||||
$this->json = new InputBag((array) json_decode($this->getContent(), true));
|
||||
$this->json = new InputBag((array) json_decode($this->getContent() ?: '[]', true));
|
||||
}
|
||||
|
||||
if (is_null($key)) {
|
||||
@@ -499,7 +499,7 @@ class Request extends SymfonyRequest implements Arrayable, ArrayAccess
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null): static
|
||||
public function duplicate(?array $query = null, ?array $request = null, ?array $attributes = null, ?array $cookies = null, ?array $files = null, ?array $server = null): static
|
||||
{
|
||||
return parent::duplicate($query, $request, $attributes, $cookies, $this->filterFiles($files), $server);
|
||||
}
|
||||
|
||||
@@ -266,15 +266,17 @@ trait ConditionallyLoadsAttributes
|
||||
return value($default);
|
||||
}
|
||||
|
||||
$loadedValue = $this->resource->{$relationship};
|
||||
|
||||
if (func_num_args() === 1) {
|
||||
return $this->resource->{$relationship};
|
||||
return $loadedValue;
|
||||
}
|
||||
|
||||
if ($this->resource->{$relationship} === null) {
|
||||
if ($loadedValue === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
return value($value);
|
||||
return value($value, $loadedValue);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,6 +12,7 @@ use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\ConditionallyLoadsAttributes;
|
||||
use Illuminate\Http\Resources\DelegatesToResource;
|
||||
use JsonException;
|
||||
use JsonSerializable;
|
||||
|
||||
class JsonResource implements ArrayAccess, JsonSerializable, Responsable, UrlRoutable
|
||||
@@ -144,10 +145,10 @@ class JsonResource implements ArrayAccess, JsonSerializable, Responsable, UrlRou
|
||||
*/
|
||||
public function toJson($options = 0)
|
||||
{
|
||||
$json = json_encode($this->jsonSerialize(), $options);
|
||||
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw JsonEncodingException::forResource($this, json_last_error_msg());
|
||||
try {
|
||||
$json = json_encode($this->jsonSerialize(), $options | JSON_THROW_ON_ERROR);
|
||||
} catch (JsonException $e) {
|
||||
throw JsonEncodingException::forResource($this, $e->getMessage());
|
||||
}
|
||||
|
||||
return $json;
|
||||
|
||||
0
vendor/laravel/framework/src/Illuminate/Http/Response.php
vendored
Normal file → Executable file
0
vendor/laravel/framework/src/Illuminate/Http/Response.php
vendored
Normal file → Executable file
0
vendor/laravel/framework/src/Illuminate/Http/composer.json
vendored
Normal file → Executable file
0
vendor/laravel/framework/src/Illuminate/Http/composer.json
vendored
Normal file → Executable file
Reference in New Issue
Block a user