Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[12.x] Improve typehints for Http classes #54783

Draft
wants to merge 3 commits into
base: 12.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/Illuminate/Http/Client/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ class Factory
/**
* The recorded response array.
*
* @var array
* @var list<array{0: \Illuminate\Http\Client\Request, 1: \Illuminate\Http\Client\Response|null}>
*/
protected $recorded = [];

/**
* All created response sequences.
*
* @var array
* @var list<\Illuminate\Http\Client\ResponseSequence>
*/
protected $responseSequences = [];

Expand Down Expand Up @@ -170,7 +170,7 @@ public static function response($body = null, $status = 200, $headers = [])
* Create a new connection exception for use during stubbing.
*
* @param string|null $message
* @return \GuzzleHttp\Promise\PromiseInterface
* @return \Closure(\Illuminate\Http\Client\Request): \GuzzleHttp\Promise\PromiseInterface
*/
public static function failedConnection($message = null)
{
Expand All @@ -196,7 +196,7 @@ public function sequence(array $responses = [])
/**
* Register a stub callable that will intercept requests and be able to return stub responses.
*
* @param callable|array|null $callback
* @param callable|array<string, mixed>|null $callback
* @return $this
*/
public function fake($callback = null)
Expand Down Expand Up @@ -258,7 +258,7 @@ public function fakeSequence($url = '*')
* Stub the given URL using the given callback.
*
* @param string $url
* @param \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface|callable|int|string|array $callback
* @param \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface|callable|int|string|array|\Illuminate\Http\Client\ResponseSequence $callback
* @return $this
*/
public function stubUrl($url, $callback)
Expand Down Expand Up @@ -346,7 +346,7 @@ public function recordRequestResponsePair($request, $response)
/**
* Assert that a request / response pair was recorded matching a given truth test.
*
* @param callable $callback
* @param callable|(\Closure(\Illuminate\Http\Client\Request, \Illuminate\Http\Client\Response|null): bool) $callback
* @return void
*/
public function assertSent($callback)
Expand All @@ -360,7 +360,7 @@ public function assertSent($callback)
/**
* Assert that the given request was sent in the given order.
*
* @param array $callbacks
* @param list<string|(\Closure(\Illuminate\Http\Client\Request, \Illuminate\Http\Client\Response|null): bool)|callable> $callbacks
* @return void
*/
public function assertSentInOrder($callbacks)
Expand All @@ -382,7 +382,7 @@ public function assertSentInOrder($callbacks)
/**
* Assert that a request / response pair was not recorded matching a given truth test.
*
* @param callable $callback
* @param callable|(\Closure(\Illuminate\Http\Client\Request, \Illuminate\Http\Client\Response|null): bool) $callback
* @return void
*/
public function assertNotSent($callback)
Expand Down Expand Up @@ -435,8 +435,8 @@ public function assertSequencesAreEmpty()
/**
* Get a collection of the request / response pairs matching the given truth test.
*
* @param callable $callback
* @return \Illuminate\Support\Collection
* @param (\Closure(\Illuminate\Http\Client\Request, \Illuminate\Http\Client\Response|null): bool)|callable $callback
* @return \Illuminate\Support\Collection<int, array{0: \Illuminate\Http\Client\Request, 1: \Illuminate\Http\Client\Response|null}>
*/
public function recorded($callback = null)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Http/Client/Pool.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Pool
/**
* The pool of requests.
*
* @var array
* @var array<array-key, \Illuminate\Http\Client\PendingRequest>
*/
protected $pool = [];

Expand Down Expand Up @@ -66,7 +66,7 @@ protected function asyncRequest()
/**
* Retrieve the requests in the pool.
*
* @return array
* @return array<array-key, \Illuminate\Http\Client\PendingRequest>
*/
public function getRequests()
{
Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Http/Client/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public function serverError()
/**
* Execute the given callback if there was a server or client error.
*
* @param callable $callback
* @param callable|(\Closure(\Illuminate\Http\Client\Response): mixed) $callback
* @return $this
*/
public function onError(callable $callback)
Expand Down Expand Up @@ -340,7 +340,7 @@ public function throwIf($condition)
/**
* Throw an exception if the response status code matches the given code.
*
* @param callable|int $statusCode
* @param int|(\Closure(int, \Illuminate\Http\Client\Response): bool)|callable $statusCode
* @return $this
*
* @throws \Illuminate\Http\Client\RequestException
Expand All @@ -358,7 +358,7 @@ public function throwIfStatus($statusCode)
/**
* Throw an exception unless the response status code matches the given code.
*
* @param callable|int $statusCode
* @param int|(\Closure(int, \Illuminate\Http\Client\Response): bool)|callable $statusCode
* @return $this
*
* @throws \Illuminate\Http\Client\RequestException
Expand Down
Loading