Skip to content

Commit fbb8db4

Browse files
committed
fix: spark namespaces cannot show a namespace with mutilple paths
1 parent f30fba6 commit fbb8db4

4 files changed

Lines changed: 18 additions & 15 deletions

File tree

app/Config/Autoload.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class Autoload extends AutoloadConfig
3838
* ];
3939
*```
4040
*
41-
* @var array<string, string>
41+
* @var array<string, array<int, string>|string>
42+
* @phpstan-var array<string, string|list<string>>
4243
*/
4344
public $psr4 = [
4445
APP_NAMESPACE => APPPATH, // For custom app namespace

phpstan-baseline.neon.dist

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ parameters:
2020
count: 1
2121
path: system/Autoloader/Autoloader.php
2222

23-
-
24-
message: "#^Property Config\\\\Autoload\\:\\:\\$psr4 \\(array\\<string, string\\>\\) in isset\\(\\) is not nullable\\.$#"
25-
count: 1
26-
path: system/Autoloader/Autoloader.php
27-
2823
-
2924
message: "#^Property Config\\\\Cache\\:\\:\\$backupHandler \\(string\\) in isset\\(\\) is not nullable\\.$#"
3025
count: 1

system/Commands/Utilities/Namespaces.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,20 @@ public function run(array $params)
7474

7575
$tbody = [];
7676

77-
foreach ($config->psr4 as $ns => $path) {
78-
$path = realpath($path) ?: $path;
79-
80-
$tbody[] = [
81-
$ns,
82-
realpath($path) ?: $path,
83-
is_dir($path) ? 'Yes' : 'MISSING',
84-
];
77+
foreach ($config->psr4 as $ns => $paths) {
78+
if (is_string($paths)) {
79+
$paths = [$paths];
80+
}
81+
82+
foreach ($paths as $path) {
83+
$path = realpath($path) ?: $path;
84+
85+
$tbody[] = [
86+
$ns,
87+
realpath($path) ?: $path,
88+
is_dir($path) ? 'Yes' : 'MISSING',
89+
];
90+
}
8591
}
8692

8793
$thead = [

system/Config/AutoloadConfig.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ class AutoloadConfig
4545
* but this should be done prior to creating any namespaced classes,
4646
* else you will need to modify all of those classes for this to work.
4747
*
48-
* @var array<string, string>
48+
* @var array<string, array<int, string>|string>
49+
* @phpstan-var array<string, string|list<string>>
4950
*/
5051
public $psr4 = [];
5152

0 commit comments

Comments
 (0)