Skip to content

Commit

Permalink
Use fewer empty calls.
Browse files Browse the repository at this point in the history
data() helps us avoid notice errors, so we don't need to rely on
empty().
  • Loading branch information
markstory committed Oct 5, 2016
1 parent 1377aa8 commit b4aed24
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Controller/Component/CsrfComponent.php
Expand Up @@ -93,7 +93,7 @@ public function startup(Event $event)
if ($request->is('get') && $cookieData === null) {
$this->_setCookie($request, $response);
}
if ($request->is(['put', 'post', 'delete', 'patch']) || !empty($request->data())) {
if ($request->is(['put', 'post', 'delete', 'patch']) || $request->data()) {
$this->_validateToken($request);
unset($request->data[$this->_config['field']]);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Controller/Component/SecurityComponent.php
Expand Up @@ -109,7 +109,7 @@ public function startup(Event $event)
$controller = $event->subject();
$this->session = $this->request->session();
$this->_action = $this->request->param('action');
$hasData = !empty($this->request->data());
$hasData = (bool)$this->request->data();
try {
$this->_secureRequired($controller);
$this->_authRequired($controller);
Expand Down Expand Up @@ -266,7 +266,7 @@ protected function _authRequired(Controller $controller)
{
if (is_array($this->_config['requireAuth']) &&
!empty($this->_config['requireAuth']) &&
!empty($this->request->data())
$this->request->data()
) {
$requireAuth = $this->_config['requireAuth'];

Expand Down Expand Up @@ -318,7 +318,7 @@ protected function _authRequired(Controller $controller)
*/
protected function _validatePost(Controller $controller)
{
if (empty($controller->request->data())) {
if (!$controller->request->data()) {
return true;
}
$token = $this->_validToken($controller);
Expand Down

0 comments on commit b4aed24

Please sign in to comment.