Skip to content

Commit

Permalink
refactor: fix phpstan and regenerate baseline
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Dec 10, 2024
1 parent a17c9be commit 5fb61b1
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 39 deletions.
12 changes: 0 additions & 12 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -7453,12 +7453,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Images/Handlers/BaseHandler.php',
];
$ignoreErrors[] = [
// identifier: return.missing
'message' => '#^Method CodeIgniter\\\\Images\\\\Handlers\\\\BaseHandler\\:\\:__call\\(\\) should return mixed but return statement is missing\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Images/Handlers/BaseHandler.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Method CodeIgniter\\\\Images\\\\Handlers\\\\BaseHandler\\:\\:_text\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
Expand Down Expand Up @@ -7609,12 +7603,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Language/Language.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Method CodeIgniter\\\\Language\\\\Language\\:\\:load\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Language/Language.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Method CodeIgniter\\\\Language\\\\Language\\:\\:parseLine\\(\\) return type has no value type specified in iterable type array\\.$#',
Expand Down
3 changes: 1 addition & 2 deletions system/Filters/CSRF.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,9 @@ public function before(RequestInterface $request, $arguments = null)
* We don't have anything to do here.
*
* @param list<string>|null $arguments
*
* @return void
*/
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
return null;
}
}
3 changes: 3 additions & 0 deletions system/Filters/DebugToolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class DebugToolbar implements FilterInterface
*/
public function before(RequestInterface $request, $arguments = null)
{
return null;
}

/**
Expand All @@ -41,5 +42,7 @@ public function before(RequestInterface $request, $arguments = null)
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
service('toolbar')->prepare($request, $response);

return $response;
}
}
4 changes: 2 additions & 2 deletions system/Filters/FilterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface FilterInterface
*
* @param list<string>|null $arguments
*
* @return RequestInterface|ResponseInterface|string|void
* @return RequestInterface|ResponseInterface|string|null
*/
public function before(RequestInterface $request, $arguments = null);

Expand All @@ -45,7 +45,7 @@ public function before(RequestInterface $request, $arguments = null);
*
* @param list<string>|null $arguments
*
* @return ResponseInterface|void
* @return ResponseInterface|null
*/
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null);
}
3 changes: 1 addition & 2 deletions system/Filters/ForceHTTPS.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ public function before(RequestInterface $request, $arguments = null)
* We don't have anything to do here.
*
* @param array|null $arguments
*
* @return void
*/
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
return null;
}
}
6 changes: 5 additions & 1 deletion system/Filters/Honeypot.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ class Honeypot implements FilterInterface
public function before(RequestInterface $request, $arguments = null)
{
if (! $request instanceof IncomingRequest) {
return;
return null;
}

if (service('honeypot')->hasContent($request)) {
throw HoneypotException::isBot();
}

return null;
}

/**
Expand All @@ -52,5 +54,7 @@ public function before(RequestInterface $request, $arguments = null)
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
service('honeypot')->attachHoneypot($response);

return $response;
}
}
9 changes: 4 additions & 5 deletions system/Filters/InvalidChars.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,11 @@ class InvalidChars implements FilterInterface
* Check invalid characters.
*
* @param list<string>|null $arguments
*
* @return void
*/
public function before(RequestInterface $request, $arguments = null)
{
if (! $request instanceof IncomingRequest) {
return;
return null;
}

$data = [
Expand All @@ -69,17 +67,18 @@ public function before(RequestInterface $request, $arguments = null)
$this->checkEncoding($values);
$this->checkControl($values);
}

return null;
}

/**
* We don't have anything to do here.
*
* @param list<string>|null $arguments
*
* @return void
*/
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
return null;
}

/**
Expand Down
5 changes: 3 additions & 2 deletions system/Filters/PageCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ public function before(RequestInterface $request, $arguments = null)
* Cache the page.
*
* @param array|null $arguments
*
* @return void
*/
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
Expand All @@ -74,6 +72,9 @@ public function after(RequestInterface $request, ResponseInterface $response, $a
// so that we can have live speed updates along the way.
// Must be run after filters to preserve the Response headers.
$this->pageCache->make($request, $response);
return $response;
}

return null;
}
}
7 changes: 5 additions & 2 deletions system/Filters/PerformanceMetrics.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ class PerformanceMetrics implements FilterInterface
*/
public function before(RequestInterface $request, $arguments = null)
{
return null;
}

/**
* Replaces the performance metrics.
*
* @param array|null $arguments
*
* @return void
*/
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
Expand All @@ -57,6 +56,10 @@ public function after(RequestInterface $request, ResponseInterface $response, $a
);

$response->setBody($output);

return $response;
}

return null;
}
}
7 changes: 3 additions & 4 deletions system/Filters/SecureHeaders.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,23 @@ class SecureHeaders implements FilterInterface
* We don't have anything to do here.
*
* @param list<string>|null $arguments
*
* @return void
*/
public function before(RequestInterface $request, $arguments = null)
{
return null;
}

/**
* Add security headers.
*
* @param list<string>|null $arguments
*
* @return void
*/
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
foreach ($this->headers as $header => $value) {
$response->setHeader($header, $value);
}

return $response;
}
}
3 changes: 2 additions & 1 deletion tests/_support/Filters/Customfilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public function before(RequestInterface $request, $arguments = null)
return $request;
}

public function after(RequestInterface $request, ResponseInterface $response, $arguments = null): void
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
return null;
}
}
3 changes: 2 additions & 1 deletion tests/_support/Filters/RedirectFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public function before(RequestInterface $request, $arguments = null)
return redirect()->to('login');
}

public function after(RequestInterface $request, ResponseInterface $response, $arguments = null): void
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
return null;
}
}
3 changes: 2 additions & 1 deletion tests/system/Filters/fixtures/GoogleCurious.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public function before(RequestInterface $request, $arguments = null)
return 'This is curious';
}

public function after(RequestInterface $request, ResponseInterface $response, $arguments = null): void
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
return null;
}
}
3 changes: 2 additions & 1 deletion tests/system/Filters/fixtures/GoogleEmpty.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public function before(RequestInterface $request, $arguments = null)
return '';
}

public function after(RequestInterface $request, ResponseInterface $response, $arguments = null): void
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
return null;
}
}
3 changes: 2 additions & 1 deletion tests/system/Filters/fixtures/GoogleYou.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public function before(RequestInterface $request, $arguments = null)
return $response;
}

public function after(RequestInterface $request, ResponseInterface $response, $arguments = null): void
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
return null;
}
}
3 changes: 2 additions & 1 deletion tests/system/Filters/fixtures/Multiple1.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public function before(RequestInterface $request, $arguments = null)
return $request;
}

public function after(RequestInterface $request, ResponseInterface $response, $arguments = null): void
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
return null;
}
}
3 changes: 2 additions & 1 deletion tests/system/Filters/fixtures/Multiple2.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public function before(RequestInterface $request, $arguments = null)
return $request;
}

public function after(RequestInterface $request, ResponseInterface $response, $arguments = null): void
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
return null;
}
}

0 comments on commit 5fb61b1

Please sign in to comment.