Skip to content

Commit 892f404

Browse files
authored
Merge pull request #7764 from ping-yee/230802-config-phpstan
Dev: Remove the `config` ignore errors.
2 parents 131d140 + be62e2e commit 892f404

9 files changed

+48
-55
lines changed

phpstan-baseline.php

+16-51
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
<?php declare(strict_types = 1);
22

33
$ignoreErrors = [];
4+
$ignoreErrors[] = [
5+
'message' => '#^PHPDoc type array of property Config\\\\View\\:\\:\\$filters is not covariant with PHPDoc type array\\<string, callable\\-string\\> of overridden property CodeIgniter\\\\Config\\\\View\\:\\:\\$filters\\.$#',
6+
'count' => 1,
7+
'path' => __DIR__ . '/app/Config/View.php',
8+
];
9+
$ignoreErrors[] = [
10+
'message' => '#^PHPDoc type array of property Config\\\\View\\:\\:\\$plugins is not covariant with PHPDoc type array\\<string, callable\\-string\\> of overridden property CodeIgniter\\\\Config\\\\View\\:\\:\\$plugins\\.$#',
11+
'count' => 1,
12+
'path' => __DIR__ . '/app/Config/View.php',
13+
];
414
$ignoreErrors[] = [
515
'message' => '#^Parameter \\#1 \\$callback of function spl_autoload_register expects \\(callable\\(string\\)\\: void\\)\\|null, array\\{\\$this\\(CodeIgniter\\\\Autoloader\\\\Autoloader\\), \'loadClass\'\\} given\\.$#',
616
'count' => 1,
@@ -317,67 +327,22 @@
317327
'path' => __DIR__ . '/system/ComposerScripts.php',
318328
];
319329
$ignoreErrors[] = [
320-
'message' => '#^Method CodeIgniter\\\\Config\\\\BaseConfig\\:\\:registerProperties\\(\\) has no return type specified\\.$#',
321-
'count' => 1,
322-
'path' => __DIR__ . '/system/Config/BaseConfig.php',
323-
];
324-
$ignoreErrors[] = [
325-
'message' => '#^Method CodeIgniter\\\\Config\\\\BaseService\\:\\:injectMock\\(\\) has no return type specified\\.$#',
326-
'count' => 1,
327-
'path' => __DIR__ . '/system/Config/BaseService.php',
328-
];
329-
$ignoreErrors[] = [
330-
'message' => '#^Method CodeIgniter\\\\Config\\\\BaseService\\:\\:reset\\(\\) has no return type specified\\.$#',
331-
'count' => 1,
332-
'path' => __DIR__ . '/system/Config/BaseService.php',
333-
];
334-
$ignoreErrors[] = [
335-
'message' => '#^Method CodeIgniter\\\\Config\\\\BaseService\\:\\:resetSingle\\(\\) has no return type specified\\.$#',
336-
'count' => 1,
337-
'path' => __DIR__ . '/system/Config/BaseService.php',
338-
];
339-
$ignoreErrors[] = [
340-
'message' => '#^Method CodeIgniter\\\\Config\\\\Config\\:\\:injectMock\\(\\) has no return type specified\\.$#',
330+
'message' => '#^Property CodeIgniter\\\\Config\\\\View\\:\\:\\$coreFilters type has no signature specified for callable\\.$#',
341331
'count' => 1,
342-
'path' => __DIR__ . '/system/Config/Config.php',
343-
];
344-
$ignoreErrors[] = [
345-
'message' => '#^Method CodeIgniter\\\\Config\\\\Config\\:\\:reset\\(\\) has no return type specified\\.$#',
346-
'count' => 1,
347-
'path' => __DIR__ . '/system/Config/Config.php',
348-
];
349-
$ignoreErrors[] = [
350-
'message' => '#^Method CodeIgniter\\\\Config\\\\DotEnv\\:\\:setVariable\\(\\) has no return type specified\\.$#',
351-
'count' => 1,
352-
'path' => __DIR__ . '/system/Config/DotEnv.php',
353-
];
354-
$ignoreErrors[] = [
355-
'message' => '#^Method CodeIgniter\\\\Config\\\\Factories\\:\\:injectMock\\(\\) has no return type specified\\.$#',
356-
'count' => 1,
357-
'path' => __DIR__ . '/system/Config/Factories.php',
358-
];
359-
$ignoreErrors[] = [
360-
'message' => '#^Method CodeIgniter\\\\Config\\\\Factories\\:\\:reset\\(\\) has no return type specified\\.$#',
361-
'count' => 1,
362-
'path' => __DIR__ . '/system/Config/Factories.php',
363-
];
364-
$ignoreErrors[] = [
365-
'message' => '#^Property CodeIgniter\\\\Config\\\\ForeignCharacters\\:\\:\\$characterList has no type specified\\.$#',
366-
'count' => 1,
367-
'path' => __DIR__ . '/system/Config/ForeignCharacters.php',
332+
'path' => __DIR__ . '/system/Config/View.php',
368333
];
369334
$ignoreErrors[] = [
370-
'message' => '#^Method CodeIgniter\\\\Config\\\\Publisher\\:\\:registerProperties\\(\\) has no return type specified\\.$#',
335+
'message' => '#^Property CodeIgniter\\\\Config\\\\View\\:\\:\\$corePlugins type has no signature specified for callable\\.$#',
371336
'count' => 1,
372-
'path' => __DIR__ . '/system/Config/Publisher.php',
337+
'path' => __DIR__ . '/system/Config/View.php',
373338
];
374339
$ignoreErrors[] = [
375-
'message' => '#^Property CodeIgniter\\\\Config\\\\View\\:\\:\\$filters has no type specified\\.$#',
340+
'message' => '#^Property CodeIgniter\\\\Config\\\\View\\:\\:\\$filters type has no signature specified for callable\\.$#',
376341
'count' => 1,
377342
'path' => __DIR__ . '/system/Config/View.php',
378343
];
379344
$ignoreErrors[] = [
380-
'message' => '#^Property CodeIgniter\\\\Config\\\\View\\:\\:\\$plugins has no type specified\\.$#',
345+
'message' => '#^Property CodeIgniter\\\\Config\\\\View\\:\\:\\$plugins type has no signature specified for callable\\.$#',
381346
'count' => 1,
382347
'path' => __DIR__ . '/system/Config/View.php',
383348
];

