-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[BrowserKit] Avoid nullable values in some Client's methods #26509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
|
||
namespace Symfony\Component\BrowserKit; | ||
|
||
use Symfony\Component\BrowserKit\Exception\BadMethodCallException; | ||
use Symfony\Component\DomCrawler\Crawler; | ||
use Symfony\Component\DomCrawler\Link; | ||
use Symfony\Component\DomCrawler\Form; | ||
|
@@ -183,20 +184,30 @@ public function getCookieJar() | |
/** | ||
* Returns the current Crawler instance. | ||
* | ||
* @return Crawler|null A Crawler instance | ||
* @return Crawler A Crawler instance | ||
*/ | ||
public function getCrawler() | ||
{ | ||
if (null === $this->crawler) { | ||
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', __METHOD__), E_USER_DEPRECATED); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add the exception that would be thrown in 5.0 and comment it? That will help when we remove the deprecation notices. Thanks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fabpot Please review There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I was not clear enough. We cannot add the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
// throw new BadMethodCallException(sprintf('The "request()" method must be called before the "%s()" one', __METHOD__)); | ||
} | ||
|
||
return $this->crawler; | ||
} | ||
|
||
/** | ||
* Returns the current BrowserKit Response instance. | ||
* | ||
* @return Response|null A BrowserKit Response instance | ||
* @return Response A BrowserKit Response instance | ||
*/ | ||
public function getInternalResponse() | ||
{ | ||
if (null === $this->internalResponse) { | ||
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', __METHOD__), E_USER_DEPRECATED); | ||
// throw new BadMethodCallException(sprintf('The "request()" method must be called before the "%s()" one', __METHOD__)); | ||
} | ||
|
||
return $this->internalResponse; | ||
} | ||
|
||
|
@@ -206,22 +217,32 @@ public function getInternalResponse() | |
* The origin response is the response instance that is returned | ||
* by the code that handles requests. | ||
* | ||
* @return object|null A response instance | ||
* @return object A response instance | ||
* | ||
* @see doRequest() | ||
*/ | ||
public function getResponse() | ||
{ | ||
if (null === $this->response) { | ||
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', __METHOD__), E_USER_DEPRECATED); | ||
// throw new BadMethodCallException(sprintf('The "request()" method must be called before the "%s()" one', __METHOD__)); | ||
} | ||
|
||
return $this->response; | ||
} | ||
|
||
/** | ||
* Returns the current BrowserKit Request instance. | ||
* | ||
* @return Request|null A BrowserKit Request instance | ||
* @return Request A BrowserKit Request instance | ||
*/ | ||
public function getInternalRequest() | ||
{ | ||
if (null === $this->internalRequest) { | ||
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', __METHOD__), E_USER_DEPRECATED); | ||
// throw new BadMethodCallException(sprintf('The "request()" method must be called before the "%s()" one', __METHOD__)); | ||
} | ||
|
||
return $this->internalRequest; | ||
} | ||
|
||
|
@@ -231,12 +252,17 @@ public function getInternalRequest() | |
* The origin request is the request instance that is sent | ||
* to the code that handles requests. | ||
* | ||
* @return object|null A Request instance | ||
* @return object A Request instance | ||
* | ||
* @see doRequest() | ||
*/ | ||
public function getRequest() | ||
{ | ||
if (null === $this->request) { | ||
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', __METHOD__), E_USER_DEPRECATED); | ||
// throw new BadMethodCallException(sprintf('The "request()" method must be called before the "%s()" one', __METHOD__)); | ||
} | ||
|
||
return $this->request; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\BrowserKit\Exception; | ||
|
||
class BadMethodCallException extends \BadMethodCallException | ||
{ | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,8 +25,8 @@ | |
* | ||
* @author Fabien Potencier <[email protected]> | ||
* | ||
* @method Request|null getRequest() A Request instance | ||
* @method Response|null getResponse() A Response instance | ||
* @method Request getRequest() A Request instance | ||
* @method Response getResponse() A Response instance | ||
*/ | ||
class Client extends BaseClient | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be reverted as it's still valid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null
is returned only for BC. There are no cases whennull
might be returned.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fact is it's
Crawler|null
until 5.0to me this is different then switching to new API for parameters (
@param
), we where want users to provide correct input beforehand.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't document deprecated APIs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 sounds fair while thinking about it. Deprecation message should tell either way.