Skip to content

Commit

Permalink
Merge pull request #7795 from kai890707/20230808-format-phpstan
Browse files Browse the repository at this point in the history
Fix: Remove the  `Format`, `Log` and `Controller` ignore errors.
  • Loading branch information
kenjis committed Aug 10, 2023
2 parents 336ae3f + 7515670 commit 273e8c8
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 44 deletions.
40 changes: 0 additions & 40 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,26 +346,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Config/View.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Controller\\:\\:cachePage\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Controller.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Controller\\:\\:forceHTTPS\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Controller.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Controller\\:\\:initController\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Controller.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Controller\\:\\:loadHelpers\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Controller.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:_whereIn\\(\\) has parameter \\$values with no signature specified for Closure\\.$#',
'count' => 1,
Expand Down Expand Up @@ -956,11 +936,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Filters/Filters.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Format\\\\XMLFormatter\\:\\:arrayToXML\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Format/XMLFormatter.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\HTTP\\\\CLIRequest\\:\\:parseCommand\\(\\) has no return type specified\\.$#',
'count' => 1,
Expand Down Expand Up @@ -1151,21 +1126,6 @@
'count' => 4,
'path' => __DIR__ . '/system/Images/Handlers/ImageMagickHandler.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Log\\\\Exceptions\\\\LogException\\:\\:forInvalidLogLevel\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Log/Exceptions/LogException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Log\\\\Exceptions\\\\LogException\\:\\:forInvalidMessageType\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Log/Exceptions/LogException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Log\\\\Handlers\\\\ChromeLoggerHandler\\:\\:sendLogs\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Log/Handlers/ChromeLoggerHandler.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Model\\:\\:chunk\\(\\) has parameter \\$userFunc with no signature specified for Closure\\.$#',
'count' => 1,
Expand Down
8 changes: 8 additions & 0 deletions system/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class Controller
/**
* Constructor.
*
* @return void
*
* @throws HTTPException
*/
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
Expand All @@ -96,6 +98,8 @@ public function initController(RequestInterface $request, ResponseInterface $res
* considered secure for. Only with HSTS header.
* Default value is 1 year.
*
* @return void
*
* @throws HTTPException
*/
protected function forceHTTPS(int $duration = 31_536_000)
Expand All @@ -106,6 +110,8 @@ protected function forceHTTPS(int $duration = 31_536_000)
/**
* Provides a simple way to tie into the main CodeIgniter class and
* tell it how long to cache the current page for.
*
* @return void
*/
protected function cachePage(int $time)
{
Expand All @@ -118,6 +124,8 @@ protected function cachePage(int $time)
* @deprecated Use `helper` function instead of using this method.
*
* @codeCoverageIgnore
*
* @return void
*/
protected function loadHelpers()
{
Expand Down
8 changes: 4 additions & 4 deletions system/Format/Exceptions/FormatException.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class FormatException extends RuntimeException implements ExceptionInterface
/**
* Thrown when the instantiated class does not exist.
*
* @return FormatException
* @return static
*/
public static function forInvalidFormatter(string $class)
{
Expand All @@ -38,7 +38,7 @@ public static function forInvalidFormatter(string $class)
*
* @param string $error
*
* @return FormatException
* @return static
*/
public static function forInvalidJSON(?string $error = null)
{
Expand All @@ -49,7 +49,7 @@ public static function forInvalidJSON(?string $error = null)
* Thrown when the supplied MIME type has no
* defined Formatter class.
*
* @return FormatException
* @return static
*/
public static function forInvalidMime(string $mime)
{
Expand All @@ -60,7 +60,7 @@ public static function forInvalidMime(string $mime)
* Thrown on XMLFormatter when the `simplexml` extension
* is not installed.
*
* @return FormatException
* @return static
*
* @codeCoverageIgnore
*/
Expand Down
2 changes: 2 additions & 0 deletions system/Format/XMLFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public function format($data)
* @see http://www.codexworld.com/convert-array-to-xml-in-php/
*
* @param SimpleXMLElement $output
*
* @return void
*/
protected function arrayToXML(array $data, &$output)
{
Expand Down
6 changes: 6 additions & 0 deletions system/Log/Exceptions/LogException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@

class LogException extends FrameworkException
{
/**
* @return static
*/
public static function forInvalidLogLevel(string $level)
{
return new static(lang('Log.invalidLogLevel', [$level]));
}

/**
* @return static
*/
public static function forInvalidMessageType(string $messageType)
{
return new static(lang('Log.invalidMessageType', [$messageType]));
Expand Down
2 changes: 2 additions & 0 deletions system/Log/Handlers/ChromeLoggerHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ protected function format($object)
* Attaches the header and the content to the passed in request object.
*
* @param ResponseInterface $response
*
* @return void
*/
public function sendLogs(?ResponseInterface &$response = null)
{
Expand Down

0 comments on commit 273e8c8

Please sign in to comment.