Skip to content

Commit

Permalink
Optimize Filters
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafakhudair authored and element-code committed Aug 2, 2021
1 parent 3eb533e commit 18d1d6d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
9 changes: 2 additions & 7 deletions system/Filters/CSRF.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

namespace CodeIgniter\Filters;

use CodeIgniter\HTTP\IncomingRequest;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\Response;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Security\Exceptions\SecurityException;
use Config\Services;
Expand All @@ -37,8 +35,7 @@ class CSRF implements FilterInterface
* sent back to the client, allowing for error pages,
* redirects, etc.
*
* @param IncomingRequest|RequestInterface $request
* @param array|null $arguments
* @param array|null $arguments
*
* @throws SecurityException
*
Expand Down Expand Up @@ -66,9 +63,7 @@ public function before(RequestInterface $request, $arguments = null)
/**
* We don't have anything to do here.
*
* @param IncomingRequest|RequestInterface $request
* @param Response|ResponseInterface $response
* @param array|null $arguments
* @param array|null $arguments
*
* @return mixed
*/
Expand Down
9 changes: 2 additions & 7 deletions system/Filters/DebugToolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

namespace CodeIgniter\Filters;

use CodeIgniter\HTTP\IncomingRequest;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\Response;
use CodeIgniter\HTTP\ResponseInterface;
use Config\Services;

Expand All @@ -25,8 +23,7 @@ class DebugToolbar implements FilterInterface
/**
* We don't need to do anything here.
*
* @param IncomingRequest|RequestInterface $request
* @param array|null $arguments
* @param array|null $arguments
*
* @return void
*/
Expand All @@ -38,9 +35,7 @@ public function before(RequestInterface $request, $arguments = null)
* If the debug flag is set (CI_DEBUG) then collect performance
* and debug information and display it in a toolbar.
*
* @param IncomingRequest|RequestInterface $request
* @param Response|ResponseInterface $response
* @param array|null $arguments
* @param array|null $arguments
*
* @return void
*/
Expand Down
12 changes: 6 additions & 6 deletions system/Filters/Honeypot.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,18 @@
class Honeypot implements FilterInterface
{
/**
* Checks if Honeypot field is empty; if not
* then the requester is a bot
* Checks if Honeypot field is empty, if not then the
* requester is a bot
*
* @param array|null $arguments
*
* @throws HoneypotException
*
* @return void
*/
public function before(RequestInterface $request, $arguments = null)
{
$honeypot = Services::honeypot(new \Config\Honeypot());
if ($honeypot->hasContent($request)) {
if (Services::honeypot()->hasContent($request)) {
throw HoneypotException::isBot();
}
}
Expand All @@ -46,7 +47,6 @@ public function before(RequestInterface $request, $arguments = null)
*/
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
$honeypot = Services::honeypot(new \Config\Honeypot());
$honeypot->attachHoneypot($response);
Services::honeypot()->attachHoneypot($response);
}
}

0 comments on commit 18d1d6d

Please sign in to comment.