From b4aed2425e9a06ae32a7194935b5d069315a1b00 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 4 Oct 2016 21:36:48 -0400 Subject: [PATCH] Use fewer empty calls. data() helps us avoid notice errors, so we don't need to rely on empty(). --- src/Controller/Component/CsrfComponent.php | 2 +- src/Controller/Component/SecurityComponent.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Controller/Component/CsrfComponent.php b/src/Controller/Component/CsrfComponent.php index 1fe2a9dfa79..23dc86678c8 100644 --- a/src/Controller/Component/CsrfComponent.php +++ b/src/Controller/Component/CsrfComponent.php @@ -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']]); } diff --git a/src/Controller/Component/SecurityComponent.php b/src/Controller/Component/SecurityComponent.php index 0b5866de864..fa8a6e73d9b 100644 --- a/src/Controller/Component/SecurityComponent.php +++ b/src/Controller/Component/SecurityComponent.php @@ -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); @@ -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']; @@ -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);