Skip to content

Commit

Permalink
refactor: use Superglobals in setting 'REQUEST_METHOD' in `FeatureT…
Browse files Browse the repository at this point in the history
…estTrait`
  • Loading branch information
paulbalandan committed Nov 29, 2024
1 parent 979ba49 commit 74d3b28
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 23 deletions.
24 changes: 3 additions & 21 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -15295,12 +15295,6 @@
'count' => 1,
'path' => __DIR__ . '/tests/system/HomeTest.php',
];
$ignoreErrors[] = [
// identifier: codeigniter.superglobalAccessAssign
'message' => '#^Assigning string directly on offset \'REQUEST_METHOD\' of \\$_SERVER is discouraged\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/HomeTest.php',
];
$ignoreErrors[] = [
// identifier: empty.notAllowed
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
Expand Down Expand Up @@ -15633,13 +15627,13 @@
];
$ignoreErrors[] = [
// identifier: argument.type
'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\\.$#',
'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\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Models/DataConverterModelTest.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'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\\.$#',
'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\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Models/DataConverterModelTest.php',
];
Expand Down Expand Up @@ -16029,7 +16023,7 @@
];
$ignoreErrors[] = [
// identifier: argument.type
'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\\.$#',
'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\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php',
];
Expand Down Expand Up @@ -17089,12 +17083,6 @@
'count' => 1,
'path' => __DIR__ . '/tests/system/Test/FeatureTestAutoRoutingImprovedTest.php',
];
$ignoreErrors[] = [
// identifier: codeigniter.superglobalAccessAssign
'message' => '#^Assigning string directly on offset \'REQUEST_METHOD\' of \\$_SERVER is discouraged\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Test/FeatureTestAutoRoutingImprovedTest.php',
];
$ignoreErrors[] = [
// identifier: empty.notAllowed
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
Expand Down Expand Up @@ -17203,12 +17191,6 @@
'count' => 1,
'path' => __DIR__ . '/tests/system/Test/FeatureTestTraitTest.php',
];
$ignoreErrors[] = [
// identifier: codeigniter.superglobalAccessAssign
'message' => '#^Assigning string directly on offset \'REQUEST_METHOD\' of \\$_SERVER is discouraged\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Test/FeatureTestTraitTest.php',
];
$ignoreErrors[] = [
// identifier: empty.notAllowed
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
Expand Down
4 changes: 2 additions & 2 deletions system/Test/FeatureTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ public function call(string $method, string $path, ?array $params = null)
$method = strtoupper($method);

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

$request = $this->setupRequest($method, $path);
$request = $this->setupHeaders($request);
Expand Down

0 comments on commit 74d3b28

Please sign in to comment.