Skip to content

Commit 273e8c8

Browse files
authored
Merge pull request #7795 from kai890707/20230808-format-phpstan
Fix: Remove the `Format`, `Log` and `Controller` ignore errors.
2 parents 336ae3f + 7515670 commit 273e8c8

6 files changed

Lines changed: 22 additions & 44 deletions

File tree

phpstan-baseline.php

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -346,26 +346,6 @@
346346
'count' => 1,
347347
'path' => __DIR__ . '/system/Config/View.php',
348348
];
349-
$ignoreErrors[] = [
350-
'message' => '#^Method CodeIgniter\\\\Controller\\:\\:cachePage\\(\\) has no return type specified\\.$#',
351-
'count' => 1,
352-
'path' => __DIR__ . '/system/Controller.php',
353-
];
354-
$ignoreErrors[] = [
355-
'message' => '#^Method CodeIgniter\\\\Controller\\:\\:forceHTTPS\\(\\) has no return type specified\\.$#',
356-
'count' => 1,
357-
'path' => __DIR__ . '/system/Controller.php',
358-
];
359-
$ignoreErrors[] = [
360-
'message' => '#^Method CodeIgniter\\\\Controller\\:\\:initController\\(\\) has no return type specified\\.$#',
361-
'count' => 1,
362-
'path' => __DIR__ . '/system/Controller.php',
363-
];
364-
$ignoreErrors[] = [
365-
'message' => '#^Method CodeIgniter\\\\Controller\\:\\:loadHelpers\\(\\) has no return type specified\\.$#',
366-
'count' => 1,
367-
'path' => __DIR__ . '/system/Controller.php',
368-
];
369349
$ignoreErrors[] = [
370350
'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:_whereIn\\(\\) has parameter \\$values with no signature specified for Closure\\.$#',
371351
'count' => 1,
@@ -956,11 +936,6 @@
956936
'count' => 1,
957937
'path' => __DIR__ . '/system/Filters/Filters.php',
958938
];
959-
$ignoreErrors[] = [
960-
'message' => '#^Method CodeIgniter\\\\Format\\\\XMLFormatter\\:\\:arrayToXML\\(\\) has no return type specified\\.$#',
961-
'count' => 1,
962-
'path' => __DIR__ . '/system/Format/XMLFormatter.php',
963-
];
964939
$ignoreErrors[] = [
965940
'message' => '#^Method CodeIgniter\\\\HTTP\\\\CLIRequest\\:\\:parseCommand\\(\\) has no return type specified\\.$#',
966941
'count' => 1,
@@ -1151,21 +1126,6 @@
11511126
'count' => 4,
11521127
'path' => __DIR__ . '/system/Images/Handlers/ImageMagickHandler.php',
11531128
];
1154-
$ignoreErrors[] = [
1155-
'message' => '#^Method CodeIgniter\\\\Log\\\\Exceptions\\\\LogException\\:\\:forInvalidLogLevel\\(\\) has no return type specified\\.$#',
1156-
'count' => 1,
1157-
'path' => __DIR__ . '/system/Log/Exceptions/LogException.php',
1158-
];
1159-
$ignoreErrors[] = [
1160-
'message' => '#^Method CodeIgniter\\\\Log\\\\Exceptions\\\\LogException\\:\\:forInvalidMessageType\\(\\) has no return type specified\\.$#',
1161-
'count' => 1,
1162-
'path' => __DIR__ . '/system/Log/Exceptions/LogException.php',
1163-
];
1164-
$ignoreErrors[] = [
1165-
'message' => '#^Method CodeIgniter\\\\Log\\\\Handlers\\\\ChromeLoggerHandler\\:\\:sendLogs\\(\\) has no return type specified\\.$#',
1166-
'count' => 1,
1167-
'path' => __DIR__ . '/system/Log/Handlers/ChromeLoggerHandler.php',
1168-
];
11691129
$ignoreErrors[] = [
11701130
'message' => '#^Method CodeIgniter\\\\Model\\:\\:chunk\\(\\) has parameter \\$userFunc with no signature specified for Closure\\.$#',
11711131
'count' => 1,

system/Controller.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class Controller
7070
/**
7171
* Constructor.
7272
*
73+
* @return void
74+
*
7375
* @throws HTTPException
7476
*/
7577
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
@@ -96,6 +98,8 @@ public function initController(RequestInterface $request, ResponseInterface $res
9698
* considered secure for. Only with HSTS header.
9799
* Default value is 1 year.
98100
*
101+
* @return void
102+
*
99103
* @throws HTTPException
100104
*/
101105
protected function forceHTTPS(int $duration = 31_536_000)
@@ -106,6 +110,8 @@ protected function forceHTTPS(int $duration = 31_536_000)
106110
/**
107111
* Provides a simple way to tie into the main CodeIgniter class and
108112
* tell it how long to cache the current page for.
113+
*
114+
* @return void
109115
*/
110116
protected function cachePage(int $time)
111117
{
@@ -118,6 +124,8 @@ protected function cachePage(int $time)
118124
* @deprecated Use `helper` function instead of using this method.
119125
*
120126
* @codeCoverageIgnore
127+
*
128+
* @return void
121129
*/
122130
protected function loadHelpers()
123131
{

system/Format/Exceptions/FormatException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class FormatException extends RuntimeException implements ExceptionInterface
2525
/**
2626
* Thrown when the instantiated class does not exist.
2727
*
28-
* @return FormatException
28+
* @return static
2929
*/
3030
public static function forInvalidFormatter(string $class)
3131
{
@@ -38,7 +38,7 @@ public static function forInvalidFormatter(string $class)
3838
*
3939
* @param string $error
4040
*
41-
* @return FormatException
41+
* @return static
4242
*/
4343
public static function forInvalidJSON(?string $error = null)
4444
{
@@ -49,7 +49,7 @@ public static function forInvalidJSON(?string $error = null)
4949
* Thrown when the supplied MIME type has no
5050
* defined Formatter class.
5151
*
52-
* @return FormatException
52+
* @return static
5353
*/
5454
public static function forInvalidMime(string $mime)
5555
{
@@ -60,7 +60,7 @@ public static function forInvalidMime(string $mime)
6060
* Thrown on XMLFormatter when the `simplexml` extension
6161
* is not installed.
6262
*
63-
* @return FormatException
63+
* @return static
6464
*
6565
* @codeCoverageIgnore
6666
*/

system/Format/XMLFormatter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public function format($data)
5353
* @see http://www.codexworld.com/convert-array-to-xml-in-php/
5454
*
5555
* @param SimpleXMLElement $output
56+
*
57+
* @return void
5658
*/
5759
protected function arrayToXML(array $data, &$output)
5860
{

system/Log/Exceptions/LogException.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@
1515

1616
class LogException extends FrameworkException
1717
{
18+
/**
19+
* @return static
20+
*/
1821
public static function forInvalidLogLevel(string $level)
1922
{
2023
return new static(lang('Log.invalidLogLevel', [$level]));
2124
}
2225

26+
/**
27+
* @return static
28+
*/
2329
public static function forInvalidMessageType(string $messageType)
2430
{
2531
return new static(lang('Log.invalidMessageType', [$messageType]));

system/Log/Handlers/ChromeLoggerHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ protected function format($object)
150150
* Attaches the header and the content to the passed in request object.
151151
*
152152
* @param ResponseInterface $response
153+
*
154+
* @return void
153155
*/
154156
public function sendLogs(?ResponseInterface &$response = null)
155157
{

0 commit comments

Comments
 (0)