mirror of
https://github.com/symfony/class-loader.git
synced 2026-03-24 17:22:11 +01:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3527a2b300 | ||
|
|
c393e86a03 | ||
|
|
475b92bd71 |
@@ -18,7 +18,8 @@ namespace Symfony\Component\ClassLoader;
|
||||
*/
|
||||
class ClassCollectionLoader
|
||||
{
|
||||
static private $loaded;
|
||||
private static $loaded;
|
||||
private static $useTokenizer = true;
|
||||
|
||||
/**
|
||||
* Loads a list of classes and caches them in one big file.
|
||||
@@ -32,7 +33,7 @@ class ClassCollectionLoader
|
||||
*
|
||||
* @throws \InvalidArgumentException When class can't be loaded
|
||||
*/
|
||||
static public function load($classes, $cacheDir, $name, $autoReload, $adaptive = false, $extension = '.php')
|
||||
public static function load($classes, $cacheDir, $name, $autoReload, $adaptive = false, $extension = '.php')
|
||||
{
|
||||
// each $name can only be loaded once per PHP process
|
||||
if (isset(self::$loaded[$name])) {
|
||||
@@ -123,9 +124,13 @@ class ClassCollectionLoader
|
||||
*
|
||||
* @return string Namespaces with brackets
|
||||
*/
|
||||
static public function fixNamespaceDeclarations($source)
|
||||
public static function fixNamespaceDeclarations($source)
|
||||
{
|
||||
if (!function_exists('token_get_all')) {
|
||||
if (!function_exists('token_get_all') || !self::$useTokenizer) {
|
||||
if (preg_match('/namespace(.*?)\s*;/', $source)) {
|
||||
$source = preg_replace('/namespace(.*?)(\s*);/', "namespace$1$2\n{", $source)."}\n";
|
||||
}
|
||||
|
||||
return $source;
|
||||
}
|
||||
|
||||
@@ -177,7 +182,7 @@ class ClassCollectionLoader
|
||||
*
|
||||
* @throws \RuntimeException when a cache file cannot be written
|
||||
*/
|
||||
static private function writeCacheFile($file, $content)
|
||||
private static function writeCacheFile($file, $content)
|
||||
{
|
||||
$tmpFile = tempnam(dirname($file), basename($file));
|
||||
if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) {
|
||||
@@ -199,7 +204,7 @@ class ClassCollectionLoader
|
||||
*
|
||||
* @return string The PHP string with the comments removed
|
||||
*/
|
||||
static private function stripComments($source)
|
||||
private static function stripComments($source)
|
||||
{
|
||||
if (!function_exists('token_get_all')) {
|
||||
return $source;
|
||||
@@ -219,4 +224,12 @@ class ClassCollectionLoader
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is only useful for testing.
|
||||
*/
|
||||
public static function enableTokenizer($bool)
|
||||
{
|
||||
self::$useTokenizer = (Boolean) $bool;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class DebugUniversalClassLoader extends UniversalClassLoader
|
||||
/**
|
||||
* Replaces all regular UniversalClassLoader instances by a DebugUniversalClassLoader ones.
|
||||
*/
|
||||
static public function enable()
|
||||
public static function enable()
|
||||
{
|
||||
if (!is_array($functions = spl_autoload_functions())) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user