|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Spiral\Boot\Bootloader; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* @psalm-import-type TClass from \Spiral\Boot\BootloadManagerInterface |
|
9
|
|
|
*/ |
|
10
|
|
|
final class BootloaderRegistry implements BootloaderRegistryInterface |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* @param array<TClass>|array<TClass, array<string, mixed>> $systemBootloaders |
|
14
|
|
|
* @param array<TClass>|array<TClass, array<string, mixed>> $bootloaders |
|
15
|
|
|
*/ |
|
16
|
423 |
|
public function __construct( |
|
17
|
|
|
private array $systemBootloaders = [], |
|
18
|
|
|
private array $bootloaders = [], |
|
19
|
|
|
) { |
|
20
|
423 |
|
} |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @param TClass|array<TClass, array<string, mixed>> $bootloader |
|
|
|
|
|
|
24
|
|
|
*/ |
|
25
|
2 |
|
public function registerSystem(string|array $bootloader): void |
|
26
|
|
|
{ |
|
27
|
2 |
|
if ($this->hasBootloader($bootloader)) { |
|
28
|
1 |
|
return; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
2 |
|
\is_string($bootloader) |
|
|
|
|
|
|
32
|
2 |
|
? $this->systemBootloaders[] = $bootloader |
|
33
|
1 |
|
: $this->systemBootloaders[\array_key_first($bootloader)] = $bootloader[\array_key_first($bootloader)] |
|
34
|
2 |
|
; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param TClass|array<TClass, array<string, mixed>> $bootloader |
|
39
|
|
|
*/ |
|
40
|
2 |
|
public function register(string|array $bootloader): void |
|
41
|
|
|
{ |
|
42
|
2 |
|
if ($this->hasBootloader($bootloader)) { |
|
43
|
1 |
|
return; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
2 |
|
\is_string($bootloader) |
|
|
|
|
|
|
47
|
2 |
|
? $this->bootloaders[] = $bootloader |
|
48
|
1 |
|
: $this->bootloaders[\array_key_first($bootloader)] = $bootloader[\array_key_first($bootloader)] |
|
49
|
2 |
|
; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @return array<TClass>|array<TClass, array<string, mixed>> |
|
54
|
|
|
*/ |
|
55
|
422 |
|
public function getSystemBootloaders(): array |
|
56
|
|
|
{ |
|
57
|
422 |
|
return $this->systemBootloaders; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @return array<TClass>|array<TClass, array<string, mixed>> |
|
62
|
|
|
*/ |
|
63
|
422 |
|
public function getBootloaders(): array |
|
64
|
|
|
{ |
|
65
|
422 |
|
return $this->bootloaders; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @param TClass|array<TClass, array<string, mixed>> $bootloader |
|
70
|
|
|
*/ |
|
71
|
3 |
|
private function hasBootloader(string|array $bootloader): bool |
|
72
|
|
|
{ |
|
73
|
3 |
|
if (\is_array($bootloader)) { |
|
|
|
|
|
|
74
|
2 |
|
return false; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
3 |
|
return |
|
78
|
3 |
|
\in_array($bootloader, $this->systemBootloaders, true) || |
|
79
|
3 |
|
\in_array($bootloader, $this->bootloaders, true); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths