1
1
<?php
2
2
3
+ declare (strict_types=1 );
4
+
3
5
namespace Codeception \Lib \Connector ;
4
6
5
7
use Closure ;
9
11
use Phalcon \Http ;
10
12
use Phalcon \Mvc \Application ;
11
13
use Phalcon \Mvc \Micro as MicroApplication ;
14
+ use ReflectionException ;
12
15
use ReflectionProperty ;
13
16
use RuntimeException ;
14
- use Symfony \Component \BrowserKit \AbstractBrowser as Client ;
17
+ use Symfony \Component \BrowserKit \AbstractBrowser ;
15
18
use Symfony \Component \BrowserKit \Cookie ;
19
+ use Symfony \Component \BrowserKit \Request ;
16
20
use Symfony \Component \BrowserKit \Response ;
17
21
18
- class Phalcon4 extends Client
22
+ class Phalcon4 extends AbstractBrowser
19
23
{
20
24
use PhpSuperGlobalsConverter;
21
25
@@ -30,7 +34,7 @@ class Phalcon4 extends Client
30
34
*
31
35
* @param mixed $application
32
36
*/
33
- public function setApplication ($ application )
37
+ public function setApplication ($ application ): void
34
38
{
35
39
$ this ->application = $ application ;
36
40
}
@@ -43,10 +47,11 @@ public function setApplication($application)
43
47
public function getApplication ()
44
48
{
45
49
$ application = $ this ->application ;
46
-
47
50
if ($ application instanceof Closure) {
48
51
return $ application ();
49
- } elseif (is_string ($ application )) {
52
+ }
53
+
54
+ if (is_string ($ application )) {
50
55
/** @noinspection PhpIncludeInspection */
51
56
return require $ application ;
52
57
}
@@ -57,12 +62,11 @@ public function getApplication()
57
62
/**
58
63
* Makes a request.
59
64
*
60
- * @param \Symfony\Component\BrowserKit\ Request $request
65
+ * @param Request $request
61
66
*
62
- * @return \Symfony\Component\BrowserKit\Response
63
- * @throws \RuntimeException
67
+ * @throws RuntimeException|ReflectionException
64
68
*/
65
- public function doRequest ($ request )
69
+ public function doRequest ($ request ): Response
66
70
{
67
71
$ application = $ this ->getApplication ();
68
72
if (!$ application instanceof Application && !$ application instanceof MicroApplication) {
@@ -99,7 +103,7 @@ public function doRequest($request)
99
103
$ _POST = $ _REQUEST ;
100
104
}
101
105
102
- parse_str ($ queryString , $ output );
106
+ parse_str (( string ) $ queryString , $ output );
103
107
foreach ($ output as $ k => $ v ) {
104
108
$ _GET [$ k ] = $ v ;
105
109
}
@@ -125,12 +129,14 @@ public function doRequest($request)
125
129
126
130
$ headersProperty = new ReflectionProperty ($ headers , 'headers ' );
127
131
$ headersProperty ->setAccessible (true );
132
+
128
133
$ headers = $ headersProperty ->getValue ($ headers );
129
134
if (!is_array ($ headers )) {
130
135
$ headers = [];
131
136
}
132
137
133
138
$ cookiesProperty = new ReflectionProperty ($ di ['cookies ' ], 'cookies ' );
139
+
134
140
$ cookiesProperty ->setAccessible (true );
135
141
$ cookies = $ cookiesProperty ->getValue ($ di ['cookies ' ]);
136
142
if (is_array ($ cookies )) {
@@ -156,7 +162,7 @@ public function doRequest($request)
156
162
157
163
return new Response (
158
164
$ response ->getContent () ?: '' ,
159
- $ status ? $ status : 200 ,
165
+ $ status !== 0 ? $ status : 200 ,
160
166
$ headers
161
167
);
162
168
}
0 commit comments