Skip to content

Commit 8846c19

Browse files
committed
refactor: remove deprecations in Filters
1 parent cd3013b commit 8846c19

File tree

3 files changed

+11
-66
lines changed

3 files changed

+11
-66
lines changed

system/Filters/Filters.php

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
use Config\Modules;
2323

2424
/**
25-
* Filters
26-
*
2725
* @see \CodeIgniter\Filters\FiltersTest
2826
*/
2927
class Filters
@@ -125,26 +123,6 @@ class Filters
125123
protected array $filterClassInstances = [];
126124

127125
/**
128-
* Any arguments to be passed to filters.
129-
*
130-
* @var array<string, list<string>|null> [name => params]
131-
*
132-
* @deprecated 4.6.0 No longer used.
133-
*/
134-
protected $arguments = [];
135-
136-
/**
137-
* Any arguments to be passed to filtersClass.
138-
*
139-
* @var array<class-string, list<string>|null> [classname => arguments]
140-
*
141-
* @deprecated 4.6.0 No longer used.
142-
*/
143-
protected $argumentsClass = [];
144-
145-
/**
146-
* Constructor.
147-
*
148126
* @param FiltersConfig $config
149127
*/
150128
public function __construct($config, RequestInterface $request, ResponseInterface $response, ?Modules $modules = null)
@@ -501,8 +479,6 @@ public function reset(): self
501479
{
502480
$this->initialized = false;
503481

504-
$this->arguments = $this->argumentsClass = [];
505-
506482
$this->filters = $this->filtersClass = [
507483
'before' => [],
508484
'after' => [],
@@ -644,18 +620,6 @@ public function enableFilters(array $filters, string $when = 'before')
644620
return $this;
645621
}
646622

647-
/**
648-
* Returns the arguments for a specified key, or all.
649-
*
650-
* @return array<string, string>|string
651-
*
652-
* @deprecated 4.6.0 Already does not work.
653-
*/
654-
public function getArguments(?string $key = null)
655-
{
656-
return ((string) $key === '') ? $this->arguments : $this->arguments[$key];
657-
}
658-
659623
// --------------------------------------------------------------------
660624
// Processors
661625
// --------------------------------------------------------------------
@@ -732,27 +696,9 @@ protected function processMethods()
732696

733697
$method = $this->request->getMethod();
734698

735-
$found = false;
736-
737699
if (array_key_exists($method, $this->config->methods)) {
738-
$found = true;
739-
}
740-
// Checks lowercase HTTP method for backward compatibility.
741-
// @deprecated 4.5.0
742-
// @TODO remove this in the future.
743-
elseif (array_key_exists(strtolower($method), $this->config->methods)) {
744-
@trigger_error(
745-
'Setting lowercase HTTP method key "' . strtolower($method) . '" is deprecated.'
746-
. ' Use uppercase HTTP method like "' . strtoupper($method) . '".',
747-
E_USER_DEPRECATED,
748-
);
749-
750-
$found = true;
751-
$method = strtolower($method);
752-
}
753-
754-
if ($found) {
755700
$oldFilterOrder = config(Feature::class)->oldFilterOrder ?? false;
701+
756702
if ($oldFilterOrder) {
757703
$this->filters['before'] = array_merge($this->filters['before'], $this->config->methods[$method]);
758704
} else {

tests/system/Filters/CSRFTest.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
namespace CodeIgniter\Filters;
1515

16-
use CodeIgniter\Config\Services;
1716
use CodeIgniter\HTTP\CLIRequest;
1817
use CodeIgniter\HTTP\IncomingRequest;
1918
use CodeIgniter\HTTP\Response;
@@ -29,12 +28,7 @@
2928
final class CSRFTest extends CIUnitTestCase
3029
{
3130
private \Config\Filters $config;
32-
33-
/**
34-
* @var CLIRequest|IncomingRequest|null
35-
*/
36-
private $request;
37-
31+
private CLIRequest|IncomingRequest $request;
3832
private ?Response $response = null;
3933

4034
protected function setUp(): void
@@ -50,8 +44,8 @@ public function testDoNotCheckCliRequest(): void
5044
'after' => [],
5145
];
5246

53-
$this->request = Services::clirequest(null, false);
54-
$this->response = service('response');
47+
$this->request = single_service('clirequest', null);
48+
$this->response = single_service('response');
5549

5650
$filters = new Filters($this->config, $this->request, $this->response);
5751
$uri = 'admin/foo/bar';
@@ -68,8 +62,8 @@ public function testPassGetRequest(): void
6862
'after' => [],
6963
];
7064

71-
$this->request = service('incomingrequest', null, false);
72-
$this->response = service('response');
65+
$this->request = single_service('incomingrequest', null);
66+
$this->response = single_service('response');
7367

7468
$filters = new Filters($this->config, $this->request, $this->response);
7569
$uri = 'admin/foo/bar';

user_guide_src/source/changelogs/v4.8.0.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Behavior Changes
2424
================
2525

2626
- **Commands:** The ``filter:check`` command now requires the HTTP method argument to be uppercase (e.g., ``spark filter:check GET /`` instead of ``spark filter:check get /``).
27+
- **Filters:** The deprecated case-insensitive checking of HTTP methods in ``processMethods()`` has been removed.
2728

2829
Interface Changes
2930
=================
@@ -88,6 +89,10 @@ Removed Deprecated Items
8889
- ``CodeIgniter\HTTP\Exceptions\HTTPException::forInvalidSameSiteSetting()``
8990
- ``CodeIgniter\Security\Exceptions\SecurityException::forInvalidSameSite()``
9091
- ``CodeIgniter\Session\Exceptions\SessionException::forInvalidSameSiteSetting()``
92+
- **Filters:** Removed the following properties and methods deprecated:
93+
- ``CodeIgniter\Filters\Filters::$arguments`` (deprecated since v4.6.0)
94+
- ``CodeIgniter\Filters\Filters::$argumentsClass`` (deprecated since v4.6.0)
95+
- ``CodeIgniter\Filters\Filters::getArguments()`` (deprecated since v4.6.0)
9196
- **Security:** Removed the following properties and methods deprecated:
9297
- ``CodeIgniter\Security\SecurityInterface::sanitizeFilename()`` (deprecated since v4.6.2)
9398
- ``CodeIgniter\Security\Security::sanitizeFilename()`` (deprecated since v4.6.2)

0 commit comments

Comments
 (0)