system/Config/BaseConfig.php

+2
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ protected function getEnvValue(string $property, string $prefix, string $shortPr
169169
* Provides external libraries a simple way to register one or more
170170
* options into a config file.
171171
*
172+
* @return void
173+
*
172174
* @throws ReflectionException
173175
*/
174176
protected function registerProperties()

system/Config/BaseService.php

+6
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ public static function serviceExists(string $name): ?string
273273

274274
/**
275275
* Reset shared instances and mocks for testing.
276+
*
277+
* @return void
276278
*/
277279
public static function reset(bool $initAutoloader = true)
278280
{
@@ -286,6 +288,8 @@ public static function reset(bool $initAutoloader = true)
286288

287289
/**
288290
* Resets any mock and shared instances for a single service.
291+
*
292+
* @return void
289293
*/
290294
public static function resetSingle(string $name)
291295
{
@@ -297,6 +301,8 @@ public static function resetSingle(string $name)
297301
* Inject mock object for testing.
298302
*
299303
* @param object $mock
304+
*
305+
* @return void
300306
*/
301307
public static function injectMock(string $name, $mock)
302308
{

system/Config/Config.php

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public static function get(string $name, bool $getShared = true)
3434
* Helper method for injecting mock instances while testing.
3535
*
3636
* @param object $instance
37+
*
38+
* @return void
3739
*/
3840
public static function injectMock(string $name, $instance)
3941
{
@@ -42,6 +44,8 @@ public static function injectMock(string $name, $instance)
4244

4345
/**
4446
* Resets the static arrays
47+
*
48+
* @return void
4549
*/
4650
public static function reset()
4751
{

system/Config/DotEnv.php

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ public function parse(): ?array
8585
* Sets the variable into the environment. Will parse the string
8686
* first to look for {name}={value} pattern, ensure that nested
8787
* variables are handled, and strip it of single and double quotes.
88+
*
89+
* @return void
8890
*/
8991
protected function setVariable(string $name, string $value = '')
9092
{

system/Config/Factories.php

+4
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ public static function setOptions(string $component, array $values): array
267267
* Resets the static arrays, optionally just for one component
268268
*
269269
* @param string|null $component Lowercase, plural component name
270+
*
271+
* @return void
270272
*/
271273
public static function reset(?string $component = null)
272274
{
@@ -290,6 +292,8 @@ public static function reset(?string $component = null)
290292
*
291293
* @param string $component Lowercase, plural component name
292294
* @param string $name The name of the instance
295+
*
296+
* @return void
293297
*/
294298
public static function injectMock(string $component, string $name, object $instance)
295299
{

system/Config/ForeignCharacters.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
class ForeignCharacters
1818
{
1919
/**
20-
* Without further ado, the list of foreign characters.
20+
* The list of foreign characters.
21+
*
22+
* @var array<string, string>
2123
*/
2224
public $characterList = [
2325
'/ä|æ|ǽ/' => 'ae',

system/Config/Publisher.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Publisher extends BaseConfig
3636
/**
3737
* Disables Registrars to prevent modules from altering the restrictions.
3838
*/
39-
final protected function registerProperties()
39+
final protected function registerProperties(): void
4040
{
4141
}
4242
}

system/Config/View.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,27 @@ class View extends BaseConfig
3333
*
3434
* To prevent potential abuse, all filters MUST be defined here
3535
* in order for them to be available for use within the Parser.
36+
*
37+
* @var array<string, string>
38+
* @phpstan-var array<string, callable-string>
3639
*/
3740
public $filters = [];
3841

3942
/**
4043
* Parser Plugins provide a way to extend the functionality provided
4144
* by the core Parser by creating aliases that will be replaced with
4245
* any callable. Can be single or tag pair.
46+
*
47+
* @var array<string, string>
48+
* @phpstan-var array<string, callable-string>
4349
*/
4450
public $plugins = [];
4551

4652
/**
4753
* Built-in View filters.
4854
*
49-
* @var array
55+
* @var array<string, string>
56+
* @phpstan-var array<string, callable-string>
5057
*/
5158
protected $coreFilters = [
5259
'abs' => '\abs',
@@ -75,7 +82,8 @@ class View extends BaseConfig
7582
/**
7683
* Built-in View plugins.
7784
*
78-
* @var array
85+
* @var array<string, string>
86+
* @phpstan-var array<string, callable-string>
7987
*/
8088
protected $corePlugins = [
8189
'csp_script_nonce' => '\CodeIgniter\View\Plugins::cspScriptNonce',

0 commit comments

Comments
 (0)