@@ -75,10 +75,8 @@ public function followMetaRefresh(bool $followMetaRefresh = true)
7575
7676 /**
7777 * Returns whether client automatically follows redirects or not.
78- *
79- * @return bool
8078 */
81- public function isFollowingRedirects ()
79+ public function isFollowingRedirects (): bool
8280 {
8381 return $ this ->followRedirects ;
8482 }
@@ -94,10 +92,8 @@ public function setMaxRedirects(int $maxRedirects)
9492
9593 /**
9694 * Returns the maximum number of redirects that crawler can follow.
97- *
98- * @return int
9995 */
100- public function getMaxRedirects ()
96+ public function getMaxRedirects (): int
10197 {
10298 return $ this ->maxRedirects ;
10399 }
@@ -136,10 +132,8 @@ public function setServerParameter(string $key, string $value)
136132
137133 /**
138134 * Gets single server parameter for specified key.
139- *
140- * @return mixed
141135 */
142- public function getServerParameter (string $ key , mixed $ default = '' )
136+ public function getServerParameter (string $ key , mixed $ default = '' ): mixed
143137 {
144138 return $ this ->server [$ key ] ?? $ default ;
145139 }
@@ -175,30 +169,24 @@ public function jsonRequest(string $method, string $uri, array $parameters = [],
175169
176170 /**
177171 * Returns the History instance.
178- *
179- * @return History
180172 */
181- public function getHistory ()
173+ public function getHistory (): History
182174 {
183175 return $ this ->history ;
184176 }
185177
186178 /**
187179 * Returns the CookieJar instance.
188- *
189- * @return CookieJar
190180 */
191- public function getCookieJar ()
181+ public function getCookieJar (): CookieJar
192182 {
193183 return $ this ->cookieJar ;
194184 }
195185
196186 /**
197187 * Returns the current Crawler instance.
198- *
199- * @return Crawler
200188 */
201- public function getCrawler ()
189+ public function getCrawler (): Crawler
202190 {
203191 if (null === $ this ->crawler ) {
204192 throw new BadMethodCallException (sprintf ('The "request()" method must be called before "%s()". ' , __METHOD__ ));
@@ -209,10 +197,8 @@ public function getCrawler()
209197
210198 /**
211199 * Returns the current BrowserKit Response instance.
212- *
213- * @return Response
214200 */
215- public function getInternalResponse ()
201+ public function getInternalResponse (): Response
216202 {
217203 if (null === $ this ->internalResponse ) {
218204 throw new BadMethodCallException (sprintf ('The "request()" method must be called before "%s()". ' , __METHOD__ ));
@@ -227,11 +213,9 @@ public function getInternalResponse()
227213 * The origin response is the response instance that is returned
228214 * by the code that handles requests.
229215 *
230- * @return object
231- *
232216 * @see doRequest()
233217 */
234- public function getResponse ()
218+ public function getResponse (): object
235219 {
236220 if (null === $ this ->response ) {
237221 throw new BadMethodCallException (sprintf ('The "request()" method must be called before "%s()". ' , __METHOD__ ));
@@ -242,10 +226,8 @@ public function getResponse()
242226
243227 /**
244228 * Returns the current BrowserKit Request instance.
245- *
246- * @return Request
247229 */
248- public function getInternalRequest ()
230+ public function getInternalRequest (): Request
249231 {
250232 if (null === $ this ->internalRequest ) {
251233 throw new BadMethodCallException (sprintf ('The "request()" method must be called before "%s()". ' , __METHOD__ ));
@@ -260,11 +242,9 @@ public function getInternalRequest()
260242 * The origin request is the request instance that is sent
261243 * to the code that handles requests.
262244 *
263- * @return object
264- *
265245 * @see doRequest()
266246 */
267- public function getRequest ()
247+ public function getRequest (): object
268248 {
269249 if (null === $ this ->request ) {
270250 throw new BadMethodCallException (sprintf ('The "request()" method must be called before "%s()". ' , __METHOD__ ));
@@ -275,10 +255,8 @@ public function getRequest()
275255
276256 /**
277257 * Clicks on a given link.
278- *
279- * @return Crawler
280258 */
281- public function click (Link $ link )
259+ public function click (Link $ link ): Crawler
282260 {
283261 if ($ link instanceof Form) {
284262 return $ this ->submit ($ link );
@@ -306,10 +284,8 @@ public function clickLink(string $linkText): Crawler
306284 *
307285 * @param array $values An array of form field values
308286 * @param array $serverParameters An array of server parameters
309- *
310- * @return Crawler
311287 */
312- public function submit (Form $ form , array $ values = [], array $ serverParameters = [])
288+ public function submit (Form $ form , array $ values = [], array $ serverParameters = []): Crawler
313289 {
314290 $ form ->setValues ($ values );
315291
@@ -347,10 +323,8 @@ public function submitForm(string $button, array $fieldValues = [], string $meth
347323 * @param array $server The server parameters (HTTP headers are referenced with an HTTP_ prefix as PHP does)
348324 * @param string $content The raw body data
349325 * @param bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload())
350- *
351- * @return Crawler
352326 */
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
354328 {
355329 if ($ this ->isMainRequest ) {
356330 $ this ->redirectCount = 0 ;
@@ -504,10 +478,8 @@ protected function filterResponse(object $response)
504478 * Creates a crawler.
505479 *
506480 * This method returns null if the DomCrawler component is not available.
507- *
508- * @return Crawler|null
509481 */
510- protected function createCrawlerFromContent (string $ uri , string $ content , string $ type )
482+ protected function createCrawlerFromContent (string $ uri , string $ content , string $ type ): ? Crawler
511483 {
512484 if (!class_exists (Crawler::class)) {
513485 return null ;
@@ -521,10 +493,8 @@ protected function createCrawlerFromContent(string $uri, string $content, string
521493
522494 /**
523495 * Goes back in the browser history.
524- *
525- * @return Crawler
526496 */
527- public function back ()
497+ public function back (): Crawler
528498 {
529499 do {
530500 $ request = $ this ->history ->back ();
@@ -535,10 +505,8 @@ public function back()
535505
536506 /**
537507 * Goes forward in the browser history.
538- *
539- * @return Crawler
540508 */
541- public function forward ()
509+ public function forward (): Crawler
542510 {
543511 do {
544512 $ request = $ this ->history ->forward ();
@@ -549,22 +517,18 @@ public function forward()
549517
550518 /**
551519 * Reloads the current browser.
552- *
553- * @return Crawler
554520 */
555- public function reload ()
521+ public function reload (): Crawler
556522 {
557523 return $ this ->requestFromRequest ($ this ->history ->current (), false );
558524 }
559525
560526 /**
561527 * Follow redirects?
562528 *
563- * @return Crawler
564- *
565529 * @throws \LogicException If request was not a redirect
566530 */
567- public function followRedirect ()
531+ public function followRedirect (): Crawler
568532 {
569533 if (empty ($ this ->redirect )) {
570534 throw new \LogicException ('The request was not redirected. ' );
@@ -639,7 +603,7 @@ public function restart()
639603 *
640604 * @return string An absolute URI
641605 */
642- protected function getAbsoluteUri (string $ uri )
606+ protected function getAbsoluteUri (string $ uri ): string
643607 {
644608 // already absolute?
645609 if (0 === strpos ($ uri , 'http:// ' ) || 0 === strpos ($ uri , 'https:// ' )) {
@@ -682,10 +646,8 @@ protected function getAbsoluteUri(string $uri)
682646 * Makes a request from a Request object directly.
683647 *
684648 * @param bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload())
685- *
686- * @return Crawler
687649 */
688- protected function requestFromRequest (Request $ request , bool $ changeHistory = true )
650+ protected function requestFromRequest (Request $ request , bool $ changeHistory = true ): Crawler
689651 {
690652 return $ this ->request ($ request ->getMethod (), $ request ->getUri (), $ request ->getParameters (), $ request ->getFiles (), $ request ->getServer (), $ request ->getContent (), $ changeHistory );
691653 }
0 commit comments