Skip to content
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

[Routing] AnnotationFileLoader throws exception when parsing non-class files that contain "::class" syntax #18633

Closed
mkruk-u2 opened this issue Apr 25, 2016 · 0 comments

Comments

@mkruk-u2
Copy link

mkruk-u2 commented Apr 25, 2016

The AnnotationFileLoader interprets ClassName::class syntax as start of class definition and treats next token (if it's a string) as a class name.

Example:

trait Foo
{
    public function doBar()
    {
        $baz = self::class;  // this is parsed as a beginning of class definition
        if (true) {
        }
    }
}

AnnotationFileLoader will find "true" as a name of a class in that file.
This will result in "Class true does not exist" exception thrown from \Symfony\Component\Routing\Loader\AnnotationClassLoader::load.

fabpot added a commit that referenced this issue May 29, 2016
…t as a beginning of a class name (jakzal, nicolas-grekas)

This PR was merged into the 2.3 branch.

Discussion
----------

[Routing] Fix the annotation loader taking a class constant as a beginning of a class name

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

Code copy/pasted from ClassMapGenerator.php

Commits
-------

8d4f35d [Routing] Finish annotation loader taking a class constant as a beginning of a class name
43c7f9b [Routing] Fix the annotation loader taking a class constant as a beginning of a class name
@fabpot fabpot closed this as completed May 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants