Skip to content

Commit 4c69f68

Browse files
refactor: remove case-insensitive comparison for HTTP methods in FilterCollector (#9976)
* refactor: remove case-insensitive comparison for HTTP methods in `FilterCollector` * Fix changelog entry --------- Co-authored-by: michalsn <michal@sniatala.pl>
1 parent b6c0559 commit 4c69f68

File tree

3 files changed

+9
-45
lines changed

3 files changed

+9
-45
lines changed

system/Commands/Utilities/Routes/FilterCollector.php

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ public function __construct(
3737
}
3838

3939
/**
40-
* Returns filters for the URI
40+
* Returns filters for the URI based on the HTTP method.
41+
* The HTTP method is compared case-sensitively.
4142
*
4243
* @param string $method HTTP verb like `GET`,`POST` or `CLI`.
4344
* @param string $uri URI path to find filters for
@@ -46,25 +47,8 @@ public function __construct(
4647
*/
4748
public function get(string $method, string $uri): array
4849
{
49-
if ($method === strtolower($method)) {
50-
@trigger_error(
51-
'Passing lowercase HTTP method "' . $method . '" is deprecated.'
52-
. ' Use uppercase HTTP method like "' . strtoupper($method) . '".',
53-
E_USER_DEPRECATED,
54-
);
55-
}
56-
57-
/**
58-
* @deprecated 4.5.0
59-
* @TODO Remove this in the future.
60-
*/
61-
$method = strtoupper($method);
62-
6350
if ($method === 'CLI') {
64-
return [
65-
'before' => [],
66-
'after' => [],
67-
];
51+
return ['before' => [], 'after' => []];
6852
}
6953

7054
$request = service('incomingrequest', null, false);
@@ -79,7 +63,8 @@ public function get(string $method, string $uri): array
7963
}
8064

8165
/**
82-
* Returns filter classes for the URI
66+
* Returns filter classes for the URI based on the HTTP method.
67+
* The HTTP method is compared case-sensitively.
8368
*
8469
* @param string $method HTTP verb like `GET`,`POST` or `CLI`.
8570
* @param string $uri URI path to find filters for
@@ -88,25 +73,8 @@ public function get(string $method, string $uri): array
8873
*/
8974
public function getClasses(string $method, string $uri): array
9075
{
91-
if ($method === strtolower($method)) {
92-
@trigger_error(
93-
'Passing lowercase HTTP method "' . $method . '" is deprecated.'
94-
. ' Use uppercase HTTP method like "' . strtoupper($method) . '".',
95-
E_USER_DEPRECATED,
96-
);
97-
}
98-
99-
/**
100-
* @deprecated 4.5.0
101-
* @TODO Remove this in the future.
102-
*/
103-
$method = strtoupper($method);
104-
10576
if ($method === 'CLI') {
106-
return [
107-
'before' => [],
108-
'after' => [],
109-
];
77+
return ['before' => [], 'after' => []];
11078
}
11179

11280
$request = service('incomingrequest', null, false);

tests/system/Commands/Utilities/Routes/FilterCollectorTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ public function testGet(): void
3434

3535
$filters = $collector->get(Method::GET, '/');
3636

37-
$expected = [
38-
'before' => [
39-
],
40-
'after' => [
41-
],
42-
];
43-
$this->assertSame($expected, $filters);
37+
$this->assertSame(['before' => [], 'after' => []], $filters);
4438
}
4539
}

user_guide_src/source/changelogs/v4.8.0.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ BREAKING
2323
Behavior Changes
2424
================
2525

26+
- **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+
2628
Interface Changes
2729
=================
2830

0 commit comments

Comments
 (0)