annotate vendor/composer/ClassLoader.php @ 43:771f6803cc4b default tip

somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
author Charlie Root
date Sun, 26 Jan 2025 13:13:49 -0500
parents 1e000243b222
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1 <?php
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
2
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
3 /*
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
4 * This file is part of Composer.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
5 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
6 * (c) Nils Adermann <naderman@naderman.de>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
7 * Jordi Boggiano <j.boggiano@seld.be>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
8 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
9 * For the full copyright and license information, please view the LICENSE
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
10 * file that was distributed with this source code.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
11 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
12
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
13 namespace Composer\Autoload;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
14
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
15 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
16 * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
17 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
18 * $loader = new \Composer\Autoload\ClassLoader();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
19 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
20 * // register classes with namespaces
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
21 * $loader->add('Symfony\Component', __DIR__.'/component');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
22 * $loader->add('Symfony', __DIR__.'/framework');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
23 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
24 * // activate the autoloader
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
25 * $loader->register();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
26 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
27 * // to enable searching the include path (eg. for PEAR packages)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
28 * $loader->setUseIncludePath(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
29 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
30 * In this example, if you try to use a class in the Symfony\Component
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
31 * namespace or one of its children (Symfony\Component\Console for instance),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
32 * the autoloader will first look for the class under the component/
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
33 * directory, and it will then fallback to the framework/ directory if not
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
34 * found before giving up.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
35 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
36 * This class is loosely based on the Symfony UniversalClassLoader.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
37 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
38 * @author Fabien Potencier <fabien@symfony.com>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
39 * @author Jordi Boggiano <j.boggiano@seld.be>
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
40 * @see https://www.php-fig.org/psr/psr-0/
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
41 * @see https://www.php-fig.org/psr/psr-4/
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
42 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
43 class ClassLoader
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
44 {
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
45 /** @var \Closure(string):void */
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
46 private static $includeFile;
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
47
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
48 /** @var string|null */
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
49 private $vendorDir;
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
50
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
51 // PSR-4
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
52 /**
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
53 * @var array<string, array<string, int>>
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
54 */
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
55 private $prefixLengthsPsr4 = array();
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
56 /**
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
57 * @var array<string, list<string>>
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
58 */
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
59 private $prefixDirsPsr4 = array();
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
60 /**
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
61 * @var list<string>
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
62 */
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
63 private $fallbackDirsPsr4 = array();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
64
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
65 // PSR-0
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
66 /**
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
67 * List of PSR-0 prefixes
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
68 *
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
69 * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
70 *
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
71 * @var array<string, array<string, list<string>>>
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
72 */
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
73 private $prefixesPsr0 = array();
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
74 /**
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
75 * @var list<string>
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
76 */
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
77 private $fallbackDirsPsr0 = array();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
78
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
79 /** @var bool */
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
80 private $useIncludePath = false;
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
81
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
82 /**
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
83 * @var array<string, string>
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
84 */
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
85 private $classMap = array();
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
86
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
87 /** @var bool */
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
88 private $classMapAuthoritative = false;
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
89
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
90 /**
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
91 * @var array<string, bool>
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
92 */
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
93 private $missingClasses = array();
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
94
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
95 /** @var string|null */
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
96 private $apcuPrefix;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
97
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
98 /**
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
99 * @var array<string, self>
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
100 */
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
101 private static $registeredLoaders = array();
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
102
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
103 /**
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
104 * @param string|null $vendorDir
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
105 */
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
106 public function __construct($vendorDir = null)
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
107 {
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
108 $this->vendorDir = $vendorDir;
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
109 self::initializeIncludeClosure();
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
110 }
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
111
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
112 /**
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
113 * @return array<string, list<string>>
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
114 */
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
115 public function getPrefixes()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
116 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
117 if (!empty($this->prefixesPsr0)) {
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
118 return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
119 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
120
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
121 return array();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
122 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
123
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
124 /**
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
125 * @return array<string, list<string>>
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
126 */
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
127 public function getPrefixesPsr4()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
128 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
129 return $this->prefixDirsPsr4;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
130 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
131
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
132 /**
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
133 * @return list<string>
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
134 */
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
135 public function getFallbackDirs()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
136 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
137 return $this->fallbackDirsPsr0;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
138 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
139
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
140 /**
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
141 * @return list<string>
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
142 */
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
143 public function getFallbackDirsPsr4()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
144 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
145 return $this->fallbackDirsPsr4;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
146 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
147
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
148 /**
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
149 * @return array<string, string> Array of classname => path
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
150 */
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
151 public function getClassMap()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
152 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
153 return $this->classMap;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
154 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
155
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
156 /**
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
157 * @param array<string, string> $classMap Class to filename map
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
158 *
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
159 * @return void
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
160 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
161 public function addClassMap(array $classMap)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
162 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
163 if ($this->classMap) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
164 $this->classMap = array_merge($this->classMap, $classMap);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
165 } else {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
166 $this->classMap = $classMap;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
167 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
168 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
169
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
170 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
171 * Registers a set of PSR-0 directories for a given prefix, either
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
172 * appending or prepending to the ones previously set for this prefix.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
173 *
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
174 * @param string $prefix The prefix
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
175 * @param list<string>|string $paths The PSR-0 root directories
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
176 * @param bool $prepend Whether to prepend the directories
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
177 *
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
178 * @return void
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
179 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
180 public function add($prefix, $paths, $prepend = false)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
181 {
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
182 $paths = (array) $paths;
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
183 if (!$prefix) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
184 if ($prepend) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
185 $this->fallbackDirsPsr0 = array_merge(
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
186 $paths,
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
187 $this->fallbackDirsPsr0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
188 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
189 } else {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
190 $this->fallbackDirsPsr0 = array_merge(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
191 $this->fallbackDirsPsr0,
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
192 $paths
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
193 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
194 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
195
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
196 return;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
197 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
198
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
199 $first = $prefix[0];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
200 if (!isset($this->prefixesPsr0[$first][$prefix])) {
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
201 $this->prefixesPsr0[$first][$prefix] = $paths;
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
202
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
203 return;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
204 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
205 if ($prepend) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
206 $this->prefixesPsr0[$first][$prefix] = array_merge(
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
207 $paths,
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
208 $this->prefixesPsr0[$first][$prefix]
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
209 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
210 } else {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
211 $this->prefixesPsr0[$first][$prefix] = array_merge(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
212 $this->prefixesPsr0[$first][$prefix],
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
213 $paths
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
214 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
215 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
216 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
217
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
218 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
219 * Registers a set of PSR-4 directories for a given namespace, either
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
220 * appending or prepending to the ones previously set for this namespace.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
221 *
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
222 * @param string $prefix The prefix/namespace, with trailing '\\'
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
223 * @param list<string>|string $paths The PSR-4 base directories
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
224 * @param bool $prepend Whether to prepend the directories
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
225 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
226 * @throws \InvalidArgumentException
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
227 *
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
228 * @return void
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
229 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
230 public function addPsr4($prefix, $paths, $prepend = false)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
231 {
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
232 $paths = (array) $paths;
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
233 if (!$prefix) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
234 // Register directories for the root namespace.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
235 if ($prepend) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
236 $this->fallbackDirsPsr4 = array_merge(
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
237 $paths,
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
238 $this->fallbackDirsPsr4
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
239 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
240 } else {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
241 $this->fallbackDirsPsr4 = array_merge(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
242 $this->fallbackDirsPsr4,
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
243 $paths
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
244 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
245 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
246 } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
247 // Register directories for a new namespace.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
248 $length = strlen($prefix);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
249 if ('\\' !== $prefix[$length - 1]) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
250 throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
251 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
252 $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
253 $this->prefixDirsPsr4[$prefix] = $paths;
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
254 } elseif ($prepend) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
255 // Prepend directories for an already registered namespace.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
256 $this->prefixDirsPsr4[$prefix] = array_merge(
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
257 $paths,
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
258 $this->prefixDirsPsr4[$prefix]
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
259 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
260 } else {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
261 // Append directories for an already registered namespace.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
262 $this->prefixDirsPsr4[$prefix] = array_merge(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
263 $this->prefixDirsPsr4[$prefix],
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
264 $paths
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
265 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
266 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
267 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
268
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
269 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
270 * Registers a set of PSR-0 directories for a given prefix,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
271 * replacing any others previously set for this prefix.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
272 *
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
273 * @param string $prefix The prefix
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
274 * @param list<string>|string $paths The PSR-0 base directories
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
275 *
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
276 * @return void
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
277 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
278 public function set($prefix, $paths)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
279 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
280 if (!$prefix) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
281 $this->fallbackDirsPsr0 = (array) $paths;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
282 } else {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
283 $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
284 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
285 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
286
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
287 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
288 * Registers a set of PSR-4 directories for a given namespace,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
289 * replacing any others previously set for this namespace.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
290 *
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
291 * @param string $prefix The prefix/namespace, with trailing '\\'
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
292 * @param list<string>|string $paths The PSR-4 base directories
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
293 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
294 * @throws \InvalidArgumentException
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
295 *
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
296 * @return void
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
297 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
298 public function setPsr4($prefix, $paths)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
299 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
300 if (!$prefix) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
301 $this->fallbackDirsPsr4 = (array) $paths;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
302 } else {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
303 $length = strlen($prefix);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
304 if ('\\' !== $prefix[$length - 1]) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
305 throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
306 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
307 $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
308 $this->prefixDirsPsr4[$prefix] = (array) $paths;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
309 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
310 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
311
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
312 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
313 * Turns on searching the include path for class files.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
314 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
315 * @param bool $useIncludePath
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
316 *
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
317 * @return void
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
318 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
319 public function setUseIncludePath($useIncludePath)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
320 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
321 $this->useIncludePath = $useIncludePath;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
322 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
323
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
324 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
325 * Can be used to check if the autoloader uses the include path to check
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
326 * for classes.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
327 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
328 * @return bool
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
329 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
330 public function getUseIncludePath()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
331 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
332 return $this->useIncludePath;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
333 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
334
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
335 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
336 * Turns off searching the prefix and fallback directories for classes
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
337 * that have not been registered with the class map.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
338 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
339 * @param bool $classMapAuthoritative
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
340 *
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
341 * @return void
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
342 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
343 public function setClassMapAuthoritative($classMapAuthoritative)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
344 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
345 $this->classMapAuthoritative = $classMapAuthoritative;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
346 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
347
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
348 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
349 * Should class lookup fail if not found in the current class map?
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
350 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
351 * @return bool
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
352 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
353 public function isClassMapAuthoritative()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
354 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
355 return $this->classMapAuthoritative;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
356 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
357
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
358 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
359 * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
360 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
361 * @param string|null $apcuPrefix
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
362 *
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
363 * @return void
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
364 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
365 public function setApcuPrefix($apcuPrefix)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
366 {
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
367 $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
368 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
369
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
370 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
371 * The APCu prefix in use, or null if APCu caching is not enabled.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
372 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
373 * @return string|null
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
374 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
375 public function getApcuPrefix()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
376 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
377 return $this->apcuPrefix;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
378 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
379
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
380 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
381 * Registers this instance as an autoloader.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
382 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
383 * @param bool $prepend Whether to prepend the autoloader or not
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
384 *
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
385 * @return void
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
386 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
387 public function register($prepend = false)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
388 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
389 spl_autoload_register(array($this, 'loadClass'), true, $prepend);
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
390
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
391 if (null === $this->vendorDir) {
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
392 return;
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
393 }
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
394
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
395 if ($prepend) {
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
396 self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
397 } else {
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
398 unset(self::$registeredLoaders[$this->vendorDir]);
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
399 self::$registeredLoaders[$this->vendorDir] = $this;
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
400 }
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
401 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
402
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
403 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
404 * Unregisters this instance as an autoloader.
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
405 *
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
406 * @return void
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
407 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
408 public function unregister()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
409 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
410 spl_autoload_unregister(array($this, 'loadClass'));
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
411
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
412 if (null !== $this->vendorDir) {
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
413 unset(self::$registeredLoaders[$this->vendorDir]);
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
414 }
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
415 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
416
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
417 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
418 * Loads the given class or interface.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
419 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
420 * @param string $class The name of the class
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
421 * @return true|null True if loaded, null otherwise
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
422 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
423 public function loadClass($class)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
424 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
425 if ($file = $this->findFile($class)) {
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
426 $includeFile = self::$includeFile;
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
427 $includeFile($file);
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
428
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
429 return true;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
430 }
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
431
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
432 return null;
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
433 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
434
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
435 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
436 * Finds the path to the file where the class is defined.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
437 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
438 * @param string $class The name of the class
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
439 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
440 * @return string|false The path if found, false otherwise
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
441 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
442 public function findFile($class)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
443 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
444 // class map lookup
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
445 if (isset($this->classMap[$class])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
446 return $this->classMap[$class];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
447 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
448 if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
449 return false;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
450 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
451 if (null !== $this->apcuPrefix) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
452 $file = apcu_fetch($this->apcuPrefix.$class, $hit);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
453 if ($hit) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
454 return $file;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
455 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
456 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
457
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
458 $file = $this->findFileWithExtension($class, '.php');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
459
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
460 // Search for Hack files if we are running on HHVM
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
461 if (false === $file && defined('HHVM_VERSION')) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
462 $file = $this->findFileWithExtension($class, '.hh');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
463 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
464
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
465 if (null !== $this->apcuPrefix) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
466 apcu_add($this->apcuPrefix.$class, $file);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
467 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
468
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
469 if (false === $file) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
470 // Remember that this class does not exist.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
471 $this->missingClasses[$class] = true;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
472 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
473
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
474 return $file;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
475 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
476
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
477 /**
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
478 * Returns the currently registered loaders keyed by their corresponding vendor directories.
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
479 *
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
480 * @return array<string, self>
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
481 */
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
482 public static function getRegisteredLoaders()
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
483 {
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
484 return self::$registeredLoaders;
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
485 }
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
486
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
487 /**
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
488 * @param string $class
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
489 * @param string $ext
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
490 * @return string|false
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
491 */
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
492 private function findFileWithExtension($class, $ext)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
493 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
494 // PSR-4 lookup
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
495 $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
496
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
497 $first = $class[0];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
498 if (isset($this->prefixLengthsPsr4[$first])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
499 $subPath = $class;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
500 while (false !== $lastPos = strrpos($subPath, '\\')) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
501 $subPath = substr($subPath, 0, $lastPos);
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
502 $search = $subPath . '\\';
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
503 if (isset($this->prefixDirsPsr4[$search])) {
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
504 $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
505 foreach ($this->prefixDirsPsr4[$search] as $dir) {
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
506 if (file_exists($file = $dir . $pathEnd)) {
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
507 return $file;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
508 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
509 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
510 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
511 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
512 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
513
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
514 // PSR-4 fallback dirs
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
515 foreach ($this->fallbackDirsPsr4 as $dir) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
516 if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
517 return $file;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
518 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
519 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
520
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
521 // PSR-0 lookup
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
522 if (false !== $pos = strrpos($class, '\\')) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
523 // namespaced class name
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
524 $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
525 . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
526 } else {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
527 // PEAR-like class name
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
528 $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
529 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
530
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
531 if (isset($this->prefixesPsr0[$first])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
532 foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
533 if (0 === strpos($class, $prefix)) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
534 foreach ($dirs as $dir) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
535 if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
536 return $file;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
537 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
538 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
539 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
540 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
541 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
542
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
543 // PSR-0 fallback dirs
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
544 foreach ($this->fallbackDirsPsr0 as $dir) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
545 if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
546 return $file;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
547 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
548 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
549
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
550 // PSR-0 include paths.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
551 if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
552 return $file;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
553 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
554
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
555 return false;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
556 }
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
557
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
558 /**
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
559 * @return void
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
560 */
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
561 private static function initializeIncludeClosure()
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
562 {
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
563 if (self::$includeFile !== null) {
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
564 return;
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
565 }
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
566
43
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
567 /**
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
568 * Scope isolated include.
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
569 *
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
570 * Prevents access to $this/self from included files.
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
571 *
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
572 * @param string $file
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
573 * @return void
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
574 */
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
575 self::$includeFile = \Closure::bind(static function($file) {
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
576 include $file;
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
577 }, null, null);
771f6803cc4b somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
Charlie Root
parents: 0
diff changeset
578 }
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
579 }