Skip to content

Commit

Permalink
Fix: Remove the system-Exception ignore errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
kai890707 committed Aug 16, 2023
1 parent 84c28a9 commit 1764d12
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 110 deletions.
110 changes: 0 additions & 110 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -726,116 +726,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Events/Events.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Exceptions\\\\CastException\\:\\:forInvalidJsonFormatException\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Exceptions/CastException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Exceptions\\\\ConfigException\\:\\:forDisabledMigrations\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Exceptions/ConfigException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Exceptions\\\\DownloadException\\:\\:forCannotSetBinary\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Exceptions/DownloadException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Exceptions\\\\DownloadException\\:\\:forCannotSetCache\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Exceptions/DownloadException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Exceptions\\\\DownloadException\\:\\:forCannotSetFilePath\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Exceptions/DownloadException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Exceptions\\\\DownloadException\\:\\:forCannotSetStatusCode\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Exceptions/DownloadException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Exceptions\\\\DownloadException\\:\\:forNotFoundDownloadSource\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Exceptions/DownloadException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Exceptions\\\\FrameworkException\\:\\:forCopyError\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Exceptions/FrameworkException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Exceptions\\\\FrameworkException\\:\\:forEnabledZlibOutputCompression\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Exceptions/FrameworkException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Exceptions\\\\FrameworkException\\:\\:forFabricatorCreateFailed\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Exceptions/FrameworkException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Exceptions\\\\FrameworkException\\:\\:forInvalidFile\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Exceptions/FrameworkException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Exceptions\\\\FrameworkException\\:\\:forMissingExtension\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Exceptions/FrameworkException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Exceptions\\\\FrameworkException\\:\\:forNoHandlers\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Exceptions/FrameworkException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Exceptions\\\\ModelException\\:\\:forMethodNotAvailable\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Exceptions/ModelException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Exceptions\\\\ModelException\\:\\:forNoDateFormat\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Exceptions/ModelException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Exceptions\\\\ModelException\\:\\:forNoPrimaryKey\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Exceptions/ModelException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Exceptions\\\\PageNotFoundException\\:\\:forControllerNotFound\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Exceptions/PageNotFoundException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Exceptions\\\\PageNotFoundException\\:\\:forEmptyController\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Exceptions/PageNotFoundException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Exceptions\\\\PageNotFoundException\\:\\:forLocaleNotSupported\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Exceptions/PageNotFoundException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Exceptions\\\\PageNotFoundException\\:\\:forMethodNotFound\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Exceptions/PageNotFoundException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Exceptions\\\\PageNotFoundException\\:\\:forPageNotFound\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Exceptions/PageNotFoundException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Exceptions\\\\TestException\\:\\:forInvalidMockClass\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Exceptions/TestException.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\Files\\\\File\\:\\:\\$size \\(int\\) on left side of \\?\\? is not nullable\\.$#',
'count' => 1,
Expand Down
3 changes: 3 additions & 0 deletions system/Exceptions/CastException.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public function getExitCode(): int
return EXIT_CONFIG;
}

/**
* @return static
*/
public static function forInvalidJsonFormatException(int $error)
{
switch ($error) {
Expand Down
3 changes: 3 additions & 0 deletions system/Exceptions/ConfigException.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public function getExitCode(): int
return EXIT_CONFIG;
}

/**
* @return static
*/
public static function forDisabledMigrations()
{
return new static(lang('Migrations.disabled'));
Expand Down
15 changes: 15 additions & 0 deletions system/Exceptions/DownloadException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,41 @@ class DownloadException extends RuntimeException implements ExceptionInterface
{
use DebugTraceableTrait;

/**
* @return static
*/
public static function forCannotSetFilePath(string $path)
{
return new static(lang('HTTP.cannotSetFilepath', [$path]));
}

/**
* @return static
*/
public static function forCannotSetBinary()
{
return new static(lang('HTTP.cannotSetBinary'));
}

/**
* @return static
*/
public static function forNotFoundDownloadSource()
{
return new static(lang('HTTP.notFoundDownloadSource'));
}

/**
* @return static
*/
public static function forCannotSetCache()
{
return new static(lang('HTTP.cannotSetCache'));
}

/**
* @return static
*/
public static function forCannotSetStatusCode(int $code, string $reason)
{
return new static(lang('HTTP.cannotSetStatusCode', [$code, $reason]));
Expand Down
18 changes: 18 additions & 0 deletions system/Exceptions/FrameworkException.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,33 @@ class FrameworkException extends RuntimeException implements ExceptionInterface
{
use DebugTraceableTrait;

/**
* @return static
*/
public static function forEnabledZlibOutputCompression()
{
return new static(lang('Core.enabledZlibOutputCompression'));
}

/**
* @return static
*/
public static function forInvalidFile(string $path)
{
return new static(lang('Core.invalidFile', [$path]));
}

/**
* @return static
*/
public static function forCopyError(string $path)
{
return new static(lang('Core.copyError', [$path]));
}

/**
* @return static
*/
public static function forMissingExtension(string $extension)
{
if (strpos($extension, 'intl') !== false) {
Expand All @@ -54,11 +66,17 @@ public static function forMissingExtension(string $extension)
return new static($message);
}

/**
* @return static
*/
public static function forNoHandlers(string $class)
{
return new static(lang('Core.noHandlers', [$class]));
}

/**
* @return static
*/
public static function forFabricatorCreateFailed(string $table, string $reason)
{
return new static(lang('Fabricator.createFailed', [$table, $reason]));
Expand Down
9 changes: 9 additions & 0 deletions system/Exceptions/ModelException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,25 @@
*/
class ModelException extends FrameworkException
{
/**
* @return static
*/
public static function forNoPrimaryKey(string $modelName)
{
return new static(lang('Database.noPrimaryKey', [$modelName]));
}

/**
* @return static
*/
public static function forNoDateFormat(string $modelName)
{
return new static(lang('Database.noDateFormat', [$modelName]));
}

/**
* @return static
*/
public static function forMethodNotAvailable(string $modelName, string $methodName)
{
return new static(lang('Database.methodNotAvailable', [$modelName, $methodName]));
Expand Down
15 changes: 15 additions & 0 deletions system/Exceptions/PageNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,41 @@ class PageNotFoundException extends OutOfBoundsException implements ExceptionInt
*/
protected $code = 404;

/**
* @return static
*/
public static function forPageNotFound(?string $message = null)
{
return new static($message ?? self::lang('HTTP.pageNotFound'));
}

/**
* @return static
*/
public static function forEmptyController()
{
return new static(self::lang('HTTP.emptyController'));
}

/**
* @return static
*/
public static function forControllerNotFound(string $controller, string $method)
{
return new static(self::lang('HTTP.controllerNotFound', [$controller, $method]));
}

/**
* @return static
*/
public static function forMethodNotFound(string $method)
{
return new static(self::lang('HTTP.methodNotFound', [$method]));
}

/**
* @return static
*/
public static function forLocaleNotSupported(string $locale)
{
return new static(self::lang('HTTP.localeNotSupported', [$locale]));
Expand Down
3 changes: 3 additions & 0 deletions system/Exceptions/TestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class TestException extends CriticalError
{
use DebugTraceableTrait;

/**
* @return static
*/
public static function forInvalidMockClass(string $name)
{
return new static(lang('Test.invalidMockClass', [$name]));
Expand Down

0 comments on commit 1764d12

Please sign in to comment.