2222 *
2323 * To make the actual request, you need to implement the doRequest() method.
2424 *
25- * HttpBrowser is an implementation that uses the HttpClient component
26- * to make real HTTP requests.
27- *
2825 * If you want to be able to run requests in their own process (insulated flag),
2926 * you need to also implement the getScript() method.
3027 *
@@ -51,9 +48,7 @@ abstract class AbstractBrowser
5148 private $ isMainRequest = true ;
5249
5350 /**
54- * @param array $server The server parameters (equivalent of $_SERVER)
55- * @param History $history A History instance to store the browser history
56- * @param CookieJar $cookieJar A CookieJar instance to store the cookies
51+ * @param array $server The server parameters (equivalent of $_SERVER)
5752 */
5853 public function __construct (array $ server = [], History $ history = null , CookieJar $ cookieJar = null )
5954 {
@@ -297,7 +292,6 @@ public function clickLink(string $linkText): Crawler
297292 /**
298293 * Submits a form.
299294 *
300- * @param Form $form A Form instance
301295 * @param array $values An array of form field values
302296 * @param array $serverParameters An array of server parameters
303297 *
@@ -366,7 +360,7 @@ public function request(string $method, string $uri, array $parameters = [], arr
366360 $ uri = preg_replace ('{^ ' .parse_url ($ uri , PHP_URL_SCHEME ).'} ' , $ server ['HTTPS ' ] ? 'https ' : 'http ' , $ uri );
367361 }
368362
369- if (!$ this ->history ->isEmpty ()) {
363+ if (!isset ( $ server [ ' HTTP_REFERER ' ]) && ! $ this ->history ->isEmpty ()) {
370364 $ server ['HTTP_REFERER ' ] = $ this ->history ->current ()->getUri ();
371365 }
372366
@@ -481,8 +475,6 @@ protected function getScript($request)
481475 /**
482476 * Filters the BrowserKit request to the origin one.
483477 *
484- * @param Request $request The BrowserKit Request to filter
485- *
486478 * @return object An origin request instance
487479 */
488480 protected function filterRequest (Request $ request )
@@ -685,8 +677,7 @@ protected function getAbsoluteUri(string $uri)
685677 /**
686678 * Makes a request from a Request object directly.
687679 *
688- * @param Request $request A Request instance
689- * @param bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload())
680+ * @param bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload())
690681 *
691682 * @return Crawler
692683 */
@@ -695,7 +686,7 @@ protected function requestFromRequest(Request $request, $changeHistory = true)
695686 return $ this ->request ($ request ->getMethod (), $ request ->getUri (), $ request ->getParameters (), $ request ->getFiles (), $ request ->getServer (), $ request ->getContent (), $ changeHistory );
696687 }
697688
698- private function updateServerFromUri ($ server , $ uri )
689+ private function updateServerFromUri (array $ server , string $ uri ): array
699690 {
700691 $ server ['HTTP_HOST ' ] = $ this ->extractHost ($ uri );
701692 $ scheme = parse_url ($ uri , PHP_URL_SCHEME );
@@ -705,7 +696,7 @@ private function updateServerFromUri($server, $uri)
705696 return $ server ;
706697 }
707698
708- private function extractHost ($ uri )
699+ private function extractHost (string $ uri ): ? string
709700 {
710701 $ host = parse_url ($ uri , PHP_URL_HOST );
711702
0 commit comments