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