mirror of
https://github.com/symfony/class-loader.git
synced 2026-03-24 17:22:11 +01:00
Compare commits
69 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a01933a8d | ||
|
|
d77ac7df59 | ||
|
|
355a6b3ee2 | ||
|
|
ac7c135db5 | ||
|
|
71ff8cc2af | ||
|
|
136d713362 | ||
|
|
72df2d4535 | ||
|
|
a08420fb07 | ||
|
|
6dc4479622 | ||
|
|
6abee87b00 | ||
|
|
f43622ab16 | ||
|
|
7b12dc6915 | ||
|
|
f604d121fa | ||
|
|
c77176c94f | ||
|
|
25d492fa74 | ||
|
|
bd1ffcea9c | ||
|
|
f0a379b040 | ||
|
|
a4e0538494 | ||
|
|
2ae3b6f88a | ||
|
|
480abf8101 | ||
|
|
7c31a493f4 | ||
|
|
89922ecb2b | ||
|
|
00efe62b37 | ||
|
|
4a439e796e | ||
|
|
519ac47b5f | ||
|
|
e0d78d3cfd | ||
|
|
931f370587 | ||
|
|
b9ce73294e | ||
|
|
82f4e6502e | ||
|
|
598dfd4610 | ||
|
|
85b2532f2f | ||
|
|
1ecb64f0c2 | ||
|
|
cc6272033e | ||
|
|
41f582851c | ||
|
|
e722b63c50 | ||
|
|
ad6b79e597 | ||
|
|
b44bb69fd2 | ||
|
|
731d5a42fa | ||
|
|
34e525229a | ||
|
|
d7819f2f17 | ||
|
|
2f8a6f96e2 | ||
|
|
53074e1533 | ||
|
|
35e977baae | ||
|
|
e2a07cb502 | ||
|
|
307598c291 | ||
|
|
8defca3a59 | ||
|
|
47b66544f8 | ||
|
|
a57eb271c2 | ||
|
|
4993c270bb | ||
|
|
0d2d67d18f | ||
|
|
ea9e58e776 | ||
|
|
09a40f5433 | ||
|
|
46754025d0 | ||
|
|
6b87e5db15 | ||
|
|
39a9bc391d | ||
|
|
d3b0938fa2 | ||
|
|
3acea26b17 | ||
|
|
732b31a9fe | ||
|
|
afb83252cb | ||
|
|
b321e4830b | ||
|
|
343414e2a5 | ||
|
|
e971e40b45 | ||
|
|
dd8c297b91 | ||
|
|
26de2f175f | ||
|
|
142de518bf | ||
|
|
8a70d1963f | ||
|
|
18d1b5e575 | ||
|
|
181f15a84f | ||
|
|
0a5217edb6 |
@@ -15,13 +15,21 @@ namespace Symfony\Component\ClassLoader;
|
||||
* ApcClassLoader implements a wrapping autoloader cached in APC for PHP 5.3.
|
||||
*
|
||||
* It expects an object implementing a findFile method to find the file. This
|
||||
* allow using it as a wrapper around the other loaders of the component (the
|
||||
* allows using it as a wrapper around the other loaders of the component (the
|
||||
* ClassLoader and the UniversalClassLoader for instance) but also around any
|
||||
* other autoloader following this convention (the Composer one for instance)
|
||||
* other autoloaders following this convention (the Composer one for instance).
|
||||
*
|
||||
* // with a Symfony autoloader
|
||||
* use Symfony\Component\ClassLoader\ClassLoader;
|
||||
*
|
||||
* $loader = new ClassLoader();
|
||||
* $loader->addPrefix('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->addPrefix('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* // or with a Composer autoloader
|
||||
* use Composer\Autoload\ClassLoader;
|
||||
*
|
||||
* $loader = new ClassLoader();
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
@@ -36,36 +44,31 @@ namespace Symfony\Component\ClassLoader;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class ApcClassLoader
|
||||
{
|
||||
private $prefix;
|
||||
|
||||
/**
|
||||
* The class loader object being decorated.
|
||||
* A class loader object that implements the findFile() method.
|
||||
*
|
||||
* @var \Symfony\Component\ClassLoader\ClassLoader
|
||||
* A class loader object that implements the findFile() method.
|
||||
* @var object
|
||||
*/
|
||||
protected $decorated;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $prefix The APC namespace prefix to use.
|
||||
* @param object $decorated A class loader object that implements the findFile() method.
|
||||
* @param string $prefix The APC namespace prefix to use.
|
||||
* @param object $decorated A class loader object that implements the findFile() method.
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function __construct($prefix, $decorated)
|
||||
{
|
||||
if (!extension_loaded('apc')) {
|
||||
throw new \RuntimeException('Unable to use ApcClassLoader as APC is not enabled.');
|
||||
if (!function_exists('apcu_fetch')) {
|
||||
throw new \RuntimeException('Unable to use ApcClassLoader as APC is not installed.');
|
||||
}
|
||||
|
||||
if (!method_exists($decorated, 'findFile')) {
|
||||
@@ -79,7 +82,7 @@ class ApcClassLoader
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param Boolean $prepend Whether to prepend the autoloader or not
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
@@ -99,7 +102,7 @@ class ApcClassLoader
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return Boolean|null True, if loaded
|
||||
* @return bool|null True, if loaded
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
@@ -119,8 +122,10 @@ class ApcClassLoader
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
if (false === $file = apc_fetch($this->prefix.$class)) {
|
||||
apc_store($this->prefix.$class, $file = $this->decorated->findFile($class));
|
||||
$file = apcu_fetch($this->prefix.$class, $success);
|
||||
|
||||
if (!$success) {
|
||||
apcu_store($this->prefix.$class, $file = $this->decorated->findFile($class) ?: null);
|
||||
}
|
||||
|
||||
return $file;
|
||||
@@ -133,5 +138,4 @@ class ApcClassLoader
|
||||
{
|
||||
return call_user_func_array(array($this->decorated, $method), $args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ namespace Symfony\Component\ClassLoader;
|
||||
* // register classes with namespaces
|
||||
* $loader->registerNamespaces(array(
|
||||
* 'Symfony\Component' => __DIR__.'/component',
|
||||
* 'Symfony' => __DIR__.'/framework',
|
||||
* 'Sensio' => array(__DIR__.'/src', __DIR__.'/vendor'),
|
||||
* 'Symfony' => __DIR__.'/framework',
|
||||
* 'Sensio' => array(__DIR__.'/src', __DIR__.'/vendor'),
|
||||
* ));
|
||||
*
|
||||
* // register a library using the PEAR naming convention
|
||||
@@ -57,8 +57,6 @@ namespace Symfony\Component\ClassLoader;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class ApcUniversalClassLoader extends UniversalClassLoader
|
||||
{
|
||||
@@ -70,12 +68,10 @@ class ApcUniversalClassLoader extends UniversalClassLoader
|
||||
* @param string $prefix A prefix to create a namespace in APC
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function __construct($prefix)
|
||||
{
|
||||
if (!extension_loaded('apc')) {
|
||||
if (!function_exists('apcu_fetch')) {
|
||||
throw new \RuntimeException('Unable to use ApcUniversalClassLoader as APC is not enabled.');
|
||||
}
|
||||
|
||||
@@ -91,8 +87,10 @@ class ApcUniversalClassLoader extends UniversalClassLoader
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
if (false === $file = apc_fetch($this->prefix.$class)) {
|
||||
apc_store($this->prefix.$class, $file = parent::findFile($class));
|
||||
$file = apcu_fetch($this->prefix.$class, $success);
|
||||
|
||||
if (!$success) {
|
||||
apcu_store($this->prefix.$class, $file = parent::findFile($class) ?: null);
|
||||
}
|
||||
|
||||
return $file;
|
||||
|
||||
@@ -25,12 +25,12 @@ class ClassCollectionLoader
|
||||
/**
|
||||
* Loads a list of classes and caches them in one big file.
|
||||
*
|
||||
* @param array $classes An array of classes to load
|
||||
* @param string $cacheDir A cache directory
|
||||
* @param string $name The cache name prefix
|
||||
* @param Boolean $autoReload Whether to flush the cache when the cache is stale or not
|
||||
* @param Boolean $adaptive Whether to remove already declared classes or not
|
||||
* @param string $extension File extension of the resulting file
|
||||
* @param array $classes An array of classes to load
|
||||
* @param string $cacheDir A cache directory
|
||||
* @param string $name The cache name prefix
|
||||
* @param bool $autoReload Whether to flush the cache when the cache is stale or not
|
||||
* @param bool $adaptive Whether to remove already declared classes or not
|
||||
* @param string $extension File extension of the resulting file
|
||||
*
|
||||
* @throws \InvalidArgumentException When class can't be loaded
|
||||
*/
|
||||
@@ -116,8 +116,8 @@ class ClassCollectionLoader
|
||||
}
|
||||
|
||||
// cache the core classes
|
||||
if (!is_dir(dirname($cache))) {
|
||||
mkdir(dirname($cache), 0777, true);
|
||||
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));
|
||||
}
|
||||
self::writeCacheFile($cache, '<?php '.$content);
|
||||
|
||||
@@ -137,8 +137,8 @@ class ClassCollectionLoader
|
||||
public static function fixNamespaceDeclarations($source)
|
||||
{
|
||||
if (!function_exists('token_get_all') || !self::$useTokenizer) {
|
||||
if (preg_match('/namespace(.*?)\s*;/', $source)) {
|
||||
$source = preg_replace('/namespace(.*?)\s*;/', "namespace$1\n{", $source)."}\n";
|
||||
if (preg_match('/(^|\s)namespace(.*?)\s*;/', $source)) {
|
||||
$source = preg_replace('/(^|\s)namespace(.*?)\s*;/', "$1namespace$2\n{", $source)."}\n";
|
||||
}
|
||||
|
||||
return $source;
|
||||
@@ -149,8 +149,9 @@ class ClassCollectionLoader
|
||||
$inNamespace = false;
|
||||
$tokens = token_get_all($source);
|
||||
|
||||
for (reset($tokens); false !== $token = current($tokens); next($tokens)) {
|
||||
if (is_string($token)) {
|
||||
for ($i = 0; isset($tokens[$i]); ++$i) {
|
||||
$token = $tokens[$i];
|
||||
if (!isset($token[1]) || 'b"' === $token) {
|
||||
$rawChunk .= $token;
|
||||
} elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {
|
||||
// strip comments
|
||||
@@ -162,12 +163,12 @@ class ClassCollectionLoader
|
||||
$rawChunk .= $token[1];
|
||||
|
||||
// namespace name and whitespaces
|
||||
while (($t = next($tokens)) && is_array($t) && in_array($t[0], array(T_WHITESPACE, T_NS_SEPARATOR, T_STRING))) {
|
||||
$rawChunk .= $t[1];
|
||||
while (isset($tokens[++$i][1]) && in_array($tokens[$i][0], array(T_WHITESPACE, T_NS_SEPARATOR, T_STRING))) {
|
||||
$rawChunk .= $tokens[$i][1];
|
||||
}
|
||||
if ('{' === $t) {
|
||||
if ('{' === $tokens[$i]) {
|
||||
$inNamespace = false;
|
||||
prev($tokens);
|
||||
--$i;
|
||||
} else {
|
||||
$rawChunk = rtrim($rawChunk)."\n{";
|
||||
$inNamespace = true;
|
||||
@@ -175,8 +176,8 @@ class ClassCollectionLoader
|
||||
} elseif (T_START_HEREDOC === $token[0]) {
|
||||
$output .= self::compressCode($rawChunk).$token[1];
|
||||
do {
|
||||
$token = next($tokens);
|
||||
$output .= is_string($token) ? $token : $token[1];
|
||||
$token = $tokens[++$i];
|
||||
$output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token;
|
||||
} while ($token[0] !== T_END_HEREDOC);
|
||||
$output .= "\n";
|
||||
$rawChunk = '';
|
||||
@@ -192,7 +193,15 @@ class ClassCollectionLoader
|
||||
$rawChunk .= "}\n";
|
||||
}
|
||||
|
||||
return $output.self::compressCode($rawChunk);
|
||||
$output .= self::compressCode($rawChunk);
|
||||
|
||||
if (PHP_VERSION_ID >= 70000) {
|
||||
// PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098
|
||||
unset($tokens, $rawChunk);
|
||||
gc_mem_caches();
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,7 +209,7 @@ class ClassCollectionLoader
|
||||
*/
|
||||
public static function enableTokenizer($bool)
|
||||
{
|
||||
self::$useTokenizer = (Boolean) $bool;
|
||||
self::$useTokenizer = (bool) $bool;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,7 +292,7 @@ class ClassCollectionLoader
|
||||
|
||||
$traits = array();
|
||||
|
||||
if (function_exists('get_declared_traits')) {
|
||||
if (method_exists('ReflectionClass', 'getTraits')) {
|
||||
foreach ($classes as $c) {
|
||||
foreach (self::resolveDependencies(self::computeTraitDeps($c), $c) as $trait) {
|
||||
if ($trait !== $c) {
|
||||
@@ -335,10 +344,10 @@ class ClassCollectionLoader
|
||||
* This function does not check for circular dependencies as it should never
|
||||
* occur with PHP traits.
|
||||
*
|
||||
* @param array $tree The dependency tree
|
||||
* @param \ReflectionClass $node The node
|
||||
* @param \ArrayObject $resolved An array of already resolved dependencies
|
||||
* @param \ArrayObject $unresolved An array of dependencies to be resolved
|
||||
* @param array $tree The dependency tree
|
||||
* @param \ReflectionClass $node The node
|
||||
* @param \ArrayObject $resolved An array of already resolved dependencies
|
||||
* @param \ArrayObject $unresolved An array of dependencies to be resolved
|
||||
*
|
||||
* @return \ArrayObject The dependencies for the given node
|
||||
*
|
||||
@@ -353,14 +362,17 @@ class ClassCollectionLoader
|
||||
$unresolved = new \ArrayObject();
|
||||
}
|
||||
$nodeName = $node->getName();
|
||||
$unresolved[$nodeName] = $node;
|
||||
foreach ($tree[$nodeName] as $dependency) {
|
||||
if (!$resolved->offsetExists($dependency->getName())) {
|
||||
self::resolveDependencies($tree, $dependency, $resolved, $unresolved);
|
||||
|
||||
if (isset($tree[$nodeName])) {
|
||||
$unresolved[$nodeName] = $node;
|
||||
foreach ($tree[$nodeName] as $dependency) {
|
||||
if (!$resolved->offsetExists($dependency->getName())) {
|
||||
self::resolveDependencies($tree, $dependency, $resolved, $unresolved);
|
||||
}
|
||||
}
|
||||
$resolved[$nodeName] = $node;
|
||||
unset($unresolved[$nodeName]);
|
||||
}
|
||||
$resolved[$nodeName] = $node;
|
||||
unset($unresolved[$nodeName]);
|
||||
|
||||
return $resolved;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace Symfony\Component\ClassLoader;
|
||||
|
||||
/**
|
||||
* ClassLoader implements an PSR-0 class loader
|
||||
* ClassLoader implements an PSR-0 class loader.
|
||||
*
|
||||
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
|
||||
*
|
||||
@@ -76,7 +76,7 @@ class ClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of classes
|
||||
* Registers a set of classes.
|
||||
*
|
||||
* @param string $prefix The classes prefix
|
||||
* @param array|string $paths The location(s) of the classes
|
||||
@@ -91,30 +91,34 @@ class ClassLoader
|
||||
return;
|
||||
}
|
||||
if (isset($this->prefixes[$prefix])) {
|
||||
$this->prefixes[$prefix] = array_merge(
|
||||
$this->prefixes[$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
if (is_array($paths)) {
|
||||
$this->prefixes[$prefix] = array_unique(array_merge(
|
||||
$this->prefixes[$prefix],
|
||||
$paths
|
||||
));
|
||||
} elseif (!in_array($paths, $this->prefixes[$prefix])) {
|
||||
$this->prefixes[$prefix][] = $paths;
|
||||
}
|
||||
} else {
|
||||
$this->prefixes[$prefix] = (array) $paths;
|
||||
$this->prefixes[$prefix] = array_unique((array) $paths);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on searching the include for class files.
|
||||
*
|
||||
* @param Boolean $useIncludePath
|
||||
* @param bool $useIncludePath
|
||||
*/
|
||||
public function setUseIncludePath($useIncludePath)
|
||||
{
|
||||
$this->useIncludePath = $useIncludePath;
|
||||
$this->useIncludePath = (bool) $useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to check if the autoloader uses the include path to check
|
||||
* for classes.
|
||||
*
|
||||
* @return Boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getUseIncludePath()
|
||||
{
|
||||
@@ -124,7 +128,7 @@ class ClassLoader
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param Boolean $prepend Whether to prepend the autoloader or not
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
@@ -144,7 +148,7 @@ class ClassLoader
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return Boolean|null True, if loaded
|
||||
* @return bool|null True, if loaded
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
|
||||
@@ -11,15 +11,23 @@
|
||||
|
||||
namespace Symfony\Component\ClassLoader;
|
||||
|
||||
if (!defined('SYMFONY_TRAIT')) {
|
||||
if (PHP_VERSION_ID >= 50400) {
|
||||
define('SYMFONY_TRAIT', T_TRAIT);
|
||||
} else {
|
||||
define('SYMFONY_TRAIT', 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ClassMapGenerator
|
||||
* ClassMapGenerator.
|
||||
*
|
||||
* @author Gyula Sallai <salla016@gmail.com>
|
||||
*/
|
||||
class ClassMapGenerator
|
||||
{
|
||||
/**
|
||||
* Generate a class map file
|
||||
* Generate a class map file.
|
||||
*
|
||||
* @param array|string $dirs Directories or a single path to search in
|
||||
* @param string $file The name of the class map file
|
||||
@@ -37,7 +45,7 @@ class ClassMapGenerator
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate over all files in the given directory searching for classes
|
||||
* Iterate over all files in the given directory searching for classes.
|
||||
*
|
||||
* @param \Iterator|string $dir The directory to search in or an iterator
|
||||
*
|
||||
@@ -64,17 +72,21 @@ class ClassMapGenerator
|
||||
|
||||
$classes = self::findClasses($path);
|
||||
|
||||
if (PHP_VERSION_ID >= 70000) {
|
||||
// PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098
|
||||
gc_mem_caches();
|
||||
}
|
||||
|
||||
foreach ($classes as $class) {
|
||||
$map[$class] = $path;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the classes in the given file
|
||||
* Extract the classes in the given file.
|
||||
*
|
||||
* @param string $path The file to check
|
||||
*
|
||||
@@ -83,16 +95,15 @@ class ClassMapGenerator
|
||||
private static function findClasses($path)
|
||||
{
|
||||
$contents = file_get_contents($path);
|
||||
$tokens = token_get_all($contents);
|
||||
$T_TRAIT = version_compare(PHP_VERSION, '5.4', '<') ? -1 : T_TRAIT;
|
||||
$tokens = token_get_all($contents);
|
||||
|
||||
$classes = array();
|
||||
|
||||
$namespace = '';
|
||||
for ($i = 0, $max = count($tokens); $i < $max; $i++) {
|
||||
for ($i = 0; isset($tokens[$i]); ++$i) {
|
||||
$token = $tokens[$i];
|
||||
|
||||
if (is_string($token)) {
|
||||
if (!isset($token[1])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -102,21 +113,41 @@ class ClassMapGenerator
|
||||
case T_NAMESPACE:
|
||||
$namespace = '';
|
||||
// If there is a namespace, extract it
|
||||
while (($t = $tokens[++$i]) && is_array($t)) {
|
||||
if (in_array($t[0], array(T_STRING, T_NS_SEPARATOR))) {
|
||||
$namespace .= $t[1];
|
||||
while (isset($tokens[++$i][1])) {
|
||||
if (in_array($tokens[$i][0], array(T_STRING, T_NS_SEPARATOR))) {
|
||||
$namespace .= $tokens[$i][1];
|
||||
}
|
||||
}
|
||||
$namespace .= '\\';
|
||||
break;
|
||||
case T_CLASS:
|
||||
case T_INTERFACE:
|
||||
case $T_TRAIT:
|
||||
case SYMFONY_TRAIT:
|
||||
// Skip usage of ::class constant
|
||||
$isClassConstant = false;
|
||||
for ($j = $i - 1; $j > 0; --$j) {
|
||||
if (!isset($tokens[$j][1])) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (T_DOUBLE_COLON === $tokens[$j][0]) {
|
||||
$isClassConstant = true;
|
||||
break;
|
||||
} elseif (!in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($isClassConstant) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Find the classname
|
||||
while (($t = $tokens[++$i]) && is_array($t)) {
|
||||
while (isset($tokens[++$i][1])) {
|
||||
$t = $tokens[$i];
|
||||
if (T_STRING === $t[0]) {
|
||||
$class .= $t[1];
|
||||
} elseif ($class !== '' && T_WHITESPACE == $t[0]) {
|
||||
} elseif ('' !== $class && T_WHITESPACE === $t[0]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,6 @@ namespace Symfony\Component\ClassLoader;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Christophe Coevoet <stof@notk.org>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class DebugClassLoader
|
||||
{
|
||||
@@ -31,8 +29,6 @@ class DebugClassLoader
|
||||
* Constructor.
|
||||
*
|
||||
* @param object $classFinder
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function __construct($classFinder)
|
||||
{
|
||||
@@ -70,7 +66,7 @@ class DebugClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a file by class name
|
||||
* Finds a file by class name.
|
||||
*
|
||||
* @param string $class A class name to resolve to file
|
||||
*
|
||||
@@ -78,7 +74,7 @@ class DebugClassLoader
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
return $this->classFinder->findFile($class);
|
||||
return $this->classFinder->findFile($class) ?: null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +82,7 @@ class DebugClassLoader
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return Boolean|null True, if loaded
|
||||
* @return bool|null True, if loaded
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
|
||||
@@ -48,7 +48,7 @@ class DebugUniversalClassLoader extends UniversalClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2004-2013 Fabien Potencier
|
||||
Copyright (c) 2004-2016 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
|
||||
|
||||
@@ -33,7 +33,7 @@ class MapClassLoader
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param Boolean $prepend Whether to prepend the autoloader or not
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
|
||||
69
README.md
69
README.md
@@ -1,69 +1,14 @@
|
||||
ClassLoader Component
|
||||
=====================
|
||||
|
||||
ClassLoader loads your project classes automatically if they follow some
|
||||
standard PHP conventions.
|
||||
|
||||
The Universal ClassLoader is able to autoload classes that implement the PSR-0
|
||||
standard or the PEAR naming convention.
|
||||
|
||||
First, register the autoloader:
|
||||
|
||||
require_once __DIR__.'/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
|
||||
|
||||
use Symfony\Component\ClassLoader\UniversalClassLoader;
|
||||
|
||||
$loader = new UniversalClassLoader();
|
||||
$loader->register();
|
||||
|
||||
Then, register some namespaces with the `registerNamespace()` method:
|
||||
|
||||
$loader->registerNamespace('Symfony', __DIR__.'/src');
|
||||
$loader->registerNamespace('Monolog', __DIR__.'/vendor/monolog/src');
|
||||
|
||||
The `registerNamespace()` method takes a namespace prefix and a path where to
|
||||
look for the classes as arguments.
|
||||
|
||||
You can also register a sub-namespaces:
|
||||
|
||||
$loader->registerNamespace('Doctrine\\Common', __DIR__.'/vendor/doctrine-common/lib');
|
||||
|
||||
The order of registration is significant and the first registered namespace
|
||||
takes precedence over later registered one.
|
||||
|
||||
You can also register more than one path for a given namespace:
|
||||
|
||||
$loader->registerNamespace('Symfony', array(__DIR__.'/src', __DIR__.'/symfony/src'));
|
||||
|
||||
Alternatively, you can use the `registerNamespaces()` method to register more
|
||||
than one namespace at once:
|
||||
|
||||
$loader->registerNamespaces(array(
|
||||
'Symfony' => array(__DIR__.'/src', __DIR__.'/symfony/src'),
|
||||
'Doctrine\\Common' => __DIR__.'/vendor/doctrine-common/lib',
|
||||
'Doctrine' => __DIR__.'/vendor/doctrine/lib',
|
||||
'Monolog' => __DIR__.'/vendor/monolog/src',
|
||||
));
|
||||
|
||||
For better performance, you can use the APC based version of the universal
|
||||
class loader:
|
||||
|
||||
require_once __DIR__.'/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
|
||||
require_once __DIR__.'/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php';
|
||||
|
||||
use Symfony\Component\ClassLoader\ApcUniversalClassLoader;
|
||||
|
||||
$loader = new ApcUniversalClassLoader('apc.prefix.');
|
||||
|
||||
Furthermore, the component provides tools to aggregate classes into a single
|
||||
file, which is especially useful to improve performance on servers that do not
|
||||
provide byte caches.
|
||||
The ClassLoader component provides tools to autoload your classes and cache
|
||||
their locations for performance.
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
You can run the unit tests with the following command:
|
||||
|
||||
$ cd path/to/Symfony/Component/ClassLoader/
|
||||
$ composer.phar install
|
||||
$ phpunit
|
||||
* [Documentation](https://symfony.com/doc/current/components/class_loader/index.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)
|
||||
in the [main Symfony repository](https://github.com/symfony/symfony)
|
||||
|
||||
@@ -17,21 +17,17 @@ class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
if (!extension_loaded('apc')) {
|
||||
$this->markTestSkipped('The apc extension is not available.');
|
||||
}
|
||||
|
||||
if (!(ini_get('apc.enabled') && ini_get('apc.enable_cli'))) {
|
||||
$this->markTestSkipped('The apc extension is available, but not enabled.');
|
||||
if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) {
|
||||
apcu_clear_cache();
|
||||
} else {
|
||||
apc_clear_cache('user');
|
||||
$this->markTestSkipped('APC is not enabled.');
|
||||
}
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) {
|
||||
apc_clear_cache('user');
|
||||
apcu_clear_cache();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +36,7 @@ class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$loader = new ApcUniversalClassLoader('test.prefix.');
|
||||
$loader->registerNamespace('Apc\Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
|
||||
$this->assertEquals($loader->findFile('\Apc\Namespaced\FooBar'), apc_fetch('test.prefix.\Apc\Namespaced\FooBar'), '__construct() takes a prefix as its first argument');
|
||||
$this->assertEquals($loader->findFile('\Apc\Namespaced\FooBar'), apcu_fetch('test.prefix.\Apc\Namespaced\FooBar'), '__construct() takes a prefix as its first argument');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,15 +51,13 @@ class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue(class_exists($className), $message);
|
||||
}
|
||||
|
||||
public function getLoadClassTests()
|
||||
{
|
||||
return array(
|
||||
array('\\Apc\\Namespaced\\Foo', '\\Apc\\Namespaced\\Foo', '->loadClass() loads Apc\Namespaced\Foo class'),
|
||||
public function getLoadClassTests()
|
||||
{
|
||||
return array(
|
||||
array('\\Apc\\Namespaced\\Foo', 'Apc\\Namespaced\\Foo', '->loadClass() loads Apc\Namespaced\Foo class'),
|
||||
array('Apc_Pearlike_Foo', 'Apc_Pearlike_Foo', '->loadClass() loads Apc_Pearlike_Foo class'),
|
||||
array('\\Apc\\Namespaced\\Bar', '\\Apc\\Namespaced\\Bar', '->loadClass() loads Apc\Namespaced\Bar class with a leading slash'),
|
||||
array('Apc_Pearlike_Bar', '\\Apc_Pearlike_Bar', '->loadClass() loads Apc_Pearlike_Bar class with a leading slash'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLoadClassFromFallbackTests
|
||||
@@ -79,15 +73,15 @@ class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue(class_exists($className), $message);
|
||||
}
|
||||
|
||||
public function getLoadClassFromFallbackTests()
|
||||
{
|
||||
return array(
|
||||
array('\\Apc\\Namespaced\\Baz', '\\Apc\\Namespaced\\Baz', '->loadClass() loads Apc\Namespaced\Baz class'),
|
||||
public function getLoadClassFromFallbackTests()
|
||||
{
|
||||
return array(
|
||||
array('\\Apc\\Namespaced\\Baz', 'Apc\\Namespaced\\Baz', '->loadClass() loads Apc\Namespaced\Baz class'),
|
||||
array('Apc_Pearlike_Baz', 'Apc_Pearlike_Baz', '->loadClass() loads Apc_Pearlike_Baz class'),
|
||||
array('\\Apc\\Namespaced\\FooBar', '\\Apc\\Namespaced\\FooBar', '->loadClass() loads Apc\Namespaced\Baz class from fallback dir'),
|
||||
array('\\Apc\\Namespaced\\FooBar', 'Apc\\Namespaced\\FooBar', '->loadClass() loads Apc\Namespaced\Baz class from fallback dir'),
|
||||
array('Apc_Pearlike_FooBar', 'Apc_Pearlike_FooBar', '->loadClass() loads Apc_Pearlike_Baz class from fallback dir'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLoadClassNamespaceCollisionTests
|
||||
@@ -102,15 +96,15 @@ class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue(class_exists($className), $message);
|
||||
}
|
||||
|
||||
public function getLoadClassNamespaceCollisionTests()
|
||||
{
|
||||
return array(
|
||||
public function getLoadClassNamespaceCollisionTests()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha',
|
||||
'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta',
|
||||
),
|
||||
'\Apc\NamespaceCollision\A\Foo',
|
||||
'Apc\NamespaceCollision\A\Foo',
|
||||
'->loadClass() loads NamespaceCollision\A\Foo from alpha.',
|
||||
),
|
||||
array(
|
||||
@@ -118,7 +112,7 @@ class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta',
|
||||
'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha',
|
||||
),
|
||||
'\Apc\NamespaceCollision\A\Bar',
|
||||
'Apc\NamespaceCollision\A\Bar',
|
||||
'->loadClass() loads NamespaceCollision\A\Bar from alpha.',
|
||||
),
|
||||
array(
|
||||
@@ -126,7 +120,7 @@ class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha',
|
||||
'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta',
|
||||
),
|
||||
'\Apc\NamespaceCollision\A\B\Foo',
|
||||
'Apc\NamespaceCollision\A\B\Foo',
|
||||
'->loadClass() loads NamespaceCollision\A\B\Foo from beta.',
|
||||
),
|
||||
array(
|
||||
@@ -134,11 +128,11 @@ class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta',
|
||||
'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha',
|
||||
),
|
||||
'\Apc\NamespaceCollision\A\B\Bar',
|
||||
'Apc\NamespaceCollision\A\B\Bar',
|
||||
'->loadClass() loads NamespaceCollision\A\B\Bar from beta.',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLoadClassPrefixCollisionTests
|
||||
@@ -152,9 +146,9 @@ class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue(class_exists($className), $message);
|
||||
}
|
||||
|
||||
public function getLoadClassPrefixCollisionTests()
|
||||
{
|
||||
return array(
|
||||
public function getLoadClassPrefixCollisionTests()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
'ApcPrefixCollision_A_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc',
|
||||
@@ -188,5 +182,5 @@ class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
'->loadClass() loads ApcPrefixCollision_A_B_Bar from beta.',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,14 +20,11 @@ require_once __DIR__.'/Fixtures/ClassesWithParents/A.php';
|
||||
|
||||
class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @requires PHP 5.4
|
||||
*/
|
||||
public function testTraitDependencies()
|
||||
{
|
||||
if (version_compare(phpversion(), '5.4', '<')) {
|
||||
$this->markTestSkipped('Requires PHP > 5.4');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
require_once __DIR__.'/Fixtures/deps/traits.php';
|
||||
|
||||
$r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader');
|
||||
@@ -97,15 +94,10 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider getDifferentOrdersForTraits
|
||||
* @requires PHP 5.4
|
||||
*/
|
||||
public function testClassWithTraitsReordering(array $classes)
|
||||
{
|
||||
if (version_compare(phpversion(), '5.4', '<')) {
|
||||
$this->markTestSkipped('Requires PHP > 5.4');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/ATrait.php';
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/BTrait.php';
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/CTrait.php';
|
||||
@@ -146,6 +138,35 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 5.4
|
||||
*/
|
||||
public function testFixClassWithTraitsOrdering()
|
||||
{
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/CTrait.php';
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/F.php';
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/G.php';
|
||||
|
||||
$classes = array(
|
||||
'ClassesWithParents\\F',
|
||||
'ClassesWithParents\\G',
|
||||
);
|
||||
|
||||
$expected = array(
|
||||
'ClassesWithParents\\CTrait',
|
||||
'ClassesWithParents\\F',
|
||||
'ClassesWithParents\\G',
|
||||
);
|
||||
|
||||
$r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader');
|
||||
$m = $r->getMethod('getOrderedClasses');
|
||||
$m->setAccessible(true);
|
||||
|
||||
$ordered = $m->invoke('Symfony\Component\ClassLoader\ClassCollectionLoader', $classes);
|
||||
|
||||
$this->assertEquals($expected, array_map(function ($class) { return $class->getName(); }, $ordered));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getFixNamespaceDeclarationsData
|
||||
*/
|
||||
@@ -184,12 +205,12 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
array("namespace Bar ;\nclass Foo {}\n", "namespace Bar\n{\nclass Foo {}\n}\n"),
|
||||
array("namespace Foo\Bar;\nclass Foo {}\n", "namespace Foo\Bar\n{\nclass Foo {}\n}\n"),
|
||||
array("namespace Foo\Bar\Bar\n{\nclass Foo {}\n}\n", "namespace Foo\Bar\Bar\n{\nclass Foo {}\n}\n"),
|
||||
array("namespace\n{\nclass Foo {}\n}\n", "namespace\n{\nclass Foo {}\n}\n"),
|
||||
array("\nnamespace\n{\nclass Foo {}\n\$namespace=123;}\n", "\nnamespace\n{\nclass Foo {}\n\$namespace=123;}\n"),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testUnableToLoadClassException()
|
||||
{
|
||||
@@ -220,26 +241,26 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
spl_autoload_unregister($r);
|
||||
|
||||
$this->assertEquals(<<<EOF
|
||||
$this->assertEquals(<<<'EOF'
|
||||
namespace Namespaced
|
||||
{
|
||||
class WithComments
|
||||
{
|
||||
public static \$loaded = true;
|
||||
public static $loaded = true;
|
||||
}
|
||||
\$string ='string shoult not be modified {\$string}';
|
||||
\$heredoc = (<<<HD
|
||||
$string ='string should not be modified {$string}';
|
||||
$heredoc = (<<<HD
|
||||
|
||||
|
||||
Heredoc should not be modified {\$string}
|
||||
Heredoc should not be modified {$string}
|
||||
|
||||
|
||||
HD
|
||||
);
|
||||
\$nowdoc =<<<'ND'
|
||||
$nowdoc =<<<'ND'
|
||||
|
||||
|
||||
Nowdoc should not be modified {\$string}
|
||||
Nowdoc should not be modified {$string}
|
||||
|
||||
|
||||
ND
|
||||
@@ -249,7 +270,7 @@ namespace
|
||||
{
|
||||
class Pearlike_WithComments
|
||||
{
|
||||
public static \$loaded = true;
|
||||
public static $loaded = true;
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
@@ -76,14 +76,36 @@ class ClassLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testAddPrefix()
|
||||
public function testAddPrefixSingle()
|
||||
{
|
||||
$loader = new ClassLoader();
|
||||
$loader->addPrefix('Foo', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$loader->addPrefix('Foo', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$prefixes = $loader->getPrefixes();
|
||||
$this->assertArrayHasKey('Foo', $prefixes);
|
||||
$this->assertCount(1, $prefixes['Foo']);
|
||||
}
|
||||
|
||||
public function testAddPrefixesSingle()
|
||||
{
|
||||
$loader = new ClassLoader();
|
||||
$loader->addPrefixes(array('Foo' => array('foo', 'foo')));
|
||||
$loader->addPrefixes(array('Foo' => array('foo')));
|
||||
$prefixes = $loader->getPrefixes();
|
||||
$this->assertArrayHasKey('Foo', $prefixes);
|
||||
$this->assertCount(1, $prefixes['Foo'], print_r($prefixes, true));
|
||||
}
|
||||
|
||||
public function testAddPrefixMulti()
|
||||
{
|
||||
$loader = new ClassLoader();
|
||||
$loader->addPrefix('Foo', 'foo');
|
||||
$loader->addPrefix('Foo', 'bar');
|
||||
$prefixes = $loader->getPrefixes();
|
||||
$this->assertArrayHasKey('Foo', $prefixes);
|
||||
$this->assertCount(2, $prefixes['Foo']);
|
||||
$this->assertContains('foo', $prefixes['Foo']);
|
||||
$this->assertContains('bar', $prefixes['Foo']);
|
||||
}
|
||||
|
||||
public function testUseIncludePath()
|
||||
|
||||
@@ -16,13 +16,13 @@ use Symfony\Component\ClassLoader\ClassMapGenerator;
|
||||
class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var string $workspace
|
||||
* @var string|null
|
||||
*/
|
||||
private $workspace = null;
|
||||
|
||||
public function prepare_workspace()
|
||||
{
|
||||
$this->workspace = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.time().rand(0, 1000);
|
||||
$this->workspace = sys_get_temp_dir().'/'.microtime(true).'.'.mt_rand();
|
||||
mkdir($this->workspace, 0777, true);
|
||||
$this->workspace = realpath($this->workspace);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* @dataProvider getTestCreateMapTests
|
||||
*/
|
||||
public function testDump($directory, $expected)
|
||||
public function testDump($directory)
|
||||
{
|
||||
$this->prepare_workspace();
|
||||
|
||||
@@ -72,11 +72,11 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$data = array(
|
||||
array(__DIR__.'/Fixtures/Namespaced', array(
|
||||
'Namespaced\\Bar' => realpath(__DIR__).'/Fixtures/Namespaced/Bar.php',
|
||||
'Namespaced\\Foo' => realpath(__DIR__).'/Fixtures/Namespaced/Foo.php',
|
||||
'Namespaced\\Baz' => realpath(__DIR__).'/Fixtures/Namespaced/Baz.php',
|
||||
'Namespaced\\Bar' => realpath(__DIR__).'/Fixtures/Namespaced/Bar.php',
|
||||
'Namespaced\\Foo' => realpath(__DIR__).'/Fixtures/Namespaced/Foo.php',
|
||||
'Namespaced\\Baz' => realpath(__DIR__).'/Fixtures/Namespaced/Baz.php',
|
||||
'Namespaced\\WithComments' => realpath(__DIR__).'/Fixtures/Namespaced/WithComments.php',
|
||||
)
|
||||
),
|
||||
),
|
||||
array(__DIR__.'/Fixtures/beta/NamespaceCollision', array(
|
||||
'NamespaceCollision\\A\\B\\Bar' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Bar.php',
|
||||
@@ -85,26 +85,26 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
|
||||
'NamespaceCollision\\C\\B\\Foo' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/C/B/Foo.php',
|
||||
)),
|
||||
array(__DIR__.'/Fixtures/Pearlike', array(
|
||||
'Pearlike_Foo' => realpath(__DIR__).'/Fixtures/Pearlike/Foo.php',
|
||||
'Pearlike_Bar' => realpath(__DIR__).'/Fixtures/Pearlike/Bar.php',
|
||||
'Pearlike_Baz' => realpath(__DIR__).'/Fixtures/Pearlike/Baz.php',
|
||||
'Pearlike_Foo' => realpath(__DIR__).'/Fixtures/Pearlike/Foo.php',
|
||||
'Pearlike_Bar' => realpath(__DIR__).'/Fixtures/Pearlike/Bar.php',
|
||||
'Pearlike_Baz' => realpath(__DIR__).'/Fixtures/Pearlike/Baz.php',
|
||||
'Pearlike_WithComments' => realpath(__DIR__).'/Fixtures/Pearlike/WithComments.php',
|
||||
)),
|
||||
array(__DIR__.'/Fixtures/classmap', array(
|
||||
'Foo\\Bar\\A' => realpath(__DIR__).'/Fixtures/classmap/sameNsMultipleClasses.php',
|
||||
'Foo\\Bar\\B' => realpath(__DIR__).'/Fixtures/classmap/sameNsMultipleClasses.php',
|
||||
'A' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php',
|
||||
'Alpha\\A' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php',
|
||||
'Alpha\\B' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php',
|
||||
'Beta\\A' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php',
|
||||
'Beta\\B' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php',
|
||||
'Foo\\Bar\\A' => realpath(__DIR__).'/Fixtures/classmap/sameNsMultipleClasses.php',
|
||||
'Foo\\Bar\\B' => realpath(__DIR__).'/Fixtures/classmap/sameNsMultipleClasses.php',
|
||||
'A' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php',
|
||||
'Alpha\\A' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php',
|
||||
'Alpha\\B' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php',
|
||||
'Beta\\A' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php',
|
||||
'Beta\\B' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php',
|
||||
'ClassMap\\SomeInterface' => realpath(__DIR__).'/Fixtures/classmap/SomeInterface.php',
|
||||
'ClassMap\\SomeParent' => realpath(__DIR__).'/Fixtures/classmap/SomeParent.php',
|
||||
'ClassMap\\SomeClass' => realpath(__DIR__).'/Fixtures/classmap/SomeClass.php',
|
||||
'ClassMap\\SomeParent' => realpath(__DIR__).'/Fixtures/classmap/SomeParent.php',
|
||||
'ClassMap\\SomeClass' => realpath(__DIR__).'/Fixtures/classmap/SomeClass.php',
|
||||
)),
|
||||
);
|
||||
|
||||
if (version_compare(PHP_VERSION, '5.4', '>=')) {
|
||||
if (PHP_VERSION_ID >= 50400) {
|
||||
$data[] = array(__DIR__.'/Fixtures/php5.4', array(
|
||||
'TFoo' => __DIR__.'/Fixtures/php5.4/traits.php',
|
||||
'CFoo' => __DIR__.'/Fixtures/php5.4/traits.php',
|
||||
@@ -115,15 +115,17 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
|
||||
));
|
||||
}
|
||||
|
||||
if (PHP_VERSION_ID >= 50500) {
|
||||
$data[] = array(__DIR__.'/Fixtures/php5.5', array(
|
||||
'ClassCons\\Foo' => __DIR__.'/Fixtures/php5.5/class_cons.php',
|
||||
));
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function testCreateMapFinderSupport()
|
||||
{
|
||||
if (!class_exists('Symfony\\Component\\Finder\\Finder')) {
|
||||
$this->markTestSkipped('Finder component is not available');
|
||||
}
|
||||
|
||||
$finder = new \Symfony\Component\Finder\Finder();
|
||||
$finder->files()->in(__DIR__.'/Fixtures/beta/NamespaceCollision');
|
||||
|
||||
@@ -138,10 +140,10 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
|
||||
protected function assertEqualsNormalized($expected, $actual, $message = null)
|
||||
{
|
||||
foreach ($expected as $ns => $path) {
|
||||
$expected[$ns] = strtr($path, '\\', '/');
|
||||
$expected[$ns] = str_replace('\\', '/', $path);
|
||||
}
|
||||
foreach ($actual as $ns => $path) {
|
||||
$actual[$ns] = strtr($path, '\\', '/');
|
||||
$actual[$ns] = str_replace('\\', '/', $path);
|
||||
}
|
||||
$this->assertEquals($expected, $actual, $message);
|
||||
}
|
||||
|
||||
@@ -2,4 +2,6 @@
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
class A extends B {}
|
||||
class A extends B
|
||||
{
|
||||
}
|
||||
|
||||
@@ -2,4 +2,6 @@
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
class B implements CInterface {}
|
||||
class B implements CInterface
|
||||
{
|
||||
}
|
||||
|
||||
8
Tests/Fixtures/ClassesWithParents/F.php
Normal file
8
Tests/Fixtures/ClassesWithParents/F.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
class F
|
||||
{
|
||||
use CTrait;
|
||||
}
|
||||
8
Tests/Fixtures/ClassesWithParents/G.php
Normal file
8
Tests/Fixtures/ClassesWithParents/G.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
class G
|
||||
{
|
||||
use CTrait;
|
||||
}
|
||||
@@ -17,7 +17,7 @@ class WithComments
|
||||
public static $loaded = true;
|
||||
}
|
||||
|
||||
$string = 'string shoult not be modified {$string}';
|
||||
$string = 'string should not be modified {$string}';
|
||||
|
||||
$heredoc = (<<<HD
|
||||
|
||||
|
||||
@@ -13,5 +13,4 @@ namespace ClassMap;
|
||||
|
||||
class SomeClass extends SomeParent implements SomeInterface
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -13,5 +13,4 @@ namespace ClassMap;
|
||||
|
||||
interface SomeInterface
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -13,5 +13,4 @@ namespace ClassMap;
|
||||
|
||||
abstract class SomeParent
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace {
|
||||
class A {}
|
||||
class A
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
namespace Alpha {
|
||||
class A {}
|
||||
class B {}
|
||||
class A
|
||||
{
|
||||
}
|
||||
class B
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beta {
|
||||
class A {}
|
||||
class B {}
|
||||
class A
|
||||
{
|
||||
}
|
||||
class B
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,5 +11,9 @@
|
||||
|
||||
namespace Foo\Bar;
|
||||
|
||||
class A {}
|
||||
class B {}
|
||||
class A
|
||||
{
|
||||
}
|
||||
class B
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
trait TD
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
trait TZ
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace {
|
||||
trait TFoo
|
||||
{
|
||||
@@ -25,6 +26,7 @@ namespace Foo {
|
||||
|
||||
class CBar implements IBar
|
||||
{
|
||||
use TBar, TFooBar;
|
||||
use TBar;
|
||||
use TFooBar;
|
||||
}
|
||||
}
|
||||
|
||||
11
Tests/Fixtures/php5.5/class_cons.php
Normal file
11
Tests/Fixtures/php5.5/class_cons.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace ClassCons;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
\Foo\TBar/* foo */::class;
|
||||
}
|
||||
}
|
||||
@@ -32,8 +32,8 @@ namespace Symfony\Component\ClassLoader;
|
||||
* // register classes with namespaces
|
||||
* $loader->registerNamespaces(array(
|
||||
* 'Symfony\Component' => __DIR__.'/component',
|
||||
* 'Symfony' => __DIR__.'/framework',
|
||||
* 'Sensio' => array(__DIR__.'/src', __DIR__.'/vendor'),
|
||||
* 'Symfony' => __DIR__.'/framework',
|
||||
* 'Sensio' => array(__DIR__.'/src', __DIR__.'/vendor'),
|
||||
* ));
|
||||
*
|
||||
* // register a library using the PEAR naming convention
|
||||
@@ -55,8 +55,6 @@ namespace Symfony\Component\ClassLoader;
|
||||
* found before giving up.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class UniversalClassLoader
|
||||
{
|
||||
@@ -68,20 +66,20 @@ class UniversalClassLoader
|
||||
|
||||
/**
|
||||
* Turns on searching the include for class files. Allows easy loading
|
||||
* of installed PEAR packages
|
||||
* of installed PEAR packages.
|
||||
*
|
||||
* @param Boolean $useIncludePath
|
||||
* @param bool $useIncludePath
|
||||
*/
|
||||
public function useIncludePath($useIncludePath)
|
||||
{
|
||||
$this->useIncludePath = $useIncludePath;
|
||||
$this->useIncludePath = (bool) $useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to check if the autoloader uses the include path to check
|
||||
* for classes.
|
||||
*
|
||||
* @return Boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function getUseIncludePath()
|
||||
{
|
||||
@@ -132,8 +130,6 @@ class UniversalClassLoader
|
||||
* Registers the directory to use as a fallback for namespaces.
|
||||
*
|
||||
* @param array $dirs An array of directories
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function registerNamespaceFallbacks(array $dirs)
|
||||
{
|
||||
@@ -154,8 +150,6 @@ class UniversalClassLoader
|
||||
* Registers directories to use as a fallback for class prefixes.
|
||||
*
|
||||
* @param array $dirs An array of directories
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function registerPrefixFallbacks(array $dirs)
|
||||
{
|
||||
@@ -173,11 +167,9 @@ class UniversalClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an array of namespaces
|
||||
* Registers an array of namespaces.
|
||||
*
|
||||
* @param array $namespaces An array of namespaces (namespaces as keys and locations as values)
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function registerNamespaces(array $namespaces)
|
||||
{
|
||||
@@ -191,8 +183,6 @@ class UniversalClassLoader
|
||||
*
|
||||
* @param string $namespace The namespace
|
||||
* @param array|string $paths The location(s) of the namespace
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function registerNamespace($namespace, $paths)
|
||||
{
|
||||
@@ -203,8 +193,6 @@ class UniversalClassLoader
|
||||
* Registers an array of classes using the PEAR naming convention.
|
||||
*
|
||||
* @param array $classes An array of classes (prefixes as keys and locations as values)
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function registerPrefixes(array $classes)
|
||||
{
|
||||
@@ -218,8 +206,6 @@ class UniversalClassLoader
|
||||
*
|
||||
* @param string $prefix The classes prefix
|
||||
* @param array|string $paths The location(s) of the classes
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function registerPrefix($prefix, $paths)
|
||||
{
|
||||
@@ -229,9 +215,7 @@ class UniversalClassLoader
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param Boolean $prepend Whether to prepend the autoloader or not
|
||||
*
|
||||
* @api
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
@@ -243,7 +227,7 @@ class UniversalClassLoader
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return Boolean|null True, if loaded
|
||||
* @return bool|null True, if loaded
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
@@ -287,7 +271,6 @@ class UniversalClassLoader
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// PEAR-like class name
|
||||
$normalizedClass = str_replace('_', DIRECTORY_SEPARATOR, $class).'.php';
|
||||
|
||||
@@ -17,11 +17,19 @@ namespace Symfony\Component\ClassLoader;
|
||||
* It expects an object implementing a findFile method to find the file. This
|
||||
* allow using it as a wrapper around the other loaders of the component (the
|
||||
* ClassLoader and the UniversalClassLoader for instance) but also around any
|
||||
* other autoloader following this convention (the Composer one for instance)
|
||||
* other autoloaders following this convention (the Composer one for instance).
|
||||
*
|
||||
* // with a Symfony autoloader
|
||||
* use Symfony\Component\ClassLoader\ClassLoader;
|
||||
*
|
||||
* $loader = new ClassLoader();
|
||||
* $loader->addPrefix('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->addPrefix('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* // or with a Composer autoloader
|
||||
* use Composer\Autoload\ClassLoader;
|
||||
*
|
||||
* $loader = new ClassLoader();
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
@@ -43,18 +51,17 @@ class WinCacheClassLoader
|
||||
private $prefix;
|
||||
|
||||
/**
|
||||
* The class loader object being decorated.
|
||||
* A class loader object that implements the findFile() method.
|
||||
*
|
||||
* @var \Symfony\Component\ClassLoader\ClassLoader
|
||||
* A class loader object that implements the findFile() method.
|
||||
* @var object
|
||||
*/
|
||||
protected $decorated;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $prefix The WinCache namespace prefix to use.
|
||||
* @param object $decorated A class loader object that implements the findFile() method.
|
||||
* @param string $prefix The WinCache namespace prefix to use.
|
||||
* @param object $decorated A class loader object that implements the findFile() method.
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
* @throws \InvalidArgumentException
|
||||
@@ -76,7 +83,7 @@ class WinCacheClassLoader
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param Boolean $prepend Whether to prepend the autoloader or not
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
@@ -96,7 +103,7 @@ class WinCacheClassLoader
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return Boolean|null True, if loaded
|
||||
* @return bool|null True, if loaded
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
@@ -116,8 +123,10 @@ class WinCacheClassLoader
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
if (false === $file = wincache_ucache_get($this->prefix.$class)) {
|
||||
wincache_ucache_set($this->prefix.$class, $file = $this->decorated->findFile($class), 0);
|
||||
$file = wincache_ucache_get($this->prefix.$class, $success);
|
||||
|
||||
if (!$success) {
|
||||
wincache_ucache_set($this->prefix.$class, $file = $this->decorated->findFile($class) ?: null, 0);
|
||||
}
|
||||
|
||||
return $file;
|
||||
|
||||
@@ -12,16 +12,24 @@
|
||||
namespace Symfony\Component\ClassLoader;
|
||||
|
||||
/**
|
||||
* XcacheClassLoader implements a wrapping autoloader cached in Xcache for PHP 5.3.
|
||||
* XcacheClassLoader implements a wrapping autoloader cached in XCache for PHP 5.3.
|
||||
*
|
||||
* It expects an object implementing a findFile method to find the file. This
|
||||
* allows using it as a wrapper around the other loaders of the component (the
|
||||
* ClassLoader and the UniversalClassLoader for instance) but also around any
|
||||
* other autoloader following this convention (the Composer one for instance)
|
||||
* other autoloaders following this convention (the Composer one for instance).
|
||||
*
|
||||
* // with a Symfony autoloader
|
||||
* use Symfony\Component\ClassLoader\ClassLoader;
|
||||
*
|
||||
* $loader = new ClassLoader();
|
||||
* $loader->addPrefix('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->addPrefix('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* // or with a Composer autoloader
|
||||
* use Composer\Autoload\ClassLoader;
|
||||
*
|
||||
* $loader = new ClassLoader();
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
@@ -37,43 +45,45 @@ namespace Symfony\Component\ClassLoader;
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
* @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class XcacheClassLoader
|
||||
{
|
||||
private $prefix;
|
||||
private $classFinder;
|
||||
|
||||
/**
|
||||
* A class loader object that implements the findFile() method.
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
private $decorated;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $prefix A prefix to create a namespace in Xcache
|
||||
* @param object $classFinder An object that implements findFile() method.
|
||||
* @param string $prefix The XCache namespace prefix to use.
|
||||
* @param object $decorated A class loader object that implements the findFile() method.
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function __construct($prefix, $classFinder)
|
||||
public function __construct($prefix, $decorated)
|
||||
{
|
||||
if (!extension_loaded('Xcache')) {
|
||||
throw new \RuntimeException('Unable to use XcacheClassLoader as Xcache is not enabled.');
|
||||
if (!extension_loaded('xcache')) {
|
||||
throw new \RuntimeException('Unable to use XcacheClassLoader as XCache is not enabled.');
|
||||
}
|
||||
|
||||
if (!method_exists($classFinder, 'findFile')) {
|
||||
if (!method_exists($decorated, 'findFile')) {
|
||||
throw new \InvalidArgumentException('The class finder must implement a "findFile" method.');
|
||||
}
|
||||
|
||||
$this->prefix = $prefix;
|
||||
$this->classFinder = $classFinder;
|
||||
$this->decorated = $decorated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param Boolean $prepend Whether to prepend the autoloader or not
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
@@ -93,7 +103,7 @@ class XcacheClassLoader
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return Boolean|null True, if loaded
|
||||
* @return bool|null True, if loaded
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
@@ -116,9 +126,18 @@ class XcacheClassLoader
|
||||
if (xcache_isset($this->prefix.$class)) {
|
||||
$file = xcache_get($this->prefix.$class);
|
||||
} else {
|
||||
xcache_set($this->prefix.$class, $file = $this->classFinder->findFile($class));
|
||||
$file = $this->decorated->findFile($class) ?: null;
|
||||
xcache_set($this->prefix.$class, $file);
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes through all unknown calls onto the decorated object.
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
return call_user_func_array(array($this->decorated, $method), $args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"type": "library",
|
||||
"description": "Symfony ClassLoader Component",
|
||||
"keywords": [],
|
||||
"homepage": "http://symfony.com",
|
||||
"homepage": "https://symfony.com",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
@@ -12,18 +12,22 @@
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"minimum-stability": "dev",
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
"php": ">=5.3.3",
|
||||
"symfony/polyfill-apcu": "~1.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/finder": "~2.0"
|
||||
"symfony/finder": "~2.0,>=2.0.5"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": { "Symfony\\Component\\ClassLoader\\": "" }
|
||||
"psr-0": { "Symfony\\Component\\ClassLoader\\": "" },
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"target-dir": "Symfony/Component/ClassLoader",
|
||||
"extra": {
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
bootstrap="vendor/autoload.php"
|
||||
>
|
||||
<php>
|
||||
<ini name="error_reporting" value="-1" />
|
||||
</php>
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="Symfony ClassLoader Component Test Suite">
|
||||
<directory>./Tests/</directory>
|
||||
|
||||
Reference in New Issue
Block a user