1515use GuzzleHttp \Psr7 \Response as Psr7Response ;
1616use GuzzleHttp \Psr7 \Uri as Psr7Uri ;
1717use Symfony \Component \BrowserKit \AbstractBrowser as Client ;
18- use Symfony \Component \BrowserKit \Cookie ;
1918use Symfony \Component \BrowserKit \Request as BrowserKitRequest ;
2019use Symfony \Component \BrowserKit \Response as BrowserKitResponse ;
2120
@@ -27,10 +26,10 @@ class Guzzle extends Client
2726 ];
2827 protected $ refreshMaxInterval = 0 ;
2928
30- protected $ awsCredentials = null ;
31- protected $ awsSignature = null ;
29+ protected $ awsCredentials ;
30+ protected $ awsSignature ;
3231
33- /** @var \GuzzleHttp\Client */
32+ /** @var GuzzleClient */
3433 protected $ client ;
3534
3635 /**
@@ -49,7 +48,7 @@ public function setRefreshMaxInterval($seconds)
4948 $ this ->refreshMaxInterval = $ seconds ;
5049 }
5150
52- public function setClient (GuzzleClient & $ client )
51+ public function setClient (GuzzleClient $ client )
5352 {
5453 $ this ->client = $ client ;
5554 }
@@ -66,7 +65,7 @@ public function setClient(GuzzleClient &$client)
6665 */
6766 public function setHeader ($ name , $ value )
6867 {
69- if (strval ( $ value) === '' ) {
68+ if (( string ) $ value === '' ) {
7069 $ this ->deleteHeader ($ name );
7170 } else {
7271 $ this ->requestOptions ['headers ' ][$ name ] = $ value ;
@@ -101,9 +100,9 @@ public function setAuth($username, $password, $type = 'basic')
101100 /**
102101 * Taken from Mink\BrowserKitDriver
103102 *
104- * @param Response $response
103+ * @param Psr7Response $response
105104 *
106- * @return \Symfony\Component\BrowserKit\Response
105+ * @return BrowserKitResponse
107106 */
108107 protected function createResponse (Psr7Response $ response )
109108 {
@@ -120,7 +119,7 @@ protected function createResponse(Psr7Response $response)
120119 }
121120
122121 if (strpos ($ contentType , 'charset= ' ) === false ) {
123- if (preg_match ('/\ <meta[^\ >]+charset *= *[" \']?([a-zA-Z\-0-9]+)/i ' , $ body , $ matches )) {
122+ if (preg_match ('/<meta[^>]+charset *= *[" \']?([a-zA-Z\-0-9]+)/i ' , $ body , $ matches )) {
124123 $ contentType .= ';charset= ' . $ matches [1 ];
125124 }
126125 $ headers ['Content-Type ' ] = [$ contentType ];
@@ -131,7 +130,7 @@ protected function createResponse(Psr7Response $response)
131130 $ matches = [];
132131
133132 $ matchesMeta = preg_match (
134- '/\ <meta[^\ >]+http-equiv="refresh" content="\s*(\d*)\s*;\s*url=(.*?)"/i ' ,
133+ '/<meta[^>]+http-equiv="refresh" content="\s*(\d*)\s*;\s*url=(.*?)"/i ' ,
135134 $ body ,
136135 $ matches
137136 );
@@ -149,7 +148,7 @@ protected function createResponse(Psr7Response $response)
149148 $ uri = new Psr7Uri ($ this ->getAbsoluteUri ($ matches [2 ]));
150149 $ currentUri = new Psr7Uri ($ this ->getHistory ()->current ()->getUri ());
151150
152- if ($ uri ->withFragment ('' ) != $ currentUri ->withFragment ('' )) {
151+ if ($ uri ->withFragment ('' ) !== $ currentUri ->withFragment ('' )) {
153152 $ status = 302 ;
154153 $ headers ['Location ' ] = $ matchesMeta ? htmlspecialchars_decode ($ uri ) : (string )$ uri ;
155154 }
@@ -196,7 +195,7 @@ protected function doRequest($request)
196195 }
197196
198197 $ formData = $ this ->extractFormData ($ request );
199- if (empty ($ multipartData ) and $ formData ) {
198+ if (empty ($ multipartData ) && $ formData ) {
200199 $ options ['form_params ' ] = $ formData ;
201200 }
202201
@@ -292,7 +291,7 @@ protected function mapFiles($requestFiles, $arrayName = '')
292291 if (is_array ($ info )) {
293292 if (isset ($ info ['tmp_name ' ])) {
294293 if ($ info ['tmp_name ' ]) {
295- $ handle = fopen ($ info ['tmp_name ' ], 'r ' );
294+ $ handle = fopen ($ info ['tmp_name ' ], 'rb ' );
296295 $ filename = isset ($ info ['name ' ]) ? $ info ['name ' ] : null ;
297296 $ file = [
298297 'name ' => $ name ,
@@ -312,7 +311,7 @@ protected function mapFiles($requestFiles, $arrayName = '')
312311 } else {
313312 $ files [] = [
314313 'name ' => $ name ,
315- 'contents ' => fopen ($ info , 'r ' )
314+ 'contents ' => fopen ($ info , 'rb ' )
316315 ];
317316 }
318317 }
@@ -325,7 +324,6 @@ protected function extractCookies($host)
325324 $ jar = [];
326325 $ cookies = $ this ->getCookieJar ()->all ();
327326 foreach ($ cookies as $ cookie ) {
328- /** @var $cookie Cookie **/
329327 $ setCookie = SetCookie::fromString ((string )$ cookie );
330328 if (!$ setCookie ->getDomain ()) {
331329 $ setCookie ->setDomain ($ host );
0 commit comments