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 4.7.6 4.7.7 4.7.8 4.7.9 4.8.0 4.9.0 4.9.1 5.0.1 5.0.2 5.1.1 5.1.2 5.1.3 5.2.0 5.2.1 5.3.2 5.3.3.1 5.3.4 5.3.5 5.3.6 5.3.7
woocommerce-multilingual / vendor / composer / ClassLoader.php
woocommerce-multilingual / vendor / composer Last commit date
installers 2 weeks ago ClassLoader.php 2 weeks ago InstalledVersions.php 2 weeks ago LICENSE 5 years ago autoload_classmap.php 2 weeks ago autoload_files.php 2 weeks ago autoload_namespaces.php 2 weeks ago autoload_psr4.php 2 weeks ago autoload_real.php 2 weeks ago autoload_static.php 2 weeks ago installed.php 2 weeks ago platform_check.php 2 weeks ago
ClassLoader.php
342 lines
1 <?php
2
3 /*
4 * This file is part of Composer.
5 *
6 * (c) Nils Adermann <naderman@naderman.de>
7 * Jordi Boggiano <j.boggiano@seld.be>
8 *
9 * For the full copyright and license information, please view the LICENSE
10 * file that was distributed with this source code.
11 */
12
13 namespace Composer\Autoload;
14
15 class ClassLoader
16 {
17 private $vendorDir;
18
19 private $prefixLengthsPsr4 = array();
20 private $prefixDirsPsr4 = array();
21 private $fallbackDirsPsr4 = array();
22
23 private $prefixesPsr0 = array();
24 private $fallbackDirsPsr0 = array();
25
26 private $useIncludePath = false;
27
28 private $classMap = array();
29
30 private $classMapAuthoritative = false;
31
32 private $missingClasses = array();
33
34 private $apcuPrefix;
35
36 private static $registeredLoaders = array();
37
38 public function __construct($vendorDir = null)
39 {
40 $this->vendorDir = $vendorDir;
41 }
42
43 public function getPrefixes()
44 {
45 if (!empty($this->prefixesPsr0)) {
46 return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
47 }
48
49 return array();
50 }
51
52 public function getPrefixesPsr4()
53 {
54 return $this->prefixDirsPsr4;
55 }
56
57 public function getFallbackDirs()
58 {
59 return $this->fallbackDirsPsr0;
60 }
61
62 public function getFallbackDirsPsr4()
63 {
64 return $this->fallbackDirsPsr4;
65 }
66
67 public function getClassMap()
68 {
69 return $this->classMap;
70 }
71
72 public function addClassMap(array $classMap)
73 {
74 if ($this->classMap) {
75 $this->classMap = array_merge($this->classMap, $classMap);
76 } else {
77 $this->classMap = $classMap;
78 }
79 }
80
81 public function add($prefix, $paths, $prepend = false)
82 {
83 if (!$prefix) {
84 if ($prepend) {
85 $this->fallbackDirsPsr0 = array_merge(
86 (array) $paths,
87 $this->fallbackDirsPsr0
88 );
89 } else {
90 $this->fallbackDirsPsr0 = array_merge(
91 $this->fallbackDirsPsr0,
92 (array) $paths
93 );
94 }
95
96 return;
97 }
98
99 $first = $prefix[0];
100 if (!isset($this->prefixesPsr0[$first][$prefix])) {
101 $this->prefixesPsr0[$first][$prefix] = (array) $paths;
102
103 return;
104 }
105 if ($prepend) {
106 $this->prefixesPsr0[$first][$prefix] = array_merge(
107 (array) $paths,
108 $this->prefixesPsr0[$first][$prefix]
109 );
110 } else {
111 $this->prefixesPsr0[$first][$prefix] = array_merge(
112 $this->prefixesPsr0[$first][$prefix],
113 (array) $paths
114 );
115 }
116 }
117
118 public function addPsr4($prefix, $paths, $prepend = false)
119 {
120 if (!$prefix) {
121 if ($prepend) {
122 $this->fallbackDirsPsr4 = array_merge(
123 (array) $paths,
124 $this->fallbackDirsPsr4
125 );
126 } else {
127 $this->fallbackDirsPsr4 = array_merge(
128 $this->fallbackDirsPsr4,
129 (array) $paths
130 );
131 }
132 } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
133 $length = strlen($prefix);
134 if ('\\' !== $prefix[$length - 1]) {
135 throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
136 }
137 $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
138 $this->prefixDirsPsr4[$prefix] = (array) $paths;
139 } elseif ($prepend) {
140 $this->prefixDirsPsr4[$prefix] = array_merge(
141 (array) $paths,
142 $this->prefixDirsPsr4[$prefix]
143 );
144 } else {
145 $this->prefixDirsPsr4[$prefix] = array_merge(
146 $this->prefixDirsPsr4[$prefix],
147 (array) $paths
148 );
149 }
150 }
151
152 public function set($prefix, $paths)
153 {
154 if (!$prefix) {
155 $this->fallbackDirsPsr0 = (array) $paths;
156 } else {
157 $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
158 }
159 }
160
161 public function setPsr4($prefix, $paths)
162 {
163 if (!$prefix) {
164 $this->fallbackDirsPsr4 = (array) $paths;
165 } else {
166 $length = strlen($prefix);
167 if ('\\' !== $prefix[$length - 1]) {
168 throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
169 }
170 $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
171 $this->prefixDirsPsr4[$prefix] = (array) $paths;
172 }
173 }
174
175 public function setUseIncludePath($useIncludePath)
176 {
177 $this->useIncludePath = $useIncludePath;
178 }
179
180 public function getUseIncludePath()
181 {
182 return $this->useIncludePath;
183 }
184
185 public function setClassMapAuthoritative($classMapAuthoritative)
186 {
187 $this->classMapAuthoritative = $classMapAuthoritative;
188 }
189
190 public function isClassMapAuthoritative()
191 {
192 return $this->classMapAuthoritative;
193 }
194
195 public function setApcuPrefix($apcuPrefix)
196 {
197 $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
198 }
199
200 public function getApcuPrefix()
201 {
202 return $this->apcuPrefix;
203 }
204
205 public function register($prepend = false)
206 {
207 spl_autoload_register(array($this, 'loadClass'), true, $prepend);
208
209 if (null === $this->vendorDir) {
210 return;
211 }
212
213 if ($prepend) {
214 self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
215 } else {
216 unset(self::$registeredLoaders[$this->vendorDir]);
217 self::$registeredLoaders[$this->vendorDir] = $this;
218 }
219 }
220
221 public function unregister()
222 {
223 spl_autoload_unregister(array($this, 'loadClass'));
224
225 if (null !== $this->vendorDir) {
226 unset(self::$registeredLoaders[$this->vendorDir]);
227 }
228 }
229
230 public function loadClass($class)
231 {
232 if ($file = $this->findFile($class)) {
233 includeFile($file);
234
235 return true;
236 }
237
238 return null;
239 }
240
241 public function findFile($class)
242 {
243 if (isset($this->classMap[$class])) {
244 return $this->classMap[$class];
245 }
246 if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
247 return false;
248 }
249 if (null !== $this->apcuPrefix) {
250 $file = apcu_fetch($this->apcuPrefix.$class, $hit);
251 if ($hit) {
252 return $file;
253 }
254 }
255
256 $file = $this->findFileWithExtension($class, '.php');
257
258 if (false === $file && defined('HHVM_VERSION')) {
259 $file = $this->findFileWithExtension($class, '.hh');
260 }
261
262 if (null !== $this->apcuPrefix) {
263 apcu_add($this->apcuPrefix.$class, $file);
264 }
265
266 if (false === $file) {
267 $this->missingClasses[$class] = true;
268 }
269
270 return $file;
271 }
272
273 public static function getRegisteredLoaders()
274 {
275 return self::$registeredLoaders;
276 }
277
278 private function findFileWithExtension($class, $ext)
279 {
280 $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
281
282 $first = $class[0];
283 if (isset($this->prefixLengthsPsr4[$first])) {
284 $subPath = $class;
285 while (false !== $lastPos = strrpos($subPath, '\\')) {
286 $subPath = substr($subPath, 0, $lastPos);
287 $search = $subPath . '\\';
288 if (isset($this->prefixDirsPsr4[$search])) {
289 $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
290 foreach ($this->prefixDirsPsr4[$search] as $dir) {
291 if (file_exists($file = $dir . $pathEnd)) {
292 return $file;
293 }
294 }
295 }
296 }
297 }
298
299 foreach ($this->fallbackDirsPsr4 as $dir) {
300 if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
301 return $file;
302 }
303 }
304
305 if (false !== $pos = strrpos($class, '\\')) {
306 $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
307 . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
308 } else {
309 $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
310 }
311
312 if (isset($this->prefixesPsr0[$first])) {
313 foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
314 if (0 === strpos($class, $prefix)) {
315 foreach ($dirs as $dir) {
316 if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
317 return $file;
318 }
319 }
320 }
321 }
322 }
323
324 foreach ($this->fallbackDirsPsr0 as $dir) {
325 if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
326 return $file;
327 }
328 }
329
330 if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
331 return $file;
332 }
333
334 return false;
335 }
336 }
337
338 function includeFile($file)
339 {
340 include $file;
341 }
342