Skip to content

Commit 07ebcad

Browse files
committed
Update phpstan-codeigniter and fix new errors
1 parent cf43310 commit 07ebcad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+112
-179
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"require-dev": {
2121
"codeigniter/coding-standard": "^1.5",
22-
"codeigniter/phpstan-codeigniter": "^v1.1",
22+
"codeigniter/phpstan-codeigniter": "^1.1",
2323
"ergebnis/composer-normalize": "^2.28",
2424
"fakerphp/faker": "^1.9",
2525
"kint-php/kint": "^5.0.4",

phpstan-baseline.php

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@
181181
'count' => 1,
182182
'path' => __DIR__ . '/system/Cache/Handlers/PredisHandler.php',
183183
];
184+
$ignoreErrors[] = [
185+
'message' => '#^Call to function config with Config\\\\Kint\\:\\:class is discouraged\\.$#',
186+
'count' => 1,
187+
'path' => __DIR__ . '/system/CodeIgniter.php',
188+
];
184189
$ignoreErrors[] = [
185190
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
186191
'count' => 6,
@@ -871,16 +876,6 @@
871876
'count' => 4,
872877
'path' => __DIR__ . '/system/Config/BaseConfig.php',
873878
];
874-
$ignoreErrors[] = [
875-
'message' => '#^Argument \\#1 \\$name \\(\'Config\\\\\\\\Modules\'\\) passed to function config does not extend CodeIgniter\\\\\\\\Config\\\\\\\\BaseConfig\\.$#',
876-
'count' => 1,
877-
'path' => __DIR__ . '/system/Config/BaseConfig.php',
878-
];
879-
$ignoreErrors[] = [
880-
'message' => '#^Argument \\#1 \\$name \\(\'Config\\\\\\\\Modules\'\\) passed to function config does not extend CodeIgniter\\\\\\\\Config\\\\\\\\BaseConfig\\.$#',
881-
'count' => 2,
882-
'path' => __DIR__ . '/system/Config/BaseService.php',
883-
];
884879
$ignoreErrors[] = [
885880
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
886881
'count' => 3,
@@ -931,11 +926,6 @@
931926
'count' => 1,
932927
'path' => __DIR__ . '/system/Config/Services.php',
933928
];
934-
$ignoreErrors[] = [
935-
'message' => '#^Argument \\#1 \\$name \\(\'Config\\\\\\\\Modules\'\\) passed to function config does not extend CodeIgniter\\\\\\\\Config\\\\\\\\BaseConfig\\.$#',
936-
'count' => 1,
937-
'path' => __DIR__ . '/system/Config/Services.php',
938-
];
939929
$ignoreErrors[] = [
940930
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
941931
'count' => 1,
@@ -2011,11 +2001,6 @@
20112001
'count' => 4,
20122002
'path' => __DIR__ . '/system/Entity/Entity.php',
20132003
];
2014-
$ignoreErrors[] = [
2015-
'message' => '#^Argument \\#1 \\$name \\(\'Config\\\\\\\\Modules\'\\) passed to function config does not extend CodeIgniter\\\\\\\\Config\\\\\\\\BaseConfig\\.$#',
2016-
'count' => 1,
2017-
'path' => __DIR__ . '/system/Events/Events.php',
2018-
];
20192004
$ignoreErrors[] = [
20202005
'message' => '#^Method CodeIgniter\\\\Events\\\\Events\\:\\:on\\(\\) has parameter \\$callback with no signature specified for callable\\.$#',
20212006
'count' => 1,
@@ -2056,11 +2041,6 @@
20562041
'count' => 3,
20572042
'path' => __DIR__ . '/system/Files/File.php',
20582043
];
2059-
$ignoreErrors[] = [
2060-
'message' => '#^Argument \\#1 \\$name \\(\'Config\\\\\\\\Modules\'\\) passed to function config does not extend CodeIgniter\\\\\\\\Config\\\\\\\\BaseConfig\\.$#',
2061-
'count' => 1,
2062-
'path' => __DIR__ . '/system/Filters/Filters.php',
2063-
];
20642044
$ignoreErrors[] = [
20652045
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
20662046
'count' => 2,

phpstan.neon.dist

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,12 @@ parameters:
3232
checkGenericClassInNonGenericObjectType: false
3333
checkMissingCallableSignature: true
3434
treatPhpDocTypesAsCertain: false
35+
codeigniter:
36+
additionalConfigNamespaces:
37+
- CodeIgniter\Config
3538
strictRules:
3639
allRules: false
3740
disallowedLooseComparison: true
3841
booleansInConditions: true
3942
disallowedConstructs: true
4043
matchingInheritedMethodNames: true
41-
ignoreErrors:
42-
- '#^Call to function config with Config\\.+\:\:class is discouraged\.$#'
43-
codeigniter:
44-
additionalConfigNamespaces:
45-
- CodeIgniter\Config\

system/CLI/BaseCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace CodeIgniter\CLI;
1313

14-
use Config\Exceptions;
1514
use Psr\Log\LoggerInterface;
1615
use ReflectionException;
1716
use Throwable;
@@ -124,7 +123,7 @@ protected function showError(Throwable $e)
124123
{
125124
$exception = $e;
126125
$message = $e->getMessage();
127-
$config = config(Exceptions::class);
126+
$config = config('Exceptions');
128127

129128
require $config->errorViewPath . '/cli/error_exception.php';
130129
}

system/CLI/Console.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace CodeIgniter\CLI;
1313

1414
use CodeIgniter\CodeIgniter;
15-
use Config\App;
1615
use Config\Services;
1716
use Exception;
1817

@@ -33,7 +32,7 @@ class Console
3332
public function run()
3433
{
3534
// Create CLIRequest
36-
$appConfig = config(App::class);
35+
$appConfig = config('App');
3736
Services::createRequest($appConfig, true);
3837
// Load Routes
3938
Services::routes()->loadRoutes();

system/CLI/GeneratorTrait.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace CodeIgniter\CLI;
1313

14-
use Config\Generators;
1514
use Config\Services;
1615
use Throwable;
1716

@@ -268,7 +267,7 @@ protected function qualifyClassName(): string
268267
protected function renderTemplate(array $data = []): string
269268
{
270269
try {
271-
return view(config(Generators::class)->views[$this->name], $data, ['debug' => false]);
270+
return view(config('Generators')->views[$this->name], $data, ['debug' => false]);
272271
} catch (Throwable $e) {
273272
log_message('error', (string) $e);
274273

system/Cache/Handlers/BaseHandler.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Closure;
1515
use CodeIgniter\Cache\CacheInterface;
16-
use Config\Cache;
1716
use Exception;
1817
use InvalidArgumentException;
1918

@@ -64,7 +63,7 @@ public static function validateKey($key, $prefix = ''): string
6463
throw new InvalidArgumentException('Cache key cannot be empty.');
6564
}
6665

67-
$reserved = config(Cache::class)->reservedCharacters ?? self::RESERVED_CHARACTERS;
66+
$reserved = config('Cache')->reservedCharacters ?? self::RESERVED_CHARACTERS;
6867
if ($reserved && strpbrk($key, $reserved) !== false) {
6968
throw new InvalidArgumentException('Cache key contains reserved characters ' . $reserved);
7069
}

system/CodeIgniter.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@
3131
use CodeIgniter\Router\Router;
3232
use Config\App;
3333
use Config\Cache;
34-
use Config\Feature;
3534
use Config\Kint as KintConfig;
3635
use Config\Services;
3736
use Exception;
38-
use Kint;
37+
use Kint\Kint;
3938
use Kint\Renderer\CliRenderer;
4039
use Kint\Renderer\RichRenderer;
4140
use Locale;
@@ -358,7 +357,7 @@ public function run(?RouteCollectionInterface $routes = null, bool $returnRespon
358357
$this->spoofRequestMethod();
359358

360359
try {
361-
$this->response = $this->handleRequest($routes, config(Cache::class), $returnResponse);
360+
$this->response = $this->handleRequest($routes, config('Cache'), $returnResponse);
362361
} catch (ResponsableInterface|DeprecatedRedirectException $e) {
363362
$this->outputBufferingEnd();
364363
if ($e instanceof DeprecatedRedirectException) {
@@ -458,7 +457,7 @@ protected function handleRequest(?RouteCollectionInterface $routes, Cache $cache
458457
// If any filters were specified within the routes file,
459458
// we need to ensure it's active for the current request
460459
if ($routeFilter !== null) {
461-
$multipleFiltersEnabled = config(Feature::class)->multipleFilters ?? false;
460+
$multipleFiltersEnabled = config('Feature')->multipleFilters ?? false;
462461
if ($multipleFiltersEnabled) {
463462
$filters->enableFilters($routeFilter, 'before');
464463
$filters->enableFilters($routeFilter, 'after');
@@ -832,7 +831,7 @@ protected function tryToRouteIt(?RouteCollectionInterface $routes = null)
832831
$this->benchmark->stop('routing');
833832

834833
// for backward compatibility
835-
$multipleFiltersEnabled = config(Feature::class)->multipleFilters ?? false;
834+
$multipleFiltersEnabled = config('Feature')->multipleFilters ?? false;
836835
if (! $multipleFiltersEnabled) {
837836
return $this->router->getFilter();
838837
}
@@ -973,7 +972,7 @@ protected function display404errors(PageNotFoundException $e)
973972

974973
unset($override);
975974

976-
$cacheConfig = config(Cache::class);
975+
$cacheConfig = config('Cache');
977976
$this->gatherOutput($cacheConfig, $returned);
978977

979978
return $this->response;

system/Commands/Cache/ClearCache.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use CodeIgniter\Cache\CacheFactory;
1515
use CodeIgniter\CLI\BaseCommand;
1616
use CodeIgniter\CLI\CLI;
17-
use Config\Cache;
1817

1918
/**
2019
* Clears current cache.
@@ -63,7 +62,7 @@ class ClearCache extends BaseCommand
6362
*/
6463
public function run(array $params)
6564
{
66-
$config = config(Cache::class);
65+
$config = config('Cache');
6766
$handler = $params[0] ?? $config->handler;
6867

6968
if (! array_key_exists($handler, $config->validHandlers)) {

system/Commands/Cache/InfoCache.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use CodeIgniter\CLI\BaseCommand;
1616
use CodeIgniter\CLI\CLI;
1717
use CodeIgniter\I18n\Time;
18-
use Config\Cache;
1918

2019
/**
2120
* Shows information on the cache.
@@ -55,7 +54,7 @@ class InfoCache extends BaseCommand
5554
*/
5655
public function run(array $params)
5756
{
58-
$config = config(Cache::class);
57+
$config = config('Cache');
5958
helper('number');
6059

6160
if ($config->handler !== 'file') {

0 commit comments

Comments
 (0)