Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Merged
merged 1 commit into from
Nov 25, 2015

Conversation

nicolas-grekas
Copy link
Member

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #14871
License MIT
Doc PR -

@nicolas-grekas
Copy link
Member Author

Not bullet proof, but that's not a target (if you want a bullet proof solution, enable token_get_all).

@stof
Copy link
Member

stof commented Nov 25, 2015

👍

1 similar comment
@Tobion
Copy link
Contributor

Tobion commented Nov 25, 2015

👍

@Tobion
Copy link
Contributor

Tobion commented Nov 25, 2015

Thank you @nicolas-grekas.

@Tobion Tobion merged commit 4a17c9e into symfony:2.3 Nov 25, 2015
Tobion added a commit that referenced this pull request Nov 25, 2015
…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
@nicolas-grekas nicolas-grekas deleted the fix-14871 branch November 25, 2015 19:35
@@ -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)) {
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks!

This was referenced Nov 30, 2015
This was referenced Dec 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants