29
29
* you need to also implement the getScript() method.
30
30
*
31
31
* @author Fabien Potencier <[email protected] >
32
+ *
33
+ * @template TRequest of object
34
+ * @template TResponse of object
32
35
*/
33
36
abstract class AbstractBrowser
34
37
{
35
38
protected History $ history ;
36
39
protected CookieJar $ cookieJar ;
37
40
protected array $ server = [];
38
41
protected Request $ internalRequest ;
42
+ /** @psalm-var TRequest */
39
43
protected object $ request ;
40
44
protected Response $ internalResponse ;
45
+ /** @psalm-var TResponse */
41
46
protected object $ response ;
42
47
protected Crawler $ crawler ;
43
48
protected bool $ useHtml5Parser = true ;
@@ -221,6 +226,8 @@ public function getInternalResponse(): Response
221
226
* The origin response is the response instance that is returned
222
227
* by the code that handles requests.
223
228
*
229
+ * @psalm-return TResponse
230
+ *
224
231
* @see doRequest()
225
232
*/
226
233
public function getResponse (): object
@@ -242,6 +249,8 @@ public function getInternalRequest(): Request
242
249
* The origin request is the request instance that is sent
243
250
* to the code that handles requests.
244
251
*
252
+ * @psalm-return TRequest
253
+ *
245
254
* @see doRequest()
246
255
*/
247
256
public function getRequest (): object
@@ -402,7 +411,9 @@ public function request(string $method, string $uri, array $parameters = [], arr
402
411
/**
403
412
* Makes a request in another process.
404
413
*
405
- * @return object
414
+ * @psalm-param TRequest $request
415
+ *
416
+ * @psalm-return TResponse
406
417
*
407
418
* @throws \RuntimeException When processing returns exit code
408
419
*/
@@ -437,13 +448,17 @@ protected function doRequestInProcess(object $request)
437
448
/**
438
449
* Makes a request.
439
450
*
440
- * @return object
451
+ * @psalm-param TRequest $request
452
+ *
453
+ * @psalm-return TResponse
441
454
*/
442
455
abstract protected function doRequest (object $ request );
443
456
444
457
/**
445
458
* Returns the script to execute when the request must be insulated.
446
459
*
460
+ * @psalm-param TRequest $request
461
+ *
447
462
* @param object $request An origin request instance
448
463
*
449
464
* @return string
@@ -459,6 +474,8 @@ protected function getScript(object $request)
459
474
* Filters the BrowserKit request to the origin one.
460
475
*
461
476
* @return object
477
+ *
478
+ * @psalm-return TRequest
462
479
*/
463
480
protected function filterRequest (Request $ request )
464
481
{
@@ -468,6 +485,8 @@ protected function filterRequest(Request $request)
468
485
/**
469
486
* Filters the origin response to the BrowserKit one.
470
487
*
488
+ * @psalm-param TResponse $response
489
+ *
471
490
* @return Response
472
491
*/
473
492
protected function filterResponse (object $ response )
0 commit comments