1717
1818declare (strict_types=1 );
1919
20- class BaseClassLoader extends \Threaded implements DynamicClassLoader{
20+ class BaseClassLoader extends \ThreadedBase implements DynamicClassLoader{
2121
22- /** @var \Threaded|string[] */
22+ /**
23+ * @var \ThreadedArray|string[]
24+ * @phpstan-var \ThreadedArray<int, string>
25+ */
2326 private $ fallbackLookup ;
24- /** @var \Threaded|string[][] */
27+ /**
28+ * @var \ThreadedArray|string[][]
29+ * @phpstan-var \ThreadedArray<string, \ThreadedArray<int, string>>
30+ */
2531 private $ psr4Lookup ;
2632
2733 public function __construct (){
28- $ this ->fallbackLookup = new \Threaded ;
29- $ this ->psr4Lookup = new \Threaded ;
34+ $ this ->fallbackLookup = new \ThreadedArray () ;
35+ $ this ->psr4Lookup = new \ThreadedArray () ;
3036 }
3137
3238 protected function normalizePath (string $ path ) : string {
@@ -46,17 +52,19 @@ public function addPath(string $namespacePrefix, string $path, bool $prepend = f
4652 }else {
4753 $ namespacePrefix = trim ($ namespacePrefix , '\\' ) . '\\' ;
4854 $ this ->psr4Lookup ->synchronized (function () use ($ namespacePrefix , $ path , $ prepend ) : void {
49- /** @var \Threaded|null $list */
5055 $ list = $ this ->psr4Lookup [$ namespacePrefix ] ?? null ;
5156 if ($ list === null ){
52- $ list = $ this ->psr4Lookup [$ namespacePrefix ] = new \Threaded ;
57+ $ list = $ this ->psr4Lookup [$ namespacePrefix ] = new \ThreadedArray () ;
5358 }
5459 $ this ->appendOrPrependLookupEntry ($ list , $ path , $ prepend );
5560 });
5661 }
5762 }
5863
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 {
6068 if ($ prepend ){
6169 $ entries = $ this ->getAndRemoveLookupEntries ($ list );
6270 $ list [] = $ entry ;
@@ -69,12 +77,15 @@ protected function appendOrPrependLookupEntry(\Threaded $list, string $entry, bo
6977 }
7078
7179 /**
72- * @return mixed[]
80+ * @return string[]
81+ *
82+ * @phpstan-param \ThreadedArray<int, string> $list
83+ * @phpstan-return list<string>
7384 */
74- protected function getAndRemoveLookupEntries (\Threaded $ list ) : array {
85+ protected function getAndRemoveLookupEntries (\ThreadedArray $ list ) : array {
7586 $ entries = [];
76- while ($ list ->count () > 0 ){
77- $ entries [] = $ list -> shift () ;
87+ while (( $ entry = $ list ->shift ()) !== null ){
88+ $ entries [] = $ entry ;
7889 }
7990 return $ entries ;
8091 }
@@ -127,8 +138,6 @@ public function findClass(string $name) : ?string{
127138 while (false !== $ lastPos = strrpos ($ subPath , '\\' )){
128139 $ subPath = substr ($ subPath , 0 , $ lastPos );
129140 $ search = $ subPath . '\\' ;
130-
131- /** @var \Threaded|null $lookup */
132141 $ lookup = $ this ->psr4Lookup [$ search ] ?? null ;
133142 if ($ lookup !== null ){
134143 $ pathEnd = DIRECTORY_SEPARATOR . substr ($ logicalPathPsr4 , $ lastPos + 1 );
0 commit comments