@@ -75,10 +75,8 @@ public function followMetaRefresh(bool $followMetaRefresh = true)
75
75
76
76
/**
77
77
* Returns whether client automatically follows redirects or not.
78
- *
79
- * @return bool
80
78
*/
81
- public function isFollowingRedirects ()
79
+ public function isFollowingRedirects (): bool
82
80
{
83
81
return $ this ->followRedirects ;
84
82
}
@@ -94,10 +92,8 @@ public function setMaxRedirects(int $maxRedirects)
94
92
95
93
/**
96
94
* Returns the maximum number of redirects that crawler can follow.
97
- *
98
- * @return int
99
95
*/
100
- public function getMaxRedirects ()
96
+ public function getMaxRedirects (): int
101
97
{
102
98
return $ this ->maxRedirects ;
103
99
}
@@ -136,10 +132,8 @@ public function setServerParameter(string $key, string $value)
136
132
137
133
/**
138
134
* Gets single server parameter for specified key.
139
- *
140
- * @return mixed
141
135
*/
142
- public function getServerParameter (string $ key , mixed $ default = '' )
136
+ public function getServerParameter (string $ key , mixed $ default = '' ): mixed
143
137
{
144
138
return $ this ->server [$ key ] ?? $ default ;
145
139
}
@@ -175,30 +169,24 @@ public function jsonRequest(string $method, string $uri, array $parameters = [],
175
169
176
170
/**
177
171
* Returns the History instance.
178
- *
179
- * @return History
180
172
*/
181
- public function getHistory ()
173
+ public function getHistory (): History
182
174
{
183
175
return $ this ->history ;
184
176
}
185
177
186
178
/**
187
179
* Returns the CookieJar instance.
188
- *
189
- * @return CookieJar
190
180
*/
191
- public function getCookieJar ()
181
+ public function getCookieJar (): CookieJar
192
182
{
193
183
return $ this ->cookieJar ;
194
184
}
195
185
196
186
/**
197
187
* Returns the current Crawler instance.
198
- *
199
- * @return Crawler
200
188
*/
201
- public function getCrawler ()
189
+ public function getCrawler (): Crawler
202
190
{
203
191
if (null === $ this ->crawler ) {
204
192
throw new BadMethodCallException (sprintf ('The "request()" method must be called before "%s()". ' , __METHOD__ ));
@@ -209,10 +197,8 @@ public function getCrawler()
209
197
210
198
/**
211
199
* Returns the current BrowserKit Response instance.
212
- *
213
- * @return Response
214
200
*/
215
- public function getInternalResponse ()
201
+ public function getInternalResponse (): Response
216
202
{
217
203
if (null === $ this ->internalResponse ) {
218
204
throw new BadMethodCallException (sprintf ('The "request()" method must be called before "%s()". ' , __METHOD__ ));
@@ -227,11 +213,9 @@ public function getInternalResponse()
227
213
* The origin response is the response instance that is returned
228
214
* by the code that handles requests.
229
215
*
230
- * @return object
231
- *
232
216
* @see doRequest()
233
217
*/
234
- public function getResponse ()
218
+ public function getResponse (): object
235
219
{
236
220
if (null === $ this ->response ) {
237
221
throw new BadMethodCallException (sprintf ('The "request()" method must be called before "%s()". ' , __METHOD__ ));
@@ -242,10 +226,8 @@ public function getResponse()
242
226
243
227
/**
244
228
* Returns the current BrowserKit Request instance.
245
- *
246
- * @return Request
247
229
*/
248
- public function getInternalRequest ()
230
+ public function getInternalRequest (): Request
249
231
{
250
232
if (null === $ this ->internalRequest ) {
251
233
throw new BadMethodCallException (sprintf ('The "request()" method must be called before "%s()". ' , __METHOD__ ));
@@ -260,11 +242,9 @@ public function getInternalRequest()
260
242
* The origin request is the request instance that is sent
261
243
* to the code that handles requests.
262
244
*
263
- * @return object
264
- *
265
245
* @see doRequest()
266
246
*/
267
- public function getRequest ()
247
+ public function getRequest (): object
268
248
{
269
249
if (null === $ this ->request ) {
270
250
throw new BadMethodCallException (sprintf ('The "request()" method must be called before "%s()". ' , __METHOD__ ));
@@ -275,10 +255,8 @@ public function getRequest()
275
255
276
256
/**
277
257
* Clicks on a given link.
278
- *
279
- * @return Crawler
280
258
*/
281
- public function click (Link $ link )
259
+ public function click (Link $ link ): Crawler
282
260
{
283
261
if ($ link instanceof Form) {
284
262
return $ this ->submit ($ link );
@@ -306,10 +284,8 @@ public function clickLink(string $linkText): Crawler
306
284
*
307
285
* @param array $values An array of form field values
308
286
* @param array $serverParameters An array of server parameters
309
- *
310
- * @return Crawler
311
287
*/
312
- public function submit (Form $ form , array $ values = [], array $ serverParameters = [])
288
+ public function submit (Form $ form , array $ values = [], array $ serverParameters = []): Crawler
313
289
{
314
290
$ form ->setValues ($ values );
315
291
@@ -347,10 +323,8 @@ public function submitForm(string $button, array $fieldValues = [], string $meth
347
323
* @param array $server The server parameters (HTTP headers are referenced with an HTTP_ prefix as PHP does)
348
324
* @param string $content The raw body data
349
325
* @param bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload())
350
- *
351
- * @return Crawler
352
326
*/
353
- public function request (string $ method , string $ uri , array $ parameters = [], array $ files = [], array $ server = [], string $ content = null , bool $ changeHistory = true )
327
+ public function request (string $ method , string $ uri , array $ parameters = [], array $ files = [], array $ server = [], string $ content = null , bool $ changeHistory = true ): Crawler
354
328
{
355
329
if ($ this ->isMainRequest ) {
356
330
$ this ->redirectCount = 0 ;
@@ -504,10 +478,8 @@ protected function filterResponse(object $response)
504
478
* Creates a crawler.
505
479
*
506
480
* This method returns null if the DomCrawler component is not available.
507
- *
508
- * @return Crawler|null
509
481
*/
510
- protected function createCrawlerFromContent (string $ uri , string $ content , string $ type )
482
+ protected function createCrawlerFromContent (string $ uri , string $ content , string $ type ): ? Crawler
511
483
{
512
484
if (!class_exists (Crawler::class)) {
513
485
return null ;
@@ -521,10 +493,8 @@ protected function createCrawlerFromContent(string $uri, string $content, string
521
493
522
494
/**
523
495
* Goes back in the browser history.
524
- *
525
- * @return Crawler
526
496
*/
527
- public function back ()
497
+ public function back (): Crawler
528
498
{
529
499
do {
530
500
$ request = $ this ->history ->back ();
@@ -535,10 +505,8 @@ public function back()
535
505
536
506
/**
537
507
* Goes forward in the browser history.
538
- *
539
- * @return Crawler
540
508
*/
541
- public function forward ()
509
+ public function forward (): Crawler
542
510
{
543
511
do {
544
512
$ request = $ this ->history ->forward ();
@@ -549,22 +517,18 @@ public function forward()
549
517
550
518
/**
551
519
* Reloads the current browser.
552
- *
553
- * @return Crawler
554
520
*/
555
- public function reload ()
521
+ public function reload (): Crawler
556
522
{
557
523
return $ this ->requestFromRequest ($ this ->history ->current (), false );
558
524
}
559
525
560
526
/**
561
527
* Follow redirects?
562
528
*
563
- * @return Crawler
564
- *
565
529
* @throws \LogicException If request was not a redirect
566
530
*/
567
- public function followRedirect ()
531
+ public function followRedirect (): Crawler
568
532
{
569
533
if (empty ($ this ->redirect )) {
570
534
throw new \LogicException ('The request was not redirected. ' );
@@ -639,7 +603,7 @@ public function restart()
639
603
*
640
604
* @return string An absolute URI
641
605
*/
642
- protected function getAbsoluteUri (string $ uri )
606
+ protected function getAbsoluteUri (string $ uri ): string
643
607
{
644
608
// already absolute?
645
609
if (0 === strpos ($ uri , 'http:// ' ) || 0 === strpos ($ uri , 'https:// ' )) {
@@ -682,10 +646,8 @@ protected function getAbsoluteUri(string $uri)
682
646
* Makes a request from a Request object directly.
683
647
*
684
648
* @param bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload())
685
- *
686
- * @return Crawler
687
649
*/
688
- protected function requestFromRequest (Request $ request , bool $ changeHistory = true )
650
+ protected function requestFromRequest (Request $ request , bool $ changeHistory = true ): Crawler
689
651
{
690
652
return $ this ->request ($ request ->getMethod (), $ request ->getUri (), $ request ->getParameters (), $ request ->getFiles (), $ request ->getServer (), $ request ->getContent (), $ changeHistory );
691
653
}
0 commit comments