Skip to content

Commit 74d3b28

Browse files
committed
refactor: use Superglobals in setting 'REQUEST_METHOD' in FeatureTestTrait
1 parent 979ba49 commit 74d3b28

File tree

2 files changed

+5
-23
lines changed

2 files changed

+5
-23
lines changed

phpstan-baseline.php

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15295,12 +15295,6 @@
1529515295
'count' => 1,
1529615296
'path' => __DIR__ . '/tests/system/HomeTest.php',
1529715297
];
15298-
$ignoreErrors[] = [
15299-
// identifier: codeigniter.superglobalAccessAssign
15300-
'message' => '#^Assigning string directly on offset \'REQUEST_METHOD\' of \\$_SERVER is discouraged\\.$#',
15301-
'count' => 1,
15302-
'path' => __DIR__ . '/tests/system/HomeTest.php',
15303-
];
1530415298
$ignoreErrors[] = [
1530515299
// identifier: empty.notAllowed
1530615300
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
@@ -15633,13 +15627,13 @@
1563315627
];
1563415628
$ignoreErrors[] = [
1563515629
// identifier: argument.type
15636-
'message' => '#^Parameter \\#1 \\$row of method CodeIgniter\\\\BaseModel\\:\\:save\\(\\) expects array<int\\|string, bool\\|float\\|int\\|object\\|string\\|null>\\|object, array<string, array<int, string>> given\\.$#',
15630+
'message' => '#^Parameter \\#1 \\$row of method CodeIgniter\\\\BaseModel\\:\\:save\\(\\) expects array\\<int\\|string, bool\\|float\\|int\\|object\\|string\\|null\\>\\|object, array\\<string, array\\<int, string\\>\\> given\\.$#',
1563715631
'count' => 1,
1563815632
'path' => __DIR__ . '/tests/system/Models/DataConverterModelTest.php',
1563915633
];
1564015634
$ignoreErrors[] = [
1564115635
// identifier: argument.type
15642-
'message' => '#^Parameter \\#2 \\$row of method CodeIgniter\\\\Model\\:\\:update\\(\\) expects array<int\\|string, bool\\|float\\|int\\|object\\|string\\|null>\\|object\\|null, array<string, array<int, string>> given\\.$#',
15636+
'message' => '#^Parameter \\#2 \\$row of method CodeIgniter\\\\Model\\:\\:update\\(\\) expects array\\<int\\|string, bool\\|float\\|int\\|object\\|string\\|null\\>\\|object\\|null, array\\<string, array\\<int, string\\>\\> given\\.$#',
1564315637
'count' => 1,
1564415638
'path' => __DIR__ . '/tests/system/Models/DataConverterModelTest.php',
1564515639
];
@@ -16029,7 +16023,7 @@
1602916023
];
1603016024
$ignoreErrors[] = [
1603116025
// identifier: argument.type
16032-
'message' => '#^Parameter \\#1 \\$row of method CodeIgniter\\\\BaseModel\\:\\:save\\(\\) expects array<int\\|string, bool\\|float\\|int\\|object\\|string\\|null>\\|object, array<int, array>\\|null given\\.$#',
16026+
'message' => '#^Parameter \\#1 \\$row of method CodeIgniter\\\\BaseModel\\:\\:save\\(\\) expects array\\<int\\|string, bool\\|float\\|int\\|object\\|string\\|null\\>\\|object, array\\<int, array\\>\\|null given\\.$#',
1603316027
'count' => 1,
1603416028
'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php',
1603516029
];
@@ -17089,12 +17083,6 @@
1708917083
'count' => 1,
1709017084
'path' => __DIR__ . '/tests/system/Test/FeatureTestAutoRoutingImprovedTest.php',
1709117085
];
17092-
$ignoreErrors[] = [
17093-
// identifier: codeigniter.superglobalAccessAssign
17094-
'message' => '#^Assigning string directly on offset \'REQUEST_METHOD\' of \\$_SERVER is discouraged\\.$#',
17095-
'count' => 1,
17096-
'path' => __DIR__ . '/tests/system/Test/FeatureTestAutoRoutingImprovedTest.php',
17097-
];
1709817086
$ignoreErrors[] = [
1709917087
// identifier: empty.notAllowed
1710017088
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
@@ -17203,12 +17191,6 @@
1720317191
'count' => 1,
1720417192
'path' => __DIR__ . '/tests/system/Test/FeatureTestTraitTest.php',
1720517193
];
17206-
$ignoreErrors[] = [
17207-
// identifier: codeigniter.superglobalAccessAssign
17208-
'message' => '#^Assigning string directly on offset \'REQUEST_METHOD\' of \\$_SERVER is discouraged\\.$#',
17209-
'count' => 1,
17210-
'path' => __DIR__ . '/tests/system/Test/FeatureTestTraitTest.php',
17211-
];
1721217194
$ignoreErrors[] = [
1721317195
// identifier: empty.notAllowed
1721417196
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',

system/Test/FeatureTestTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ public function call(string $method, string $path, ?array $params = null)
179179
$method = strtoupper($method);
180180

181181
// Simulate having a blank session
182-
$_SESSION = [];
183-
$_SERVER['REQUEST_METHOD'] = $method;
182+
$_SESSION = [];
183+
service('superglobals')->setServer('REQUEST_METHOD', $method);
184184

185185
$request = $this->setupRequest($method, $path);
186186
$request = $this->setupHeaders($request);

0 commit comments

Comments
 (0)