PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.7.1
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.7.1
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
← All changes | vendor/composer/ClassLoader.php +65 -72 3.10.153.7.1 View file →
@@ -41,39 +41,37 @@
41 41 * @see https://www.php-fig.org/psr/psr-4/
42 42 */
43 43 class ClassLoader
44 44 {
45 - /** @var \Closure(string):void */
46 - private static $includeFile;
47 -
48 - /** @var string|null */
45 + /** @var ?string */
49 46 private $vendorDir;
50 47
51 48 // PSR-4
52 49 /**
53 - * @var array<string, array<string, int>>
50 + * @var array[]
51 + * @psalm-var array<string, array<string, int>>
54 52 */
55 53 private $prefixLengthsPsr4 = array();
56 54 /**
57 - * @var array<string, list<string>>
55 + * @var array[]
56 + * @psalm-var array<string, array<int, string>>
58 57 */
59 58 private $prefixDirsPsr4 = array();
60 59 /**
61 - * @var list<string>
60 + * @var array[]
61 + * @psalm-var array<string, string>
62 62 */
63 63 private $fallbackDirsPsr4 = array();
64 64
65 65 // PSR-0
66 66 /**
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>>>
67 + * @var array[]
68 + * @psalm-var array<string, array<string, string[]>>
72 69 */
73 70 private $prefixesPsr0 = array();
74 71 /**
75 - * @var list<string>
72 + * @var array[]
73 + * @psalm-var array<string, string>
76 74 */
77 75 private $fallbackDirsPsr0 = array();
78 76
79 77 /** @var bool */
@@ -79,9 +77,10 @@
79 77 /** @var bool */
80 78 private $useIncludePath = false;
81 79
82 80 /**
83 - * @var array<string, string>
81 + * @var string[]
82 + * @psalm-var array<string, string>
84 83 */
85 84 private $classMap = array();
86 85
87 86 /** @var bool */
@@ -87,31 +86,31 @@
87 86 /** @var bool */
88 87 private $classMapAuthoritative = false;
89 88
90 89 /**
91 - * @var array<string, bool>
90 + * @var bool[]
91 + * @psalm-var array<string, bool>
92 92 */
93 93 private $missingClasses = array();
94 94
95 - /** @var string|null */
95 + /** @var ?string */
96 96 private $apcuPrefix;
97 97
98 98 /**
99 - * @var array<string, self>
99 + * @var self[]
100 100 */
101 101 private static $registeredLoaders = array();
102 102
103 103 /**
104 - * @param string|null $vendorDir
104 + * @param ?string $vendorDir
105 105 */
106 106 public function __construct($vendorDir = null)
107 107 {
108 108 $this->vendorDir = $vendorDir;
109 - self::initializeIncludeClosure();
110 109 }
111 110
112 111 /**
113 - * @return array<string, list<string>>
112 + * @return string[]
114 113 */
115 114 public function getPrefixes()
116 115 {
117 116 if (!empty($this->prefixesPsr0)) {
@@ -121,9 +120,10 @@
121 120 return array();
122 121 }
123 122
124 123 /**
125 - * @return array<string, list<string>>
124 + * @return array[]
125 + * @psalm-return array<string, array<int, string>>
126 126 */
127 127 public function getPrefixesPsr4()
128 128 {
129 129 return $this->prefixDirsPsr4;
@@ -129,9 +129,10 @@
129 129 return $this->prefixDirsPsr4;
130 130 }
131 131
132 132 /**
133 - * @return list<string>
133 + * @return array[]
134 + * @psalm-return array<string, string>
134 135 */
135 136 public function getFallbackDirs()
136 137 {
137 138 return $this->fallbackDirsPsr0;
@@ -137,9 +138,10 @@
137 138 return $this->fallbackDirsPsr0;
138 139 }
139 140
140 141 /**
141 - * @return list<string>
142 + * @return array[]
143 + * @psalm-return array<string, string>
142 144 */
143 145 public function getFallbackDirsPsr4()
144 146 {
145 147 return $this->fallbackDirsPsr4;
@@ -145,9 +147,10 @@
145 147 return $this->fallbackDirsPsr4;
146 148 }
147 149
148 150 /**
149 - * @return array<string, string> Array of classname => path
151 + * @return string[] Array of classname => path
152 + * @psalm-var array<string, string>
150 153 */
151 154 public function getClassMap()
152 155 {
153 156 return $this->classMap;
@@ -153,9 +156,10 @@
153 156 return $this->classMap;
154 157 }
155 158
156 159 /**
157 - * @param array<string, string> $classMap Class to filename map
160 + * @param string[] $classMap Class to filename map
161 + * @psalm-param array<string, string> $classMap
158 162 *
159 163 * @return void
160 164 */
161 165 public function addClassMap(array $classMap)
@@ -170,27 +174,26 @@
170 174 /**
171 175 * Registers a set of PSR-0 directories for a given prefix, either
172 176 * appending or prepending to the ones previously set for this prefix.
173 177 *
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
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
177 181 *
178 182 * @return void
179 183 */
180 184 public function add($prefix, $paths, $prepend = false)
181 185 {
182 - $paths = (array) $paths;
183 186 if (!$prefix) {
184 187 if ($prepend) {
185 188 $this->fallbackDirsPsr0 = array_merge(
186 - $paths,
189 + (array) $paths,
187 190 $this->fallbackDirsPsr0
188 191 );
189 192 } else {
190 193 $this->fallbackDirsPsr0 = array_merge(
191 194 $this->fallbackDirsPsr0,
192 - $paths
195 + (array) $paths
193 196 );
194 197 }
195 198
196 199 return;
@@ -197,21 +200,21 @@
197 200 }
198 201
199 202 $first = $prefix[0];
200 203 if (!isset($this->prefixesPsr0[$first][$prefix])) {
201 - $this->prefixesPsr0[$first][$prefix] = $paths;
204 + $this->prefixesPsr0[$first][$prefix] = (array) $paths;
202 205
203 206 return;
204 207 }
205 208 if ($prepend) {
206 209 $this->prefixesPsr0[$first][$prefix] = array_merge(
207 - $paths,
210 + (array) $paths,
208 211 $this->prefixesPsr0[$first][$prefix]
209 212 );
210 213 } else {
211 214 $this->prefixesPsr0[$first][$prefix] = array_merge(
212 215 $this->prefixesPsr0[$first][$prefix],
213 - $paths
216 + (array) $paths
214 217 );
215 218 }
216 219 }
217 220
@@ -218,11 +221,11 @@
218 221 /**
219 222 * Registers a set of PSR-4 directories for a given namespace, either
220 223 * appending or prepending to the ones previously set for this namespace.
221 224 *
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
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
225 228 *
226 229 * @throws \InvalidArgumentException
227 230 *
228 231 * @return void
@@ -228,20 +231,19 @@
228 231 * @return void
229 232 */
230 233 public function addPsr4($prefix, $paths, $prepend = false)
231 234 {
232 - $paths = (array) $paths;
233 235 if (!$prefix) {
234 236 // Register directories for the root namespace.
235 237 if ($prepend) {
236 238 $this->fallbackDirsPsr4 = array_merge(
237 - $paths,
239 + (array) $paths,
238 240 $this->fallbackDirsPsr4
239 241 );
240 242 } else {
241 243 $this->fallbackDirsPsr4 = array_merge(
242 244 $this->fallbackDirsPsr4,
243 - $paths
245 + (array) $paths
244 246 );
245 247 }
246 248 } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
247 249 // Register directories for a new namespace.
@@ -249,13 +251,13 @@
249 251 if ('\\' !== $prefix[$length - 1]) {
250 252 throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
251 253 }
252 254 $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
253 - $this->prefixDirsPsr4[$prefix] = $paths;
255 + $this->prefixDirsPsr4[$prefix] = (array) $paths;
254 256 } elseif ($prepend) {
255 257 // Prepend directories for an already registered namespace.
256 258 $this->prefixDirsPsr4[$prefix] = array_merge(
257 - $paths,
259 + (array) $paths,
258 260 $this->prefixDirsPsr4[$prefix]
259 261 );
260 262 } else {
261 263 // Append directories for an already registered namespace.
@@ -260,9 +262,9 @@
260 262 } else {
261 263 // Append directories for an already registered namespace.
262 264 $this->prefixDirsPsr4[$prefix] = array_merge(
263 265 $this->prefixDirsPsr4[$prefix],
264 - $paths
266 + (array) $paths
265 267 );
266 268 }
267 269 }
268 270
@@ -269,10 +271,10 @@
269 271 /**
270 272 * Registers a set of PSR-0 directories for a given prefix,
271 273 * replacing any others previously set for this prefix.
272 274 *
273 - * @param string $prefix The prefix
274 - * @param list<string>|string $paths The PSR-0 base directories
275 + * @param string $prefix The prefix
276 + * @param string[]|string $paths The PSR-0 base directories
275 277 *
276 278 * @return void
277 279 */
278 280 public function set($prefix, $paths)
@@ -287,10 +289,10 @@
287 289 /**
288 290 * Registers a set of PSR-4 directories for a given namespace,
289 291 * replacing any others previously set for this namespace.
290 292 *
291 - * @param string $prefix The prefix/namespace, with trailing '\\'
292 - * @param list<string>|string $paths The PSR-4 base directories
293 + * @param string $prefix The prefix/namespace, with trailing '\\'
294 + * @param string[]|string $paths The PSR-4 base directories
293 295 *
294 296 * @throws \InvalidArgumentException
295 297 *
296 298 * @return void
@@ -422,10 +424,9 @@
422 424 */
423 425 public function loadClass($class)
424 426 {
425 427 if ($file = $this->findFile($class)) {
426 - $includeFile = self::$includeFile;
427 - $includeFile($file);
428 + includeFile($file);
428 429
429 430 return true;
430 431 }
431 432
@@ -474,11 +475,11 @@
474 475 return $file;
475 476 }
476 477
477 478 /**
478 - * Returns the currently registered loaders keyed by their corresponding vendor directories.
479 + * Returns the currently registered loaders indexed by their corresponding vendor directories.
479 480 *
480 - * @return array<string, self>
481 + * @return self[]
481 482 */
482 483 public static function getRegisteredLoaders()
483 484 {
484 485 return self::$registeredLoaders;
@@ -553,27 +554,19 @@
553 554 }
554 555
555 556 return false;
556 557 }
558 +}
557 559
558 - /**
559 - * @return void
560 - */
561 - private static function initializeIncludeClosure()
562 - {
563 - if (self::$includeFile !== null) {
564 - return;
565 - }
566 -
567 - /**
568 - * Scope isolated include.
569 - *
570 - * Prevents access to $this/self from included files.
571 - *
572 - * @param string $file
573 - * @return void
574 - */
575 - self::$includeFile = \Closure::bind(static function($file) {
576 - include $file;
577 - }, null, null);
578 - }
560 +/**
561 + * Scope isolated include.
562 + *
563 + * Prevents access to $this/self from included files.
564 + *
565 + * @param string $file
566 + * @return void
567 + * @private
568 + */
569 +function includeFile($file)
570 +{
571 + include $file;
579 572 }