11<?php
22
3+ declare (strict_types=1 );
4+
35namespace Codeception \Lib \Connector ;
46
57use Closure ;
911use Phalcon \Http ;
1012use Phalcon \Mvc \Application ;
1113use Phalcon \Mvc \Micro as MicroApplication ;
14+ use ReflectionException ;
1215use ReflectionProperty ;
1316use RuntimeException ;
14- use Symfony \Component \BrowserKit \AbstractBrowser as Client ;
17+ use Symfony \Component \BrowserKit \AbstractBrowser ;
1518use Symfony \Component \BrowserKit \Cookie ;
19+ use Symfony \Component \BrowserKit \Request ;
1620use Symfony \Component \BrowserKit \Response ;
1721
18- class Phalcon4 extends Client
22+ class Phalcon4 extends AbstractBrowser
1923{
2024 use PhpSuperGlobalsConverter;
2125
@@ -30,7 +34,7 @@ class Phalcon4 extends Client
3034 *
3135 * @param mixed $application
3236 */
33- public function setApplication ($ application )
37+ public function setApplication ($ application ): void
3438 {
3539 $ this ->application = $ application ;
3640 }
@@ -43,10 +47,11 @@ public function setApplication($application)
4347 public function getApplication ()
4448 {
4549 $ application = $ this ->application ;
46-
4750 if ($ application instanceof Closure) {
4851 return $ application ();
49- } elseif (is_string ($ application )) {
52+ }
53+
54+ if (is_string ($ application )) {
5055 /** @noinspection PhpIncludeInspection */
5156 return require $ application ;
5257 }
@@ -57,12 +62,11 @@ public function getApplication()
5762 /**
5863 * Makes a request.
5964 *
60- * @param \Symfony\Component\BrowserKit\ Request $request
65+ * @param Request $request
6166 *
62- * @return \Symfony\Component\BrowserKit\Response
63- * @throws \RuntimeException
67+ * @throws RuntimeException|ReflectionException
6468 */
65- public function doRequest ($ request )
69+ public function doRequest ($ request ): Response
6670 {
6771 $ application = $ this ->getApplication ();
6872 if (!$ application instanceof Application && !$ application instanceof MicroApplication) {
@@ -99,7 +103,7 @@ public function doRequest($request)
99103 $ _POST = $ _REQUEST ;
100104 }
101105
102- parse_str ($ queryString , $ output );
106+ parse_str (( string ) $ queryString , $ output );
103107 foreach ($ output as $ k => $ v ) {
104108 $ _GET [$ k ] = $ v ;
105109 }
@@ -125,12 +129,14 @@ public function doRequest($request)
125129
126130 $ headersProperty = new ReflectionProperty ($ headers , 'headers ' );
127131 $ headersProperty ->setAccessible (true );
132+
128133 $ headers = $ headersProperty ->getValue ($ headers );
129134 if (!is_array ($ headers )) {
130135 $ headers = [];
131136 }
132137
133138 $ cookiesProperty = new ReflectionProperty ($ di ['cookies ' ], 'cookies ' );
139+
134140 $ cookiesProperty ->setAccessible (true );
135141 $ cookies = $ cookiesProperty ->getValue ($ di ['cookies ' ]);
136142 if (is_array ($ cookies )) {
@@ -156,7 +162,7 @@ public function doRequest($request)
156162
157163 return new Response (
158164 $ response ->getContent () ?: '' ,
159- $ status ? $ status : 200 ,
165+ $ status !== 0 ? $ status : 200 ,
160166 $ headers
161167 );
162168 }
0 commit comments