Skip to content

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

Closed
@mkruk-u2

Description

@mkruk-u2

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions