-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[ClassLoader] Fix parsing namespace when token_get_all() is missing #16668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
nicolas-grekas
commented
Nov 25, 2015
Q | A |
---|---|
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #14871 |
License | MIT |
Doc PR | - |
Not bullet proof, but that's not a target (if you want a bullet proof solution, enable token_get_all). |
👍 |
1 similar comment
👍 |
Thank you @nicolas-grekas. |
…s missing (nicolas-grekas) This PR was merged into the 2.3 branch. Discussion ---------- [ClassLoader] Fix parsing namespace when token_get_all() is missing | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #14871 | License | MIT | Doc PR | - Commits ------- 4a17c9e [ClassLoader] Fix parsing namespace when token_get_all() is missing
@@ -137,8 +137,8 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive = | |||
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)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't \b
in regexes meant for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\b would match e.g. :namespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks!