Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 068f87f

Browse files
committed
Avoid nullable values in some Client's methods
1 parent 9e82562 commit 068f87f

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

src/Symfony/Component/BrowserKit/Client.php

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,20 +183,28 @@ public function getCookieJar()
183183
/**
184184
* Returns the current Crawler instance.
185185
*
186-
* @return Crawler|null A Crawler instance
186+
* @return Crawler A Crawler instance
187187
*/
188188
public function getCrawler()
189189
{
190+
if (null === $this->crawler) {
191+
@trigger_error(sprintf('The %s() method calling before request() method is deprecated since 4.1 and will throw an exception in 5.0.', __METHOD__), E_USER_DEPRECATED);
192+
}
193+
190194
return $this->crawler;
191195
}
192196

193197
/**
194198
* Returns the current BrowserKit Response instance.
195199
*
196-
* @return Response|null A BrowserKit Response instance
200+
* @return Response A BrowserKit Response instance
197201
*/
198202
public function getInternalResponse()
199203
{
204+
if (null === $this->internalResponse) {
205+
@trigger_error(sprintf('The %s() method calling before request() method is deprecated since 4.1 and will throw an exception in 5.0.', __METHOD__), E_USER_DEPRECATED);
206+
}
207+
200208
return $this->internalResponse;
201209
}
202210

@@ -206,22 +214,30 @@ public function getInternalResponse()
206214
* The origin response is the response instance that is returned
207215
* by the code that handles requests.
208216
*
209-
* @return object|null A response instance
217+
* @return object A response instance
210218
*
211219
* @see doRequest()
212220
*/
213221
public function getResponse()
214222
{
223+
if (null === $this->response) {
224+
@trigger_error(sprintf('The %s() method calling before request() method is deprecated since 4.1 and will throw an exception in 5.0.', __METHOD__), E_USER_DEPRECATED);
225+
}
226+
215227
return $this->response;
216228
}
217229

218230
/**
219231
* Returns the current BrowserKit Request instance.
220232
*
221-
* @return Request|null A BrowserKit Request instance
233+
* @return Request A BrowserKit Request instance
222234
*/
223235
public function getInternalRequest()
224236
{
237+
if (null === $this->internalRequest) {
238+
@trigger_error(sprintf('The %s() method calling before request() method is deprecated since 4.1 and will throw an exception in 5.0.', __METHOD__), E_USER_DEPRECATED);
239+
}
240+
225241
return $this->internalRequest;
226242
}
227243

@@ -231,12 +247,16 @@ public function getInternalRequest()
231247
* The origin request is the request instance that is sent
232248
* to the code that handles requests.
233249
*
234-
* @return object|null A Request instance
250+
* @return object A Request instance
235251
*
236252
* @see doRequest()
237253
*/
238254
public function getRequest()
239255
{
256+
if (null === $this->request) {
257+
@trigger_error(sprintf('The %s() method calling before request() method is deprecated since 4.1 and will throw an exception in 5.0.', __METHOD__), E_USER_DEPRECATED);
258+
}
259+
240260
return $this->request;
241261
}
242262

src/Symfony/Component/HttpKernel/Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
*
2626
* @author Fabien Potencier <[email protected]>
2727
*
28-
* @method Request|null getRequest() A Request instance
29-
* @method Response|null getResponse() A Response instance
28+
* @method Request getRequest() A Request instance
29+
* @method Response getResponse() A Response instance
3030
*/
3131
class Client extends BaseClient
3232
{

0 commit comments

Comments
 (0)