summaryrefslogtreecommitdiff
path: root/vendor/symfony/debug/DebugClassLoader.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/debug/DebugClassLoader.php')
-rw-r--r--vendor/symfony/debug/DebugClassLoader.php58
1 files changed, 33 insertions, 25 deletions
diff --git a/vendor/symfony/debug/DebugClassLoader.php b/vendor/symfony/debug/DebugClassLoader.php
index 19e80af78f..35f1f55bef 100644
--- a/vendor/symfony/debug/DebugClassLoader.php
+++ b/vendor/symfony/debug/DebugClassLoader.php
@@ -29,16 +29,16 @@ class DebugClassLoader
{
private $classLoader;
private $isFinder;
- private $loaded = array();
+ private $loaded = [];
private static $caseCheck;
- private static $checkedClasses = array();
- private static $final = array();
- private static $finalMethods = array();
- private static $deprecated = array();
- private static $internal = array();
- private static $internalMethods = array();
- private static $annotatedParameters = array();
- private static $darwinCache = array('/' => array('/', array()));
+ private static $checkedClasses = [];
+ private static $final = [];
+ private static $finalMethods = [];
+ private static $deprecated = [];
+ private static $internal = [];
+ private static $internalMethods = [];
+ private static $annotatedParameters = [];
+ private static $darwinCache = ['/' => ['/', []]];
public function __construct(callable $classLoader)
{
@@ -98,7 +98,7 @@ class DebugClassLoader
foreach ($functions as $function) {
if (!\is_array($function) || !$function[0] instanceof self) {
- $function = array(new static($function), 'loadClass');
+ $function = [new static($function), 'loadClass'];
}
spl_autoload_register($function);
@@ -128,6 +128,14 @@ class DebugClassLoader
}
/**
+ * @return string|null
+ */
+ public function findFile($class)
+ {
+ return $this->isFinder ? $this->classLoader[0]->findFile($class) ?: null : null;
+ }
+
+ /**
* Loads the given class or interface.
*
* @param string $class The name of the class
@@ -211,7 +219,7 @@ class DebugClassLoader
public function checkAnnotations(\ReflectionClass $refl, $class)
{
- $deprecations = array();
+ $deprecations = [];
// Don't trigger deprecations for classes in the same vendor
if (2 > $len = 1 + (\strpos($class, '\\') ?: \strpos($class, '_'))) {
@@ -223,9 +231,9 @@ class DebugClassLoader
// Detect annotations on the class
if (false !== $doc = $refl->getDocComment()) {
- foreach (array('final', 'deprecated', 'internal') as $annotation) {
- if (false !== \strpos($doc, $annotation) && preg_match('#\n \* @'.$annotation.'(?:( .+?)\.?)?\r?\n \*(?: @|/$)#s', $doc, $notice)) {
- self::${$annotation}[$class] = isset($notice[1]) ? preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]) : '';
+ foreach (['final', 'deprecated', 'internal'] as $annotation) {
+ if (false !== \strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$)#s', $doc, $notice)) {
+ self::${$annotation}[$class] = isset($notice[1]) ? preg_replace('#\.?\r?\n( \*)? *(?= |\r?\n|$)#', '', $notice[1]) : '';
}
}
}
@@ -265,11 +273,11 @@ class DebugClassLoader
}
// Inherit @final, @internal and @param annotations for methods
- self::$finalMethods[$class] = array();
- self::$internalMethods[$class] = array();
- self::$annotatedParameters[$class] = array();
+ self::$finalMethods[$class] = [];
+ self::$internalMethods[$class] = [];
+ self::$annotatedParameters[$class] = [];
foreach ($parentAndOwnInterfaces as $use) {
- foreach (array('finalMethods', 'internalMethods', 'annotatedParameters') as $property) {
+ foreach (['finalMethods', 'internalMethods', 'annotatedParameters'] as $property) {
if (isset(self::${$property}[$use])) {
self::${$property}[$class] = self::${$property}[$class] ? self::${$property}[$use] + self::${$property}[$class] : self::${$property}[$use];
}
@@ -297,7 +305,7 @@ class DebugClassLoader
$doc = $method->getDocComment();
if (isset(self::$annotatedParameters[$class][$method->name])) {
- $definedParameters = array();
+ $definedParameters = [];
foreach ($method->getParameters() as $parameter) {
$definedParameters[$parameter->name] = true;
}
@@ -315,10 +323,10 @@ class DebugClassLoader
$finalOrInternal = false;
- foreach (array('final', 'internal') as $annotation) {
+ foreach (['final', 'internal'] as $annotation) {
if (false !== \strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$)#s', $doc, $notice)) {
- $message = isset($notice[1]) ? preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]) : '';
- self::${$annotation.'Methods'}[$class][$method->name] = array($class, $message);
+ $message = isset($notice[1]) ? preg_replace('#\.?\r?\n( \*)? *(?= |\r?\n|$)#', '', $notice[1]) : '';
+ self::${$annotation.'Methods'}[$class][$method->name] = [$class, $message];
$finalOrInternal = true;
}
}
@@ -330,7 +338,7 @@ class DebugClassLoader
continue;
}
if (!isset(self::$annotatedParameters[$class][$method->name])) {
- $definedParameters = array();
+ $definedParameters = [];
foreach ($method->getParameters() as $parameter) {
$definedParameters[$parameter->name] = true;
}
@@ -376,7 +384,7 @@ class DebugClassLoader
if (0 === substr_compare($real, $tail, -$tailLen, $tailLen, true)
&& 0 !== substr_compare($real, $tail, -$tailLen, $tailLen, false)
) {
- return array(substr($tail, -$tailLen + 1), substr($real, -$tailLen + 1), substr($real, 0, -$tailLen + 1));
+ return [substr($tail, -$tailLen + 1), substr($real, -$tailLen + 1), substr($real, 0, -$tailLen + 1)];
}
}
@@ -406,7 +414,7 @@ class DebugClassLoader
$k = $kDir;
$i = \strlen($dir) - 1;
while (!isset(self::$darwinCache[$k])) {
- self::$darwinCache[$k] = array($dir, array());
+ self::$darwinCache[$k] = [$dir, []];
self::$darwinCache[$dir] = &self::$darwinCache[$k];
while ('/' !== $dir[--$i]) {