11
11
12
12
namespace Symfony \Bridge \PsrHttpMessage \Tests \Fixtures ;
13
13
14
+ use Psr \Http \Message \RequestInterface ;
14
15
use Psr \Http \Message \ServerRequestInterface ;
15
16
use Psr \Http \Message \StreamInterface ;
16
17
use Psr \Http \Message \UriInterface ;
@@ -33,6 +34,10 @@ class ServerRequest extends Message implements ServerRequestInterface
33
34
public function __construct ($ version = '1.1 ' , array $ headers = [], StreamInterface $ body = null , $ requestTarget = '/ ' , $ method = 'GET ' , $ uri = null , array $ server = [], array $ cookies = [], array $ query = [], array $ uploadedFiles = [], $ data = null , array $ attributes = [])
34
35
{
35
36
parent ::__construct ($ version , $ headers , $ body );
37
+
38
+ if (!($ uri instanceof UriInterface)) {
39
+ $ uri = new Uri ((string ) $ uri );
40
+ }
36
41
37
42
$ this ->requestTarget = $ requestTarget ;
38
43
$ this ->method = $ method ;
@@ -52,10 +57,8 @@ public function getRequestTarget(): string
52
57
53
58
/**
54
59
* {@inheritdoc}
55
- *
56
- * @return static
57
60
*/
58
- public function withRequestTarget ($ requestTarget )
61
+ public function withRequestTarget ($ requestTarget ): RequestInterface
59
62
{
60
63
throw new \BadMethodCallException ('Not implemented. ' );
61
64
}
@@ -67,20 +70,16 @@ public function getMethod(): string
67
70
68
71
/**
69
72
* {@inheritdoc}
70
- *
71
- * @return static
72
73
*/
73
- public function withMethod ($ method )
74
+ public function withMethod ($ method ): RequestInterface
74
75
{
75
76
throw new \BadMethodCallException ('Not implemented. ' );
76
77
}
77
78
78
79
/**
79
80
* {@inheritdoc}
80
- *
81
- * @return UriInterface
82
81
*/
83
- public function getUri ()
82
+ public function getUri (): UriInterface
84
83
{
85
84
return $ this ->uri ;
86
85
}
@@ -90,7 +89,7 @@ public function getUri()
90
89
*
91
90
* @return static
92
91
*/
93
- public function withUri (UriInterface $ uri , $ preserveHost = false )
92
+ public function withUri (UriInterface $ uri , $ preserveHost = false ): RequestInterface
94
93
{
95
94
throw new \BadMethodCallException ('Not implemented. ' );
96
95
}
@@ -110,7 +109,7 @@ public function getCookieParams(): array
110
109
*
111
110
* @return static
112
111
*/
113
- public function withCookieParams (array $ cookies )
112
+ public function withCookieParams (array $ cookies ): ServerRequestInterface
114
113
{
115
114
throw new \BadMethodCallException ('Not implemented. ' );
116
115
}
@@ -125,7 +124,7 @@ public function getQueryParams(): array
125
124
*
126
125
* @return static
127
126
*/
128
- public function withQueryParams (array $ query )
127
+ public function withQueryParams (array $ query ): ServerRequestInterface
129
128
{
130
129
throw new \BadMethodCallException ('Not implemented. ' );
131
130
}
@@ -140,7 +139,7 @@ public function getUploadedFiles(): array
140
139
*
141
140
* @return static
142
141
*/
143
- public function withUploadedFiles (array $ uploadedFiles )
142
+ public function withUploadedFiles (array $ uploadedFiles ): ServerRequestInterface
144
143
{
145
144
throw new \BadMethodCallException ('Not implemented. ' );
146
145
}
@@ -160,7 +159,7 @@ public function getParsedBody()
160
159
*
161
160
* @return static
162
161
*/
163
- public function withParsedBody ($ data )
162
+ public function withParsedBody ($ data ): ServerRequestInterface
164
163
{
165
164
throw new \BadMethodCallException ('Not implemented. ' );
166
165
}
@@ -185,7 +184,7 @@ public function getAttribute($name, $default = null)
185
184
*
186
185
* @return static
187
186
*/
188
- public function withAttribute ($ name , $ value )
187
+ public function withAttribute ($ name , $ value ): ServerRequestInterface
189
188
{
190
189
throw new \BadMethodCallException ('Not implemented. ' );
191
190
}
@@ -195,7 +194,7 @@ public function withAttribute($name, $value)
195
194
*
196
195
* @return static
197
196
*/
198
- public function withoutAttribute ($ name )
197
+ public function withoutAttribute ($ name ): ServerRequestInterface
199
198
{
200
199
throw new \BadMethodCallException ('Not implemented. ' );
201
200
}
0 commit comments