Skip to content

Commit 5a359a0

Browse files
committed
refactor: if conditions
$config->psr4, $config->classmap, $config->files are surely defined, because thay are defined in CodeIgniter\Config\AutoloadConfig.
1 parent fbb8db4 commit 5a359a0

3 files changed

Lines changed: 7 additions & 15 deletions

File tree

phpstan-baseline.neon.dist

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,6 @@ parameters:
1010
count: 1
1111
path: system/Autoloader/Autoloader.php
1212

13-
-
14-
message: "#^Property Config\\\\Autoload\\:\\:\\$classmap \\(array\\<string, string\\>\\) in isset\\(\\) is not nullable\\.$#"
15-
count: 1
16-
path: system/Autoloader/Autoloader.php
17-
18-
-
19-
message: "#^Property Config\\\\Autoload\\:\\:\\$files \\(array\\<int, string\\>\\) in isset\\(\\) is not nullable\\.$#"
20-
count: 1
21-
path: system/Autoloader/Autoloader.php
22-
2313
-
2414
message: "#^Property Config\\\\Cache\\:\\:\\$backupHandler \\(string\\) in isset\\(\\) is not nullable\\.$#"
2515
count: 1

system/Autoloader/Autoloader.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,19 @@ public function initialize(Autoload $config, Modules $modules)
8888

8989
// We have to have one or the other, though we don't enforce the need
9090
// to have both present in order to work.
91-
if (empty($config->psr4) && empty($config->classmap)) {
91+
if ($config->psr4 === [] && $config->classmap === []) {
9292
throw new InvalidArgumentException('Config array must contain either the \'psr4\' key or the \'classmap\' key.');
9393
}
9494

95-
if (isset($config->psr4)) {
95+
if ($config->psr4 !== []) {
9696
$this->addNamespace($config->psr4);
9797
}
9898

99-
if (isset($config->classmap)) {
99+
if ($config->classmap !== []) {
100100
$this->classmap = $config->classmap;
101101
}
102102

103-
if (isset($config->files)) {
103+
if ($config->files !== []) {
104104
$this->files = $config->files;
105105
}
106106

@@ -148,7 +148,8 @@ public function register()
148148
/**
149149
* Registers namespaces with the autoloader.
150150
*
151-
* @param array|string $namespace
151+
* @param array<string, array<int, string>|string>|string $namespace
152+
* @phpstan-param array<string, list<string>|string>|string $namespace
152153
*
153154
* @return $this
154155
*/

system/Config/AutoloadConfig.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class AutoloadConfig
7373
* or for loading functions.
7474
*
7575
* @var array<int, string>
76+
* @phpstan-var list<string>
7677
*/
7778
public $files = [];
7879

0 commit comments

Comments
 (0)