Skip to content

Commit b7f80ef

Browse files
authored
[12.x] Improve typehints for Http classes (#54783)
* typehints for Illuminate\Http * remove * remove phpstan-type
1 parent ea78060 commit b7f80ef

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

src/Illuminate/Http/Client/Factory.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ class Factory
6262
/**
6363
* The recorded response array.
6464
*
65-
* @var array
65+
* @var list<array{0: \Illuminate\Http\Client\Request, 1: \Illuminate\Http\Client\Response|null}>
6666
*/
6767
protected $recorded = [];
6868

6969
/**
7070
* All created response sequences.
7171
*
72-
* @var array
72+
* @var list<\Illuminate\Http\Client\ResponseSequence>
7373
*/
7474
protected $responseSequences = [];
7575

@@ -195,7 +195,7 @@ public static function failedRequest($body = null, $status = 200, $headers = [])
195195
* Create a new connection exception for use during stubbing.
196196
*
197197
* @param string|null $message
198-
* @return \GuzzleHttp\Promise\PromiseInterface
198+
* @return \Closure(\Illuminate\Http\Client\Request): \GuzzleHttp\Promise\PromiseInterface
199199
*/
200200
public static function failedConnection($message = null)
201201
{
@@ -221,7 +221,7 @@ public function sequence(array $responses = [])
221221
/**
222222
* Register a stub callable that will intercept requests and be able to return stub responses.
223223
*
224-
* @param callable|array|null $callback
224+
* @param callable|array<string, mixed>|null $callback
225225
* @return $this
226226
*/
227227
public function fake($callback = null)
@@ -283,7 +283,7 @@ public function fakeSequence($url = '*')
283283
* Stub the given URL using the given callback.
284284
*
285285
* @param string $url
286-
* @param \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface|callable|int|string|array $callback
286+
* @param \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface|callable|int|string|array|\Illuminate\Http\Client\ResponseSequence $callback
287287
* @return $this
288288
*/
289289
public function stubUrl($url, $callback)
@@ -371,7 +371,7 @@ public function recordRequestResponsePair($request, $response)
371371
/**
372372
* Assert that a request / response pair was recorded matching a given truth test.
373373
*
374-
* @param callable $callback
374+
* @param callable|(\Closure(\Illuminate\Http\Client\Request, \Illuminate\Http\Client\Response|null): bool) $callback
375375
* @return void
376376
*/
377377
public function assertSent($callback)
@@ -385,7 +385,7 @@ public function assertSent($callback)
385385
/**
386386
* Assert that the given request was sent in the given order.
387387
*
388-
* @param array $callbacks
388+
* @param list<string|(\Closure(\Illuminate\Http\Client\Request, \Illuminate\Http\Client\Response|null): bool)|callable> $callbacks
389389
* @return void
390390
*/
391391
public function assertSentInOrder($callbacks)
@@ -407,7 +407,7 @@ public function assertSentInOrder($callbacks)
407407
/**
408408
* Assert that a request / response pair was not recorded matching a given truth test.
409409
*
410-
* @param callable $callback
410+
* @param callable|(\Closure(\Illuminate\Http\Client\Request, \Illuminate\Http\Client\Response|null): bool) $callback
411411
* @return void
412412
*/
413413
public function assertNotSent($callback)
@@ -460,8 +460,8 @@ public function assertSequencesAreEmpty()
460460
/**
461461
* Get a collection of the request / response pairs matching the given truth test.
462462
*
463-
* @param callable $callback
464-
* @return \Illuminate\Support\Collection
463+
* @param (\Closure(\Illuminate\Http\Client\Request, \Illuminate\Http\Client\Response|null): bool)|callable $callback
464+
* @return \Illuminate\Support\Collection<int, array{0: \Illuminate\Http\Client\Request, 1: \Illuminate\Http\Client\Response|null}>
465465
*/
466466
public function recorded($callback = null)
467467
{

src/Illuminate/Http/Client/Pool.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Pool
2626
/**
2727
* The pool of requests.
2828
*
29-
* @var array
29+
* @var array<array-key, \Illuminate\Http\Client\PendingRequest>
3030
*/
3131
protected $pool = [];
3232

@@ -65,7 +65,7 @@ protected function asyncRequest()
6565
/**
6666
* Retrieve the requests in the pool.
6767
*
68-
* @return array
68+
* @return array<array-key, \Illuminate\Http\Client\PendingRequest>
6969
*/
7070
public function getRequests()
7171
{

src/Illuminate/Http/Client/Response.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public function serverError()
235235
/**
236236
* Execute the given callback if there was a server or client error.
237237
*
238-
* @param callable $callback
238+
* @param callable|(\Closure(\Illuminate\Http\Client\Response): mixed) $callback
239239
* @return $this
240240
*/
241241
public function onError(callable $callback)
@@ -339,7 +339,7 @@ public function throwIf($condition)
339339
/**
340340
* Throw an exception if the response status code matches the given code.
341341
*
342-
* @param callable|int $statusCode
342+
* @param int|(\Closure(int, \Illuminate\Http\Client\Response): bool)|callable $statusCode
343343
* @return $this
344344
*
345345
* @throws \Illuminate\Http\Client\RequestException
@@ -357,7 +357,7 @@ public function throwIfStatus($statusCode)
357357
/**
358358
* Throw an exception unless the response status code matches the given code.
359359
*
360-
* @param callable|int $statusCode
360+
* @param int|(\Closure(int, \Illuminate\Http\Client\Response): bool)|callable $statusCode
361361
* @return $this
362362
*
363363
* @throws \Illuminate\Http\Client\RequestException

0 commit comments

Comments
 (0)