4242 */
4343class ClassLoader
4444{
45- /** @var ?string */
4645 private $ vendorDir ;
4746
4847 // PSR-4
49- /**
50- * @var array[]
51- * @psalm-var array<string, array<string, int>>
52- */
5348 private $ prefixLengthsPsr4 = array ();
54- /**
55- * @var array[]
56- * @psalm-var array<string, array<int, string>>
57- */
5849 private $ prefixDirsPsr4 = array ();
59- /**
60- * @var array[]
61- * @psalm-var array<string, string>
62- */
6350 private $ fallbackDirsPsr4 = array ();
6451
6552 // PSR-0
66- /**
67- * @var array[]
68- * @psalm-var array<string, array<string, string[]>>
69- */
7053 private $ prefixesPsr0 = array ();
71- /**
72- * @var array[]
73- * @psalm-var array<string, string>
74- */
7554 private $ fallbackDirsPsr0 = array ();
7655
77- /** @var bool */
7856 private $ useIncludePath = false ;
79-
80- /**
81- * @var string[]
82- * @psalm-var array<string, string>
83- */
8457 private $ classMap = array ();
85-
86- /** @var bool */
8758 private $ classMapAuthoritative = false ;
88-
89- /**
90- * @var bool[]
91- * @psalm-var array<string, bool>
92- */
9359 private $ missingClasses = array ();
94-
95- /** @var ?string */
9660 private $ apcuPrefix ;
9761
98- /**
99- * @var self[]
100- */
10162 private static $ registeredLoaders = array ();
10263
103- /**
104- * @param ?string $vendorDir
105- */
10664 public function __construct ($ vendorDir = null )
10765 {
10866 $ this ->vendorDir = $ vendorDir ;
10967 }
11068
111- /**
112- * @return string[]
113- */
11469 public function getPrefixes ()
11570 {
11671 if (!empty ($ this ->prefixesPsr0 )) {
@@ -120,47 +75,28 @@ public function getPrefixes()
12075 return array ();
12176 }
12277
123- /**
124- * @return array[]
125- * @psalm-return array<string, array<int, string>>
126- */
12778 public function getPrefixesPsr4 ()
12879 {
12980 return $ this ->prefixDirsPsr4 ;
13081 }
13182
132- /**
133- * @return array[]
134- * @psalm-return array<string, string>
135- */
13683 public function getFallbackDirs ()
13784 {
13885 return $ this ->fallbackDirsPsr0 ;
13986 }
14087
141- /**
142- * @return array[]
143- * @psalm-return array<string, string>
144- */
14588 public function getFallbackDirsPsr4 ()
14689 {
14790 return $ this ->fallbackDirsPsr4 ;
14891 }
14992
150- /**
151- * @return string[] Array of classname => path
152- * @psalm-return array<string, string>
153- */
15493 public function getClassMap ()
15594 {
15695 return $ this ->classMap ;
15796 }
15897
15998 /**
160- * @param string[] $classMap Class to filename map
161- * @psalm-param array<string, string> $classMap
162- *
163- * @return void
99+ * @param array $classMap Class to filename map
164100 */
165101 public function addClassMap (array $ classMap )
166102 {
@@ -175,11 +111,9 @@ public function addClassMap(array $classMap)
175111 * Registers a set of PSR-0 directories for a given prefix, either
176112 * appending or prepending to the ones previously set for this prefix.
177113 *
178- * @param string $prefix The prefix
179- * @param string[]|string $paths The PSR-0 root directories
180- * @param bool $prepend Whether to prepend the directories
181- *
182- * @return void
114+ * @param string $prefix The prefix
115+ * @param array|string $paths The PSR-0 root directories
116+ * @param bool $prepend Whether to prepend the directories
183117 */
184118 public function add ($ prefix , $ paths , $ prepend = false )
185119 {
@@ -222,13 +156,11 @@ public function add($prefix, $paths, $prepend = false)
222156 * Registers a set of PSR-4 directories for a given namespace, either
223157 * appending or prepending to the ones previously set for this namespace.
224158 *
225- * @param string $prefix The prefix/namespace, with trailing '\\'
226- * @param string[] |string $paths The PSR-4 base directories
227- * @param bool $prepend Whether to prepend the directories
159+ * @param string $prefix The prefix/namespace, with trailing '\\'
160+ * @param array |string $paths The PSR-4 base directories
161+ * @param bool $prepend Whether to prepend the directories
228162 *
229163 * @throws \InvalidArgumentException
230- *
231- * @return void
232164 */
233165 public function addPsr4 ($ prefix , $ paths , $ prepend = false )
234166 {
@@ -272,10 +204,8 @@ public function addPsr4($prefix, $paths, $prepend = false)
272204 * Registers a set of PSR-0 directories for a given prefix,
273205 * replacing any others previously set for this prefix.
274206 *
275- * @param string $prefix The prefix
276- * @param string[]|string $paths The PSR-0 base directories
277- *
278- * @return void
207+ * @param string $prefix The prefix
208+ * @param array|string $paths The PSR-0 base directories
279209 */
280210 public function set ($ prefix , $ paths )
281211 {
@@ -290,12 +220,10 @@ public function set($prefix, $paths)
290220 * Registers a set of PSR-4 directories for a given namespace,
291221 * replacing any others previously set for this namespace.
292222 *
293- * @param string $prefix The prefix/namespace, with trailing '\\'
294- * @param string[] |string $paths The PSR-4 base directories
223+ * @param string $prefix The prefix/namespace, with trailing '\\'
224+ * @param array |string $paths The PSR-4 base directories
295225 *
296226 * @throws \InvalidArgumentException
297- *
298- * @return void
299227 */
300228 public function setPsr4 ($ prefix , $ paths )
301229 {
@@ -315,8 +243,6 @@ public function setPsr4($prefix, $paths)
315243 * Turns on searching the include path for class files.
316244 *
317245 * @param bool $useIncludePath
318- *
319- * @return void
320246 */
321247 public function setUseIncludePath ($ useIncludePath )
322248 {
@@ -339,8 +265,6 @@ public function getUseIncludePath()
339265 * that have not been registered with the class map.
340266 *
341267 * @param bool $classMapAuthoritative
342- *
343- * @return void
344268 */
345269 public function setClassMapAuthoritative ($ classMapAuthoritative )
346270 {
@@ -361,8 +285,6 @@ public function isClassMapAuthoritative()
361285 * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
362286 *
363287 * @param string|null $apcuPrefix
364- *
365- * @return void
366288 */
367289 public function setApcuPrefix ($ apcuPrefix )
368290 {
@@ -383,8 +305,6 @@ public function getApcuPrefix()
383305 * Registers this instance as an autoloader.
384306 *
385307 * @param bool $prepend Whether to prepend the autoloader or not
386- *
387- * @return void
388308 */
389309 public function register ($ prepend = false )
390310 {
@@ -404,8 +324,6 @@ public function register($prepend = false)
404324
405325 /**
406326 * Unregisters this instance as an autoloader.
407- *
408- * @return void
409327 */
410328 public function unregister ()
411329 {
@@ -485,11 +403,6 @@ public static function getRegisteredLoaders()
485403 return self ::$ registeredLoaders ;
486404 }
487405
488- /**
489- * @param string $class
490- * @param string $ext
491- * @return string|false
492- */
493406 private function findFileWithExtension ($ class , $ ext )
494407 {
495408 // PSR-4 lookup
@@ -561,10 +474,6 @@ private function findFileWithExtension($class, $ext)
561474 * Scope isolated include.
562475 *
563476 * Prevents access to $this/self from included files.
564- *
565- * @param string $file
566- * @return void
567- * @private
568477 */
569478function includeFile ($ file )
570479{
0 commit comments