mirror of
https://github.com/symfony/class-loader.git
synced 2026-03-24 09:12:18 +01:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a22265a9f3 | ||
|
|
df12a498a6 | ||
|
|
30ec6eb319 | ||
|
|
4afd812a39 | ||
|
|
17092401a4 | ||
|
|
5e119b7df5 | ||
|
|
04a7e4c1bf | ||
|
|
e4636a4f23 | ||
|
|
bcdf6ff46e | ||
|
|
a016c360a5 |
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\ClassLoader;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\ApcClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use `composer install --apcu-autoloader` instead.', E_USER_DEPRECATED);
|
||||
@trigger_error('The '.__NAMESPACE__.'\ApcClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use `composer install --apcu-autoloader` instead.', \E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* ApcClassLoader implements a wrapping autoloader cached in APC for PHP 5.3.
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace Symfony\Component\ClassLoader;
|
||||
|
||||
if (\PHP_VERSION_ID >= 70000) {
|
||||
@trigger_error('The '.__NAMESPACE__.'\ClassCollectionLoader class is deprecated since Symfony 3.3 and will be removed in 4.0.', E_USER_DEPRECATED);
|
||||
@trigger_error('The '.__NAMESPACE__.'\ClassCollectionLoader class is deprecated since Symfony 3.3 and will be removed in 4.0.', \E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,7 @@ class ClassCollectionLoader
|
||||
|
||||
// cache the core classes
|
||||
if (!is_dir($cacheDir) && !@mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) {
|
||||
throw new \RuntimeException(sprintf('Class Collection Loader was not able to create directory "%s"', $cacheDir));
|
||||
throw new \RuntimeException(sprintf('Class Collection Loader was not able to create directory "%s".', $cacheDir));
|
||||
}
|
||||
$cacheDir = rtrim(realpath($cacheDir) ?: $cacheDir, '/'.\DIRECTORY_SEPARATOR);
|
||||
$cache = $cacheDir.'/'.$name.$extension;
|
||||
@@ -133,7 +133,7 @@ class ClassCollectionLoader
|
||||
// cache the core classes
|
||||
$cacheDir = \dirname($cache);
|
||||
if (!is_dir($cacheDir) && !@mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) {
|
||||
throw new \RuntimeException(sprintf('Class Collection Loader was not able to create directory "%s"', $cacheDir));
|
||||
throw new \RuntimeException(sprintf('Class Collection Loader was not able to create directory "%s".', $cacheDir));
|
||||
}
|
||||
|
||||
$spacesRegex = '(?:\s*+(?:(?:\#|//)[^\n]*+\n|/\*(?:(?<!\*/).)++)?+)*+';
|
||||
@@ -216,21 +216,26 @@ REGEX;
|
||||
$inNamespace = false;
|
||||
$tokens = token_get_all($source);
|
||||
|
||||
$nsTokens = [\T_WHITESPACE => true, \T_NS_SEPARATOR => true, \T_STRING => true];
|
||||
if (\defined('T_NAME_QUALIFIED')) {
|
||||
$nsTokens[T_NAME_QUALIFIED] = true;
|
||||
}
|
||||
|
||||
for ($i = 0; isset($tokens[$i]); ++$i) {
|
||||
$token = $tokens[$i];
|
||||
if (!isset($token[1]) || 'b"' === $token) {
|
||||
$rawChunk .= $token;
|
||||
} elseif (\in_array($token[0], [T_COMMENT, T_DOC_COMMENT])) {
|
||||
} elseif (\in_array($token[0], [\T_COMMENT, \T_DOC_COMMENT])) {
|
||||
// strip comments
|
||||
continue;
|
||||
} elseif (T_NAMESPACE === $token[0]) {
|
||||
} elseif (\T_NAMESPACE === $token[0]) {
|
||||
if ($inNamespace) {
|
||||
$rawChunk .= "}\n";
|
||||
}
|
||||
$rawChunk .= $token[1];
|
||||
|
||||
// namespace name and whitespaces
|
||||
while (isset($tokens[++$i][1]) && \in_array($tokens[$i][0], [T_WHITESPACE, T_NS_SEPARATOR, T_STRING])) {
|
||||
while (isset($tokens[++$i][1], $nsTokens[$tokens[$i][0]])) {
|
||||
$rawChunk .= $tokens[$i][1];
|
||||
}
|
||||
if ('{' === $tokens[$i]) {
|
||||
@@ -240,15 +245,15 @@ REGEX;
|
||||
$rawChunk = rtrim($rawChunk)."\n{";
|
||||
$inNamespace = true;
|
||||
}
|
||||
} elseif (T_START_HEREDOC === $token[0]) {
|
||||
} elseif (\T_START_HEREDOC === $token[0]) {
|
||||
$output .= self::compressCode($rawChunk).$token[1];
|
||||
do {
|
||||
$token = $tokens[++$i];
|
||||
$output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token;
|
||||
} while (T_END_HEREDOC !== $token[0]);
|
||||
} while (\T_END_HEREDOC !== $token[0]);
|
||||
$output .= "\n";
|
||||
$rawChunk = '';
|
||||
} elseif (T_CONSTANT_ENCAPSED_STRING === $token[0]) {
|
||||
} elseif (\T_CONSTANT_ENCAPSED_STRING === $token[0]) {
|
||||
$output .= self::compressCode($rawChunk).$token[1];
|
||||
$rawChunk = '';
|
||||
} else {
|
||||
@@ -336,7 +341,7 @@ REGEX;
|
||||
try {
|
||||
$reflectionClass = new \ReflectionClass($class);
|
||||
} catch (\ReflectionException $e) {
|
||||
throw new \InvalidArgumentException(sprintf('Unable to load class "%s"', $class));
|
||||
throw new \InvalidArgumentException(sprintf('Unable to load class "%s".', $class));
|
||||
}
|
||||
|
||||
$map = array_merge($map, self::getClassHierarchy($reflectionClass));
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\ClassLoader;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\ClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Composer instead.', E_USER_DEPRECATED);
|
||||
@trigger_error('The '.__NAMESPACE__.'\ClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Composer instead.', \E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* ClassLoader implements an PSR-0 class loader.
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\ClassLoader;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\ClassMapGenerator class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Composer instead.', E_USER_DEPRECATED);
|
||||
@trigger_error('The '.__NAMESPACE__.'\ClassMapGenerator class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Composer instead.', \E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* ClassMapGenerator.
|
||||
@@ -62,7 +62,7 @@ class ClassMapGenerator
|
||||
|
||||
$path = $file->getRealPath() ?: $file->getPathname();
|
||||
|
||||
if ('php' !== pathinfo($path, PATHINFO_EXTENSION)) {
|
||||
if ('php' !== pathinfo($path, \PATHINFO_EXTENSION)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -93,6 +93,11 @@ class ClassMapGenerator
|
||||
$contents = file_get_contents($path);
|
||||
$tokens = token_get_all($contents);
|
||||
|
||||
$nsTokens = [\T_STRING => true, \T_NS_SEPARATOR => true];
|
||||
if (\defined('T_NAME_QUALIFIED')) {
|
||||
$nsTokens[T_NAME_QUALIFIED] = true;
|
||||
}
|
||||
|
||||
$classes = [];
|
||||
|
||||
$namespace = '';
|
||||
@@ -106,19 +111,19 @@ class ClassMapGenerator
|
||||
$class = '';
|
||||
|
||||
switch ($token[0]) {
|
||||
case T_NAMESPACE:
|
||||
case \T_NAMESPACE:
|
||||
$namespace = '';
|
||||
// If there is a namespace, extract it
|
||||
while (isset($tokens[++$i][1])) {
|
||||
if (\in_array($tokens[$i][0], [T_STRING, T_NS_SEPARATOR])) {
|
||||
if (isset($nsTokens[$tokens[$i][0]])) {
|
||||
$namespace .= $tokens[$i][1];
|
||||
}
|
||||
}
|
||||
$namespace .= '\\';
|
||||
break;
|
||||
case T_CLASS:
|
||||
case T_INTERFACE:
|
||||
case T_TRAIT:
|
||||
case \T_CLASS:
|
||||
case \T_INTERFACE:
|
||||
case \T_TRAIT:
|
||||
// Skip usage of ::class constant
|
||||
$isClassConstant = false;
|
||||
for ($j = $i - 1; $j > 0; --$j) {
|
||||
@@ -126,10 +131,10 @@ class ClassMapGenerator
|
||||
break;
|
||||
}
|
||||
|
||||
if (T_DOUBLE_COLON === $tokens[$j][0]) {
|
||||
if (\T_DOUBLE_COLON === $tokens[$j][0]) {
|
||||
$isClassConstant = true;
|
||||
break;
|
||||
} elseif (!\in_array($tokens[$j][0], [T_WHITESPACE, T_DOC_COMMENT, T_COMMENT])) {
|
||||
} elseif (!\in_array($tokens[$j][0], [\T_WHITESPACE, \T_DOC_COMMENT, \T_COMMENT])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -141,9 +146,9 @@ class ClassMapGenerator
|
||||
// Find the classname
|
||||
while (isset($tokens[++$i][1])) {
|
||||
$t = $tokens[$i];
|
||||
if (T_STRING === $t[0]) {
|
||||
if (\T_STRING === $t[0]) {
|
||||
$class .= $t[1];
|
||||
} elseif ('' !== $class && T_WHITESPACE === $t[0]) {
|
||||
} elseif ('' !== $class && \T_WHITESPACE === $t[0]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2004-2019 Fabien Potencier
|
||||
Copyright (c) 2004-2020 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\ClassLoader;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\MapClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Composer instead.', E_USER_DEPRECATED);
|
||||
@trigger_error('The '.__NAMESPACE__.'\MapClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Composer instead.', \E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* A class loader that uses a mapping file to look up paths.
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\ClassLoader;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\Psr4ClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Composer instead.', E_USER_DEPRECATED);
|
||||
@trigger_error('The '.__NAMESPACE__.'\Psr4ClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Composer instead.', \E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* A PSR-4 compatible class loader.
|
||||
|
||||
@@ -7,7 +7,7 @@ their locations for performance.
|
||||
Resources
|
||||
---------
|
||||
|
||||
* [Documentation](https://symfony.com/doc/current/components/class_loader/index.html)
|
||||
* [Documentation](https://symfony.com/doc/current/components/class_loader.html)
|
||||
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
|
||||
* [Report issues](https://github.com/symfony/symfony/issues) and
|
||||
[send Pull Requests](https://github.com/symfony/symfony/pulls)
|
||||
|
||||
@@ -22,7 +22,7 @@ class ApcClassLoaderTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
if (!(filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN))) {
|
||||
if (!(filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN))) {
|
||||
$this->markTestSkipped('The apc extension is not enabled.');
|
||||
} else {
|
||||
apcu_clear_cache();
|
||||
@@ -31,7 +31,7 @@ class ApcClassLoaderTest extends TestCase
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
if (filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
|
||||
if (filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) {
|
||||
apcu_clear_cache();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ class ClassLoaderTest extends TestCase
|
||||
$loader->setUseIncludePath(true);
|
||||
$this->assertTrue($loader->getUseIncludePath());
|
||||
|
||||
set_include_path(__DIR__.'/Fixtures/includepath'.PATH_SEPARATOR.$includePath);
|
||||
set_include_path(__DIR__.'/Fixtures/includepath'.\PATH_SEPARATOR.$includePath);
|
||||
|
||||
$this->assertEquals(__DIR__.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'includepath'.\DIRECTORY_SEPARATOR.'Foo.php', $loader->findFile('Foo'));
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\ClassLoader;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\WinCacheClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use `composer install --apcu-autoloader` instead.', E_USER_DEPRECATED);
|
||||
@trigger_error('The '.__NAMESPACE__.'\WinCacheClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use `composer install --apcu-autoloader` instead.', \E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* WinCacheClassLoader implements a wrapping autoloader cached in WinCache.
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\ClassLoader;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\XcacheClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use `composer install --apcu-autoloader` instead.', E_USER_DEPRECATED);
|
||||
@trigger_error('The '.__NAMESPACE__.'\XcacheClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use `composer install --apcu-autoloader` instead.', \E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* XcacheClassLoader implements a wrapping autoloader cached in XCache for PHP 5.3.
|
||||
|
||||
@@ -31,10 +31,5 @@
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.4-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user