17
17
18
18
declare (strict_types=1 );
19
19
20
- class BaseClassLoader extends \Threaded implements DynamicClassLoader{
20
+ class BaseClassLoader extends \ThreadedBase implements DynamicClassLoader{
21
21
22
- /** @var \Threaded|string[] */
22
+ /**
23
+ * @var \ThreadedArray|string[]
24
+ * @phpstan-var \ThreadedArray<int, string>
25
+ */
23
26
private $ fallbackLookup ;
24
- /** @var \Threaded|string[][] */
27
+ /**
28
+ * @var \ThreadedArray|string[][]
29
+ * @phpstan-var \ThreadedArray<string, \ThreadedArray<int, string>>
30
+ */
25
31
private $ psr4Lookup ;
26
32
27
33
public function __construct (){
28
- $ this ->fallbackLookup = new \Threaded ;
29
- $ this ->psr4Lookup = new \Threaded ;
34
+ $ this ->fallbackLookup = new \ThreadedArray () ;
35
+ $ this ->psr4Lookup = new \ThreadedArray () ;
30
36
}
31
37
32
38
protected function normalizePath (string $ path ) : string {
@@ -46,17 +52,19 @@ public function addPath(string $namespacePrefix, string $path, bool $prepend = f
46
52
}else {
47
53
$ namespacePrefix = trim ($ namespacePrefix , '\\' ) . '\\' ;
48
54
$ this ->psr4Lookup ->synchronized (function () use ($ namespacePrefix , $ path , $ prepend ) : void {
49
- /** @var \Threaded|null $list */
50
55
$ list = $ this ->psr4Lookup [$ namespacePrefix ] ?? null ;
51
56
if ($ list === null ){
52
- $ list = $ this ->psr4Lookup [$ namespacePrefix ] = new \Threaded ;
57
+ $ list = $ this ->psr4Lookup [$ namespacePrefix ] = new \ThreadedArray () ;
53
58
}
54
59
$ this ->appendOrPrependLookupEntry ($ list , $ path , $ prepend );
55
60
});
56
61
}
57
62
}
58
63
59
- protected function appendOrPrependLookupEntry (\Threaded $ list , string $ entry , bool $ prepend ) : void {
64
+ /**
65
+ * @phpstan-param \ThreadedArray<int, string> $list
66
+ */
67
+ protected function appendOrPrependLookupEntry (\ThreadedArray $ list , string $ entry , bool $ prepend ) : void {
60
68
if ($ prepend ){
61
69
$ entries = $ this ->getAndRemoveLookupEntries ($ list );
62
70
$ list [] = $ entry ;
@@ -69,12 +77,15 @@ protected function appendOrPrependLookupEntry(\Threaded $list, string $entry, bo
69
77
}
70
78
71
79
/**
72
- * @return mixed[]
80
+ * @return string[]
81
+ *
82
+ * @phpstan-param \ThreadedArray<int, string> $list
83
+ * @phpstan-return list<string>
73
84
*/
74
- protected function getAndRemoveLookupEntries (\Threaded $ list ) : array {
85
+ protected function getAndRemoveLookupEntries (\ThreadedArray $ list ) : array {
75
86
$ entries = [];
76
- while ($ list ->count () > 0 ){
77
- $ entries [] = $ list -> shift () ;
87
+ while (( $ entry = $ list ->shift ()) !== null ){
88
+ $ entries [] = $ entry ;
78
89
}
79
90
return $ entries ;
80
91
}
@@ -127,8 +138,6 @@ public function findClass(string $name) : ?string{
127
138
while (false !== $ lastPos = strrpos ($ subPath , '\\' )){
128
139
$ subPath = substr ($ subPath , 0 , $ lastPos );
129
140
$ search = $ subPath . '\\' ;
130
-
131
- /** @var \Threaded|null $lookup */
132
141
$ lookup = $ this ->psr4Lookup [$ search ] ?? null ;
133
142
if ($ lookup !== null ){
134
143
$ pathEnd = DIRECTORY_SEPARATOR . substr ($ logicalPathPsr4 , $ lastPos + 1 );
0 commit comments