Skip to content

Commit f941858

Browse files
committed
Use PHPStan's baseline instead of global ignore of errors
1 parent 6658928 commit f941858

30 files changed

Lines changed: 1060 additions & 73 deletions

phpstan-baseline.neon.dist

Lines changed: 1022 additions & 0 deletions
Large diffs are not rendered by default.

phpstan.neon.dist

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ services:
88
tags:
99
- phpstan.rules.rule
1010

11+
includes:
12+
- phpstan-baseline.neon.dist
13+
1114
parameters:
1215
tmpDir: build/phpstan
1316
level: 5
@@ -28,30 +31,6 @@ parameters:
2831
- system/Test/Filters/CITestStreamFilter.php
2932
- system/ThirdParty/*
3033
- system/Validation/Views/single.php
31-
ignoreErrors:
32-
- '#Access to an undefined property CodeIgniter\\Database\\BaseConnection::\$mysqli|\$schema#'
33-
- '#Access to an undefined property CodeIgniter\\Database\\ConnectionInterface::(\$DBDriver|\$connID|\$likeEscapeStr|\$likeEscapeChar|\$escapeChar|\$protectIdentifiers|\$schema)#'
34-
- '#Call to an undefined method CodeIgniter\\Database\\BaseConnection::_(disable|enable)ForeignKeyChecks\(\)#'
35-
- '#Call to an undefined method CodeIgniter\\Router\\RouteCollectionInterface::(getDefaultNamespace|isFiltered|getFilterForRoute|getFiltersForRoute|getRoutesOptions)\(\)#'
36-
- '#Cannot access property [\$a-z_]+ on ((bool\|)?object\|resource)#'
37-
- '#Cannot call method [a-zA-Z_]+\(\) on ((bool\|)?object\|resource)#'
38-
- '#Method CodeIgniter\\Router\\RouteCollectionInterface::getRoutes\(\) invoked with 1 parameter, 0 required#'
39-
- '#Method CodeIgniter\\Validation\\ValidationInterface::run\(\) invoked with 3 parameters, 0-2 required#'
40-
- '#Negated boolean expression is always (true|false)#'
41-
- '#Return type \(bool\) of method CodeIgniter\\HTTP\\Files\\UploadedFile::move\(\) should be compatible with return type \(CodeIgniter\\Files\\File\) of method CodeIgniter\\Files\\File::move\(\)#'
42-
- '#.*\son left side of \?\? is not nullable#'
43-
- '#While loop condition is always true#'
44-
- '#Right side of && is always true#'
45-
- '#.*in isset\(\) is not nullable#'
46-
- '#.*in empty\(\) is not falsy#'
47-
- '#.*on left side of \?\? always exists and is not nullable#'
48-
- '#Variable \$error on left side of \?\? always exists and is always null#'
49-
- '#Variable \$config in empty\(\) always exists and is not falsy#'
50-
- '#If condition is always true#'
51-
- '#Dead catch - CodeIgniter\\Exceptions\\PageNotFoundException is never thrown in the try block#'
52-
- '#.* in isset\(\) does not exist#'
53-
- '#Variable \$mockService in empty\(\) always exists and is always falsy#'
54-
- '#PHPDoc type string\|null of property CodeIgniter\\Images\\Handlers\\ImageMagickHandler::\$resource is not covariant with PHPDoc type resource\|null of overridden property CodeIgniter\\Images\\Handlers\\BaseHandler::\$resource#'
5534
parallel:
5635
processTimeout: 300.0
5736
scanDirectories:

system/Autoloader/Autoloader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ public function initialize(Autoload $config, Modules $modules)
114114
public function register()
115115
{
116116
// Prepend the PSR4 autoloader for maximum performance.
117-
spl_autoload_register([$this, 'loadClass'], true, true); // @phpstan-ignore-line
117+
spl_autoload_register([$this, 'loadClass'], true, true);
118118

119119
// Now prepend another loader for the files in our class map.
120-
spl_autoload_register([$this, 'loadClassmap'], true, true); // @phpstan-ignore-line
120+
spl_autoload_register([$this, 'loadClassmap'], true, true);
121121

122122
// Load our non-class files
123123
foreach ($this->files as $file) {

system/Cache/Handlers/FileHandler.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ protected function getItem(string $filename)
241241
return false;
242242
}
243243

244-
// @phpstan-ignore-next-line
245244
if ($data['ttl'] > 0 && time() > $data['time'] + $data['ttl']) {
246245
// If the file is still there then try to remove it
247246
if (is_file($this->path . $filename)) {

system/Cache/Handlers/MemcachedHandler.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function get(string $key)
146146
}
147147
}
148148

149-
return is_array($data) ? $data[0] : $data; // @phpstan-ignore-line
149+
return is_array($data) ? $data[0] : $data;
150150
}
151151

152152
/**
@@ -172,7 +172,6 @@ public function save(string $key, $value, int $ttl = 60)
172172
return $this->memcached->set($key, $value, 0, $ttl);
173173
}
174174

175-
// @phpstan-ignore-next-line
176175
return false;
177176
}
178177

@@ -205,7 +204,6 @@ public function increment(string $key, int $offset = 1)
205204

206205
$key = static::validateKey($key, $this->prefix);
207206

208-
// @phpstan-ignore-next-line
209207
return $this->memcached->increment($key, $offset, $offset, 60);
210208
}
211209

@@ -221,7 +219,7 @@ public function decrement(string $key, int $offset = 1)
221219
$key = static::validateKey($key, $this->prefix);
222220

223221
// FIXME: third parameter isn't other handler actions.
224-
// @phpstan-ignore-next-line
222+
225223
return $this->memcached->decrement($key, $offset, $offset, 60);
226224
}
227225

system/CodeIgniter.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,6 @@ protected function getRequestObject()
537537
return;
538538
}
539539

540-
// @phpstan-ignore-next-line
541540
if (is_cli() && ENVIRONMENT !== 'testing') {
542541
// @codeCoverageIgnoreStart
543542
$this->request = Services::clirequest($this->config);
@@ -721,7 +720,7 @@ protected function tryToRouteIt(?RouteCollectionInterface $routes = null)
721720
// If a {locale} segment was matched in the final route,
722721
// then we need to set the correct locale on our Request.
723722
if ($this->router->hasLocale()) {
724-
$this->request->setLocale($this->router->getLocale()); // @phpstan-ignore-line
723+
$this->request->setLocale($this->router->getLocale());
725724
}
726725

727726
$this->benchmark->stop('routing');
@@ -816,7 +815,7 @@ protected function createController()
816815
protected function runController($class)
817816
{
818817
// If this is a console request then use the input segments as parameters
819-
$params = defined('SPARKED') ? $this->request->getSegments() : $this->router->params(); // @phpstan-ignore-line
818+
$params = defined('SPARKED') ? $this->request->getSegments() : $this->router->params();
820819

821820
if (method_exists($class, '_remap')) {
822821
$output = $class->_remap($this->method, ...$params);
@@ -969,7 +968,7 @@ public function spoofRequestMethod()
969968
return;
970969
}
971970

972-
$method = $this->request->getPost('_method'); // @phpstan-ignore-line
971+
$method = $this->request->getPost('_method');
973972

974973
if (empty($method)) {
975974
return;

system/Common.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,6 @@ function class_uses_recursive($class)
11531153

11541154
$results = [];
11551155

1156-
// @phpstan-ignore-next-line
11571156
foreach (array_reverse(class_parents($class)) + [$class => $class] as $class) {
11581157
$results += trait_uses_recursive($class);
11591158
}

system/Database/BaseConnection.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,6 @@ public function prepare(Closure $func, array $options = [])
883883
$this->pretend(false);
884884

885885
if ($sql instanceof QueryInterface) {
886-
// @phpstan-ignore-next-line
887886
$sql = $sql->getOriginalQuery();
888887
}
889888

system/Database/BaseResult.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ public function getCustomResultObject(string $className)
154154
$this->customResultObject[$className][] = $row;
155155
}
156156

157-
// @phpstan-ignore-next-line
158157
return $this->customResultObject[$className];
159158
}
160159

@@ -233,7 +232,6 @@ public function getResultObject(): array
233232
$this->resultObject[] = $row;
234233
}
235234

236-
// @phpstan-ignore-next-line
237235
return $this->resultObject;
238236
}
239237

system/Database/Postgre/Connection.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ public function getVersion(): string
117117
return $this->dataCache['version'];
118118
}
119119

120-
// @phpstan-ignore-next-line
121120
if (! $this->connID || ($pgVersion = pg_version($this->connID)) === false) {
122121
$this->initialize();
123122
}

0 commit comments

Comments
 (0)