@@ -45,63 +45,66 @@ class ClassLoader
4545 /** @var \Closure(string):void */
4646 private static $ includeFile ;
4747
48- /** @var string|null */
48+ /** @var ? string */
4949 private $ vendorDir ;
5050
5151 // PSR-4
5252 /**
53- * @var array<string, array<string, int>>
53+ * @var array[]
54+ * @psalm-var array<string, array<string, int>>
5455 */
5556 private $ prefixLengthsPsr4 = array ();
5657 /**
57- * @var array<string, list<string>>
58+ * @var array[]
59+ * @psalm-var array<string, array<int, string>>
5860 */
5961 private $ prefixDirsPsr4 = array ();
6062 /**
61- * @var list<string>
63+ * @var array[]
64+ * @psalm-var array<string, string>
6265 */
6366 private $ fallbackDirsPsr4 = array ();
6467
6568 // PSR-0
6669 /**
67- * List of PSR-0 prefixes
68- *
69- * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
70- *
71- * @var array<string, array<string, list<string>>>
70+ * @var array[]
71+ * @psalm-var array<string, array<string, string[]>>
7272 */
7373 private $ prefixesPsr0 = array ();
7474 /**
75- * @var list<string>
75+ * @var array[]
76+ * @psalm-var array<string, string>
7677 */
7778 private $ fallbackDirsPsr0 = array ();
7879
7980 /** @var bool */
8081 private $ useIncludePath = false ;
8182
8283 /**
83- * @var array<string, string>
84+ * @var string[]
85+ * @psalm-var array<string, string>
8486 */
8587 private $ classMap = array ();
8688
8789 /** @var bool */
8890 private $ classMapAuthoritative = false ;
8991
9092 /**
91- * @var array<string, bool>
93+ * @var bool[]
94+ * @psalm-var array<string, bool>
9295 */
9396 private $ missingClasses = array ();
9497
95- /** @var string|null */
98+ /** @var ? string */
9699 private $ apcuPrefix ;
97100
98101 /**
99- * @var array<string, self>
102+ * @var self[]
100103 */
101104 private static $ registeredLoaders = array ();
102105
103106 /**
104- * @param string|null $vendorDir
107+ * @param ? string $vendorDir
105108 */
106109 public function __construct ($ vendorDir = null )
107110 {
@@ -110,7 +113,7 @@ public function __construct($vendorDir = null)
110113 }
111114
112115 /**
113- * @return array< string, list<string>>
116+ * @return string[]
114117 */
115118 public function getPrefixes ()
116119 {
@@ -122,39 +125,44 @@ public function getPrefixes()
122125 }
123126
124127 /**
125- * @return array<string, list<string>>
128+ * @return array[]
129+ * @psalm-return array<string, array<int, string>>
126130 */
127131 public function getPrefixesPsr4 ()
128132 {
129133 return $ this ->prefixDirsPsr4 ;
130134 }
131135
132136 /**
133- * @return list<string>
137+ * @return array[]
138+ * @psalm-return array<string, string>
134139 */
135140 public function getFallbackDirs ()
136141 {
137142 return $ this ->fallbackDirsPsr0 ;
138143 }
139144
140145 /**
141- * @return list<string>
146+ * @return array[]
147+ * @psalm-return array<string, string>
142148 */
143149 public function getFallbackDirsPsr4 ()
144150 {
145151 return $ this ->fallbackDirsPsr4 ;
146152 }
147153
148154 /**
149- * @return array<string, string> Array of classname => path
155+ * @return string[] Array of classname => path
156+ * @psalm-return array<string, string>
150157 */
151158 public function getClassMap ()
152159 {
153160 return $ this ->classMap ;
154161 }
155162
156163 /**
157- * @param array<string, string> $classMap Class to filename map
164+ * @param string[] $classMap Class to filename map
165+ * @psalm-param array<string, string> $classMap
158166 *
159167 * @return void
160168 */
@@ -171,25 +179,24 @@ public function addClassMap(array $classMap)
171179 * Registers a set of PSR-0 directories for a given prefix, either
172180 * appending or prepending to the ones previously set for this prefix.
173181 *
174- * @param string $prefix The prefix
175- * @param list< string> |string $paths The PSR-0 root directories
176- * @param bool $prepend Whether to prepend the directories
182+ * @param string $prefix The prefix
183+ * @param string[] |string $paths The PSR-0 root directories
184+ * @param bool $prepend Whether to prepend the directories
177185 *
178186 * @return void
179187 */
180188 public function add ($ prefix , $ paths , $ prepend = false )
181189 {
182- $ paths = (array ) $ paths ;
183190 if (!$ prefix ) {
184191 if ($ prepend ) {
185192 $ this ->fallbackDirsPsr0 = array_merge (
186- $ paths ,
193+ ( array ) $ paths ,
187194 $ this ->fallbackDirsPsr0
188195 );
189196 } else {
190197 $ this ->fallbackDirsPsr0 = array_merge (
191198 $ this ->fallbackDirsPsr0 ,
192- $ paths
199+ ( array ) $ paths
193200 );
194201 }
195202
@@ -198,19 +205,19 @@ public function add($prefix, $paths, $prepend = false)
198205
199206 $ first = $ prefix [0 ];
200207 if (!isset ($ this ->prefixesPsr0 [$ first ][$ prefix ])) {
201- $ this ->prefixesPsr0 [$ first ][$ prefix ] = $ paths ;
208+ $ this ->prefixesPsr0 [$ first ][$ prefix ] = ( array ) $ paths ;
202209
203210 return ;
204211 }
205212 if ($ prepend ) {
206213 $ this ->prefixesPsr0 [$ first ][$ prefix ] = array_merge (
207- $ paths ,
214+ ( array ) $ paths ,
208215 $ this ->prefixesPsr0 [$ first ][$ prefix ]
209216 );
210217 } else {
211218 $ this ->prefixesPsr0 [$ first ][$ prefix ] = array_merge (
212219 $ this ->prefixesPsr0 [$ first ][$ prefix ],
213- $ paths
220+ ( array ) $ paths
214221 );
215222 }
216223 }
@@ -219,28 +226,27 @@ public function add($prefix, $paths, $prepend = false)
219226 * Registers a set of PSR-4 directories for a given namespace, either
220227 * appending or prepending to the ones previously set for this namespace.
221228 *
222- * @param string $prefix The prefix/namespace, with trailing '\\'
223- * @param list< string> |string $paths The PSR-4 base directories
224- * @param bool $prepend Whether to prepend the directories
229+ * @param string $prefix The prefix/namespace, with trailing '\\'
230+ * @param string[] |string $paths The PSR-4 base directories
231+ * @param bool $prepend Whether to prepend the directories
225232 *
226233 * @throws \InvalidArgumentException
227234 *
228235 * @return void
229236 */
230237 public function addPsr4 ($ prefix , $ paths , $ prepend = false )
231238 {
232- $ paths = (array ) $ paths ;
233239 if (!$ prefix ) {
234240 // Register directories for the root namespace.
235241 if ($ prepend ) {
236242 $ this ->fallbackDirsPsr4 = array_merge (
237- $ paths ,
243+ ( array ) $ paths ,
238244 $ this ->fallbackDirsPsr4
239245 );
240246 } else {
241247 $ this ->fallbackDirsPsr4 = array_merge (
242248 $ this ->fallbackDirsPsr4 ,
243- $ paths
249+ ( array ) $ paths
244250 );
245251 }
246252 } elseif (!isset ($ this ->prefixDirsPsr4 [$ prefix ])) {
@@ -250,18 +256,18 @@ public function addPsr4($prefix, $paths, $prepend = false)
250256 throw new \InvalidArgumentException ("A non-empty PSR-4 prefix must end with a namespace separator. " );
251257 }
252258 $ this ->prefixLengthsPsr4 [$ prefix [0 ]][$ prefix ] = $ length ;
253- $ this ->prefixDirsPsr4 [$ prefix ] = $ paths ;
259+ $ this ->prefixDirsPsr4 [$ prefix ] = ( array ) $ paths ;
254260 } elseif ($ prepend ) {
255261 // Prepend directories for an already registered namespace.
256262 $ this ->prefixDirsPsr4 [$ prefix ] = array_merge (
257- $ paths ,
263+ ( array ) $ paths ,
258264 $ this ->prefixDirsPsr4 [$ prefix ]
259265 );
260266 } else {
261267 // Append directories for an already registered namespace.
262268 $ this ->prefixDirsPsr4 [$ prefix ] = array_merge (
263269 $ this ->prefixDirsPsr4 [$ prefix ],
264- $ paths
270+ ( array ) $ paths
265271 );
266272 }
267273 }
@@ -270,8 +276,8 @@ public function addPsr4($prefix, $paths, $prepend = false)
270276 * Registers a set of PSR-0 directories for a given prefix,
271277 * replacing any others previously set for this prefix.
272278 *
273- * @param string $prefix The prefix
274- * @param list< string> |string $paths The PSR-0 base directories
279+ * @param string $prefix The prefix
280+ * @param string[] |string $paths The PSR-0 base directories
275281 *
276282 * @return void
277283 */
@@ -288,8 +294,8 @@ public function set($prefix, $paths)
288294 * Registers a set of PSR-4 directories for a given namespace,
289295 * replacing any others previously set for this namespace.
290296 *
291- * @param string $prefix The prefix/namespace, with trailing '\\'
292- * @param list< string> |string $paths The PSR-4 base directories
297+ * @param string $prefix The prefix/namespace, with trailing '\\'
298+ * @param string[] |string $paths The PSR-4 base directories
293299 *
294300 * @throws \InvalidArgumentException
295301 *
@@ -475,9 +481,9 @@ public function findFile($class)
475481 }
476482
477483 /**
478- * Returns the currently registered loaders keyed by their corresponding vendor directories.
484+ * Returns the currently registered loaders indexed by their corresponding vendor directories.
479485 *
480- * @return array<string, self>
486+ * @return self[]
481487 */
482488 public static function getRegisteredLoaders ()
483489 {
0 commit comments