Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
[ClassLoader] fixed unbracketed namespaces (closes #5747)
  • Loading branch information
fabpot committed Oct 27, 2012
1 parent 475b92b commit c393e86
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion ClassCollectionLoader.php
Expand Up @@ -19,6 +19,7 @@
class ClassCollectionLoader
{
private static $loaded;
private static $useTokenizer = true;

/**
* Loads a list of classes and caches them in one big file.
Expand Down Expand Up @@ -125,7 +126,11 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive =
*/
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;
}

Expand Down Expand Up @@ -219,4 +224,12 @@ private static function stripComments($source)

return $output;
}

/**
* This method is only useful for testing.
*/
public static function enableTokenizer($bool)
{
self::$useTokenizer = (Boolean) $bool;
}
}

0 comments on commit c393e86

Please sign in to comment.