Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 * This file is part of the Symfony package.
|
Chris@0
|
5 *
|
Chris@0
|
6 * (c) Fabien Potencier <fabien@symfony.com>
|
Chris@0
|
7 *
|
Chris@0
|
8 * For the full copyright and license information, please view the LICENSE
|
Chris@0
|
9 * file that was distributed with this source code.
|
Chris@0
|
10 */
|
Chris@0
|
11
|
Chris@0
|
12 namespace Symfony\Component\Debug;
|
Chris@0
|
13
|
Chris@0
|
14 /**
|
Chris@0
|
15 * Autoloader checking if the class is really defined in the file found.
|
Chris@0
|
16 *
|
Chris@0
|
17 * The ClassLoader will wrap all registered autoloaders
|
Chris@0
|
18 * and will throw an exception if a file is found but does
|
Chris@0
|
19 * not declare the class.
|
Chris@0
|
20 *
|
Chris@0
|
21 * @author Fabien Potencier <fabien@symfony.com>
|
Chris@0
|
22 * @author Christophe Coevoet <stof@notk.org>
|
Chris@0
|
23 * @author Nicolas Grekas <p@tchwork.com>
|
Chris@0
|
24 */
|
Chris@0
|
25 class DebugClassLoader
|
Chris@0
|
26 {
|
Chris@0
|
27 private $classLoader;
|
Chris@0
|
28 private $isFinder;
|
Chris@17
|
29 private $loaded = [];
|
Chris@0
|
30 private static $caseCheck;
|
Chris@17
|
31 private static $checkedClasses = [];
|
Chris@17
|
32 private static $final = [];
|
Chris@17
|
33 private static $finalMethods = [];
|
Chris@17
|
34 private static $deprecated = [];
|
Chris@17
|
35 private static $internal = [];
|
Chris@17
|
36 private static $internalMethods = [];
|
Chris@17
|
37 private static $php7Reserved = ['int' => 1, 'float' => 1, 'bool' => 1, 'string' => 1, 'true' => 1, 'false' => 1, 'null' => 1];
|
Chris@17
|
38 private static $darwinCache = ['/' => ['/', []]];
|
Chris@0
|
39
|
Chris@0
|
40 public function __construct(callable $classLoader)
|
Chris@0
|
41 {
|
Chris@0
|
42 $this->classLoader = $classLoader;
|
Chris@17
|
43 $this->isFinder = \is_array($classLoader) && method_exists($classLoader[0], 'findFile');
|
Chris@0
|
44
|
Chris@0
|
45 if (!isset(self::$caseCheck)) {
|
Chris@17
|
46 $file = file_exists(__FILE__) ? __FILE__ : rtrim(realpath('.'), \DIRECTORY_SEPARATOR);
|
Chris@17
|
47 $i = strrpos($file, \DIRECTORY_SEPARATOR);
|
Chris@0
|
48 $dir = substr($file, 0, 1 + $i);
|
Chris@0
|
49 $file = substr($file, 1 + $i);
|
Chris@0
|
50 $test = strtoupper($file) === $file ? strtolower($file) : strtoupper($file);
|
Chris@0
|
51 $test = realpath($dir.$test);
|
Chris@0
|
52
|
Chris@0
|
53 if (false === $test || false === $i) {
|
Chris@0
|
54 // filesystem is case sensitive
|
Chris@0
|
55 self::$caseCheck = 0;
|
Chris@17
|
56 } elseif (substr($test, -\strlen($file)) === $file) {
|
Chris@0
|
57 // filesystem is case insensitive and realpath() normalizes the case of characters
|
Chris@0
|
58 self::$caseCheck = 1;
|
Chris@0
|
59 } elseif (false !== stripos(PHP_OS, 'darwin')) {
|
Chris@0
|
60 // on MacOSX, HFS+ is case insensitive but realpath() doesn't normalize the case of characters
|
Chris@0
|
61 self::$caseCheck = 2;
|
Chris@0
|
62 } else {
|
Chris@0
|
63 // filesystem case checks failed, fallback to disabling them
|
Chris@0
|
64 self::$caseCheck = 0;
|
Chris@0
|
65 }
|
Chris@0
|
66 }
|
Chris@0
|
67 }
|
Chris@0
|
68
|
Chris@0
|
69 /**
|
Chris@0
|
70 * Gets the wrapped class loader.
|
Chris@0
|
71 *
|
Chris@0
|
72 * @return callable The wrapped class loader
|
Chris@0
|
73 */
|
Chris@0
|
74 public function getClassLoader()
|
Chris@0
|
75 {
|
Chris@0
|
76 return $this->classLoader;
|
Chris@0
|
77 }
|
Chris@0
|
78
|
Chris@0
|
79 /**
|
Chris@0
|
80 * Wraps all autoloaders.
|
Chris@0
|
81 */
|
Chris@0
|
82 public static function enable()
|
Chris@0
|
83 {
|
Chris@0
|
84 // Ensures we don't hit https://bugs.php.net/42098
|
Chris@0
|
85 class_exists('Symfony\Component\Debug\ErrorHandler');
|
Chris@0
|
86 class_exists('Psr\Log\LogLevel');
|
Chris@0
|
87
|
Chris@17
|
88 if (!\is_array($functions = spl_autoload_functions())) {
|
Chris@0
|
89 return;
|
Chris@0
|
90 }
|
Chris@0
|
91
|
Chris@0
|
92 foreach ($functions as $function) {
|
Chris@0
|
93 spl_autoload_unregister($function);
|
Chris@0
|
94 }
|
Chris@0
|
95
|
Chris@0
|
96 foreach ($functions as $function) {
|
Chris@17
|
97 if (!\is_array($function) || !$function[0] instanceof self) {
|
Chris@17
|
98 $function = [new static($function), 'loadClass'];
|
Chris@0
|
99 }
|
Chris@0
|
100
|
Chris@0
|
101 spl_autoload_register($function);
|
Chris@0
|
102 }
|
Chris@0
|
103 }
|
Chris@0
|
104
|
Chris@0
|
105 /**
|
Chris@0
|
106 * Disables the wrapping.
|
Chris@0
|
107 */
|
Chris@0
|
108 public static function disable()
|
Chris@0
|
109 {
|
Chris@17
|
110 if (!\is_array($functions = spl_autoload_functions())) {
|
Chris@0
|
111 return;
|
Chris@0
|
112 }
|
Chris@0
|
113
|
Chris@0
|
114 foreach ($functions as $function) {
|
Chris@0
|
115 spl_autoload_unregister($function);
|
Chris@0
|
116 }
|
Chris@0
|
117
|
Chris@0
|
118 foreach ($functions as $function) {
|
Chris@17
|
119 if (\is_array($function) && $function[0] instanceof self) {
|
Chris@0
|
120 $function = $function[0]->getClassLoader();
|
Chris@0
|
121 }
|
Chris@0
|
122
|
Chris@0
|
123 spl_autoload_register($function);
|
Chris@0
|
124 }
|
Chris@0
|
125 }
|
Chris@0
|
126
|
Chris@0
|
127 /**
|
Chris@17
|
128 * @return string|null
|
Chris@17
|
129 */
|
Chris@17
|
130 public function findFile($class)
|
Chris@17
|
131 {
|
Chris@17
|
132 return $this->isFinder ? $this->classLoader[0]->findFile($class) ?: null : null;
|
Chris@17
|
133 }
|
Chris@17
|
134
|
Chris@17
|
135 /**
|
Chris@0
|
136 * Loads the given class or interface.
|
Chris@0
|
137 *
|
Chris@0
|
138 * @param string $class The name of the class
|
Chris@0
|
139 *
|
Chris@0
|
140 * @throws \RuntimeException
|
Chris@0
|
141 */
|
Chris@0
|
142 public function loadClass($class)
|
Chris@0
|
143 {
|
Chris@12
|
144 $e = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
|
Chris@0
|
145
|
Chris@0
|
146 try {
|
Chris@12
|
147 if ($this->isFinder && !isset($this->loaded[$class])) {
|
Chris@12
|
148 $this->loaded[$class] = true;
|
Chris@17
|
149 if (!$file = $this->classLoader[0]->findFile($class) ?: false) {
|
Chris@17
|
150 // no-op
|
Chris@17
|
151 } elseif (\function_exists('opcache_is_script_cached') && @opcache_is_script_cached($file)) {
|
Chris@12
|
152 require $file;
|
Chris@12
|
153
|
Chris@17
|
154 return;
|
Chris@17
|
155 } else {
|
Chris@17
|
156 require $file;
|
Chris@0
|
157 }
|
Chris@0
|
158 } else {
|
Chris@17
|
159 \call_user_func($this->classLoader, $class);
|
Chris@0
|
160 $file = false;
|
Chris@0
|
161 }
|
Chris@0
|
162 } finally {
|
Chris@12
|
163 error_reporting($e);
|
Chris@0
|
164 }
|
Chris@0
|
165
|
Chris@12
|
166 $this->checkClass($class, $file);
|
Chris@12
|
167 }
|
Chris@0
|
168
|
Chris@12
|
169 private function checkClass($class, $file = null)
|
Chris@12
|
170 {
|
Chris@12
|
171 $exists = null === $file || \class_exists($class, false) || \interface_exists($class, false) || \trait_exists($class, false);
|
Chris@12
|
172
|
Chris@12
|
173 if (null !== $file && $class && '\\' === $class[0]) {
|
Chris@0
|
174 $class = substr($class, 1);
|
Chris@0
|
175 }
|
Chris@0
|
176
|
Chris@0
|
177 if ($exists) {
|
Chris@12
|
178 if (isset(self::$checkedClasses[$class])) {
|
Chris@12
|
179 return;
|
Chris@12
|
180 }
|
Chris@12
|
181 self::$checkedClasses[$class] = true;
|
Chris@12
|
182
|
Chris@0
|
183 $refl = new \ReflectionClass($class);
|
Chris@12
|
184 if (null === $file && $refl->isInternal()) {
|
Chris@12
|
185 return;
|
Chris@12
|
186 }
|
Chris@0
|
187 $name = $refl->getName();
|
Chris@0
|
188
|
Chris@12
|
189 if ($name !== $class && 0 === \strcasecmp($name, $class)) {
|
Chris@12
|
190 throw new \RuntimeException(sprintf('Case mismatch between loaded and declared class names: "%s" vs "%s".', $class, $name));
|
Chris@0
|
191 }
|
Chris@0
|
192
|
Chris@17
|
193 $deprecations = $this->checkAnnotations($refl, $name);
|
Chris@17
|
194
|
Chris@17
|
195 if (isset(self::$php7Reserved[\strtolower($refl->getShortName())])) {
|
Chris@17
|
196 $deprecations[] = sprintf('The "%s" class uses the reserved name "%s", it will break on PHP 7 and higher', $name, $refl->getShortName());
|
Chris@12
|
197 }
|
Chris@12
|
198
|
Chris@17
|
199 foreach ($deprecations as $message) {
|
Chris@17
|
200 @trigger_error($message, E_USER_DEPRECATED);
|
Chris@17
|
201 }
|
Chris@17
|
202 }
|
Chris@17
|
203
|
Chris@17
|
204 if (!$file) {
|
Chris@17
|
205 return;
|
Chris@17
|
206 }
|
Chris@17
|
207
|
Chris@17
|
208 if (!$exists) {
|
Chris@17
|
209 if (false !== strpos($class, '/')) {
|
Chris@17
|
210 throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\" in PHP, not "/".', $class));
|
Chris@17
|
211 }
|
Chris@17
|
212
|
Chris@17
|
213 throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file));
|
Chris@17
|
214 }
|
Chris@17
|
215
|
Chris@17
|
216 if (self::$caseCheck && $message = $this->checkCase($refl, $file, $class)) {
|
Chris@17
|
217 throw new \RuntimeException(sprintf('Case mismatch between class and real file names: "%s" vs "%s" in "%s".', $message[0], $message[1], $message[2]));
|
Chris@17
|
218 }
|
Chris@17
|
219 }
|
Chris@17
|
220
|
Chris@17
|
221 public function checkAnnotations(\ReflectionClass $refl, $class)
|
Chris@17
|
222 {
|
Chris@17
|
223 $deprecations = [];
|
Chris@17
|
224
|
Chris@17
|
225 // Don't trigger deprecations for classes in the same vendor
|
Chris@17
|
226 if (2 > $len = 1 + (\strpos($class, '\\') ?: \strpos($class, '_'))) {
|
Chris@17
|
227 $len = 0;
|
Chris@17
|
228 $ns = '';
|
Chris@17
|
229 } else {
|
Chris@17
|
230 $ns = \str_replace('_', '\\', \substr($class, 0, $len));
|
Chris@17
|
231 }
|
Chris@17
|
232
|
Chris@17
|
233 // Detect annotations on the class
|
Chris@17
|
234 if (false !== $doc = $refl->getDocComment()) {
|
Chris@17
|
235 foreach (['final', 'deprecated', 'internal'] as $annotation) {
|
Chris@18
|
236 if (false !== \strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s', $doc, $notice)) {
|
Chris@17
|
237 self::${$annotation}[$class] = isset($notice[1]) ? preg_replace('#\.?\r?\n( \*)? *(?= |\r?\n|$)#', '', $notice[1]) : '';
|
Chris@17
|
238 }
|
Chris@17
|
239 }
|
Chris@17
|
240 }
|
Chris@17
|
241
|
Chris@17
|
242 $parent = \get_parent_class($class);
|
Chris@17
|
243 $parentAndOwnInterfaces = $this->getOwnInterfaces($class, $parent);
|
Chris@17
|
244 if ($parent) {
|
Chris@17
|
245 $parentAndOwnInterfaces[$parent] = $parent;
|
Chris@17
|
246
|
Chris@17
|
247 if (!isset(self::$checkedClasses[$parent])) {
|
Chris@17
|
248 $this->checkClass($parent);
|
Chris@17
|
249 }
|
Chris@17
|
250
|
Chris@17
|
251 if (isset(self::$final[$parent])) {
|
Chris@17
|
252 $deprecations[] = sprintf('The "%s" class is considered final%s. It may change without further notice as of its next major version. You should not extend it from "%s".', $parent, self::$final[$parent], $class);
|
Chris@17
|
253 }
|
Chris@17
|
254 }
|
Chris@17
|
255
|
Chris@17
|
256 // Detect if the parent is annotated
|
Chris@17
|
257 foreach ($parentAndOwnInterfaces + \class_uses($class, false) as $use) {
|
Chris@17
|
258 if (!isset(self::$checkedClasses[$use])) {
|
Chris@17
|
259 $this->checkClass($use);
|
Chris@17
|
260 }
|
Chris@18
|
261 if (isset(self::$deprecated[$use]) && \strncmp($ns, \str_replace('_', '\\', $use), $len) && !isset(self::$deprecated[$class])) {
|
Chris@17
|
262 $type = class_exists($class, false) ? 'class' : (interface_exists($class, false) ? 'interface' : 'trait');
|
Chris@17
|
263 $verb = class_exists($use, false) || interface_exists($class, false) ? 'extends' : (interface_exists($use, false) ? 'implements' : 'uses');
|
Chris@17
|
264
|
Chris@17
|
265 $deprecations[] = sprintf('The "%s" %s %s "%s" that is deprecated%s.', $class, $type, $verb, $use, self::$deprecated[$use]);
|
Chris@17
|
266 }
|
Chris@17
|
267 if (isset(self::$internal[$use]) && \strncmp($ns, \str_replace('_', '\\', $use), $len)) {
|
Chris@17
|
268 $deprecations[] = sprintf('The "%s" %s is considered internal%s. It may change without further notice. You should not use it from "%s".', $use, class_exists($use, false) ? 'class' : (interface_exists($use, false) ? 'interface' : 'trait'), self::$internal[$use], $class);
|
Chris@17
|
269 }
|
Chris@17
|
270 }
|
Chris@17
|
271
|
Chris@17
|
272 if (\trait_exists($class)) {
|
Chris@17
|
273 return $deprecations;
|
Chris@17
|
274 }
|
Chris@17
|
275
|
Chris@17
|
276 // Inherit @final and @internal annotations for methods
|
Chris@17
|
277 self::$finalMethods[$class] = [];
|
Chris@17
|
278 self::$internalMethods[$class] = [];
|
Chris@17
|
279 foreach ($parentAndOwnInterfaces as $use) {
|
Chris@17
|
280 foreach (['finalMethods', 'internalMethods'] as $property) {
|
Chris@17
|
281 if (isset(self::${$property}[$use])) {
|
Chris@17
|
282 self::${$property}[$class] = self::${$property}[$class] ? self::${$property}[$use] + self::${$property}[$class] : self::${$property}[$use];
|
Chris@17
|
283 }
|
Chris@17
|
284 }
|
Chris@17
|
285 }
|
Chris@17
|
286
|
Chris@17
|
287 foreach ($refl->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED) as $method) {
|
Chris@17
|
288 if ($method->class !== $class) {
|
Chris@17
|
289 continue;
|
Chris@17
|
290 }
|
Chris@17
|
291
|
Chris@17
|
292 if ($parent && isset(self::$finalMethods[$parent][$method->name])) {
|
Chris@17
|
293 list($declaringClass, $message) = self::$finalMethods[$parent][$method->name];
|
Chris@17
|
294 $deprecations[] = sprintf('The "%s::%s()" method is considered final%s. It may change without further notice as of its next major version. You should not extend it from "%s".', $declaringClass, $method->name, $message, $class);
|
Chris@17
|
295 }
|
Chris@17
|
296
|
Chris@17
|
297 if (isset(self::$internalMethods[$class][$method->name])) {
|
Chris@17
|
298 list($declaringClass, $message) = self::$internalMethods[$class][$method->name];
|
Chris@17
|
299 if (\strncmp($ns, $declaringClass, $len)) {
|
Chris@17
|
300 $deprecations[] = sprintf('The "%s::%s()" method is considered internal%s. It may change without further notice. You should not extend it from "%s".', $declaringClass, $method->name, $message, $class);
|
Chris@17
|
301 }
|
Chris@17
|
302 }
|
Chris@17
|
303
|
Chris@17
|
304 // Detect method annotations
|
Chris@17
|
305 if (false === $doc = $method->getDocComment()) {
|
Chris@17
|
306 continue;
|
Chris@17
|
307 }
|
Chris@17
|
308
|
Chris@17
|
309 foreach (['final', 'internal'] as $annotation) {
|
Chris@18
|
310 if (false !== \strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s', $doc, $notice)) {
|
Chris@17
|
311 $message = isset($notice[1]) ? preg_replace('#\.?\r?\n( \*)? *(?= |\r?\n|$)#', '', $notice[1]) : '';
|
Chris@17
|
312 self::${$annotation.'Methods'}[$class][$method->name] = [$class, $message];
|
Chris@17
|
313 }
|
Chris@17
|
314 }
|
Chris@17
|
315 }
|
Chris@17
|
316
|
Chris@17
|
317 return $deprecations;
|
Chris@17
|
318 }
|
Chris@17
|
319
|
Chris@17
|
320 public function checkCase(\ReflectionClass $refl, $file, $class)
|
Chris@17
|
321 {
|
Chris@17
|
322 $real = explode('\\', $class.strrchr($file, '.'));
|
Chris@17
|
323 $tail = explode(\DIRECTORY_SEPARATOR, str_replace('/', \DIRECTORY_SEPARATOR, $file));
|
Chris@17
|
324
|
Chris@17
|
325 $i = \count($tail) - 1;
|
Chris@17
|
326 $j = \count($real) - 1;
|
Chris@17
|
327
|
Chris@17
|
328 while (isset($tail[$i], $real[$j]) && $tail[$i] === $real[$j]) {
|
Chris@17
|
329 --$i;
|
Chris@17
|
330 --$j;
|
Chris@17
|
331 }
|
Chris@17
|
332
|
Chris@17
|
333 array_splice($tail, 0, $i + 1);
|
Chris@17
|
334
|
Chris@17
|
335 if (!$tail) {
|
Chris@17
|
336 return;
|
Chris@17
|
337 }
|
Chris@17
|
338
|
Chris@17
|
339 $tail = \DIRECTORY_SEPARATOR.implode(\DIRECTORY_SEPARATOR, $tail);
|
Chris@17
|
340 $tailLen = \strlen($tail);
|
Chris@17
|
341 $real = $refl->getFileName();
|
Chris@17
|
342
|
Chris@17
|
343 if (2 === self::$caseCheck) {
|
Chris@17
|
344 $real = $this->darwinRealpath($real);
|
Chris@17
|
345 }
|
Chris@17
|
346
|
Chris@17
|
347 if (0 === substr_compare($real, $tail, -$tailLen, $tailLen, true)
|
Chris@17
|
348 && 0 !== substr_compare($real, $tail, -$tailLen, $tailLen, false)
|
Chris@17
|
349 ) {
|
Chris@17
|
350 return [substr($tail, -$tailLen + 1), substr($real, -$tailLen + 1), substr($real, 0, -$tailLen + 1)];
|
Chris@17
|
351 }
|
Chris@17
|
352 }
|
Chris@17
|
353
|
Chris@17
|
354 /**
|
Chris@17
|
355 * `realpath` on MacOSX doesn't normalize the case of characters.
|
Chris@17
|
356 */
|
Chris@17
|
357 private function darwinRealpath($real)
|
Chris@17
|
358 {
|
Chris@17
|
359 $i = 1 + strrpos($real, '/');
|
Chris@17
|
360 $file = substr($real, $i);
|
Chris@17
|
361 $real = substr($real, 0, $i);
|
Chris@17
|
362
|
Chris@17
|
363 if (isset(self::$darwinCache[$real])) {
|
Chris@17
|
364 $kDir = $real;
|
Chris@17
|
365 } else {
|
Chris@17
|
366 $kDir = strtolower($real);
|
Chris@17
|
367
|
Chris@17
|
368 if (isset(self::$darwinCache[$kDir])) {
|
Chris@17
|
369 $real = self::$darwinCache[$kDir][0];
|
Chris@17
|
370 } else {
|
Chris@17
|
371 $dir = getcwd();
|
Chris@17
|
372 chdir($real);
|
Chris@17
|
373 $real = getcwd().'/';
|
Chris@17
|
374 chdir($dir);
|
Chris@17
|
375
|
Chris@17
|
376 $dir = $real;
|
Chris@17
|
377 $k = $kDir;
|
Chris@17
|
378 $i = \strlen($dir) - 1;
|
Chris@17
|
379 while (!isset(self::$darwinCache[$k])) {
|
Chris@17
|
380 self::$darwinCache[$k] = [$dir, []];
|
Chris@17
|
381 self::$darwinCache[$dir] = &self::$darwinCache[$k];
|
Chris@17
|
382
|
Chris@17
|
383 while ('/' !== $dir[--$i]) {
|
Chris@17
|
384 }
|
Chris@17
|
385 $k = substr($k, 0, ++$i);
|
Chris@17
|
386 $dir = substr($dir, 0, $i--);
|
Chris@17
|
387 }
|
Chris@17
|
388 }
|
Chris@17
|
389 }
|
Chris@17
|
390
|
Chris@17
|
391 $dirFiles = self::$darwinCache[$kDir][1];
|
Chris@17
|
392
|
Chris@18
|
393 if (!isset($dirFiles[$file]) && ') : eval()\'d code' === substr($file, -17)) {
|
Chris@18
|
394 // Get the file name from "file_name.php(123) : eval()'d code"
|
Chris@18
|
395 $file = substr($file, 0, strrpos($file, '(', -17));
|
Chris@18
|
396 }
|
Chris@18
|
397
|
Chris@17
|
398 if (isset($dirFiles[$file])) {
|
Chris@17
|
399 return $real .= $dirFiles[$file];
|
Chris@17
|
400 }
|
Chris@17
|
401
|
Chris@17
|
402 $kFile = strtolower($file);
|
Chris@17
|
403
|
Chris@17
|
404 if (!isset($dirFiles[$kFile])) {
|
Chris@17
|
405 foreach (scandir($real, 2) as $f) {
|
Chris@17
|
406 if ('.' !== $f[0]) {
|
Chris@17
|
407 $dirFiles[$f] = $f;
|
Chris@17
|
408 if ($f === $file) {
|
Chris@17
|
409 $kFile = $k = $file;
|
Chris@17
|
410 } elseif ($f !== $k = strtolower($f)) {
|
Chris@17
|
411 $dirFiles[$k] = $f;
|
Chris@0
|
412 }
|
Chris@0
|
413 }
|
Chris@12
|
414 }
|
Chris@17
|
415 self::$darwinCache[$kDir][1] = $dirFiles;
|
Chris@0
|
416 }
|
Chris@0
|
417
|
Chris@17
|
418 return $real .= $dirFiles[$kFile];
|
Chris@0
|
419 }
|
Chris@12
|
420
|
Chris@12
|
421 /**
|
Chris@12
|
422 * `class_implements` includes interfaces from the parents so we have to manually exclude them.
|
Chris@12
|
423 *
|
Chris@12
|
424 * @param string $class
|
Chris@12
|
425 * @param string|false $parent
|
Chris@12
|
426 *
|
Chris@12
|
427 * @return string[]
|
Chris@12
|
428 */
|
Chris@12
|
429 private function getOwnInterfaces($class, $parent)
|
Chris@12
|
430 {
|
Chris@12
|
431 $ownInterfaces = class_implements($class, false);
|
Chris@12
|
432
|
Chris@12
|
433 if ($parent) {
|
Chris@12
|
434 foreach (class_implements($parent, false) as $interface) {
|
Chris@12
|
435 unset($ownInterfaces[$interface]);
|
Chris@12
|
436 }
|
Chris@12
|
437 }
|
Chris@12
|
438
|
Chris@12
|
439 foreach ($ownInterfaces as $interface) {
|
Chris@12
|
440 foreach (class_implements($interface) as $interface) {
|
Chris@12
|
441 unset($ownInterfaces[$interface]);
|
Chris@12
|
442 }
|
Chris@12
|
443 }
|
Chris@12
|
444
|
Chris@12
|
445 return $ownInterfaces;
|
Chris@12
|
446 }
|
Chris@0
|
447 }
|