Skip to content

Problem with cache generation when PHP tokenizer extension is not available #14871

@mageekguy

Description

@mageekguy

If PHP is not compiled with tokenizer extension, there is a bug in the classCollectionLoader class with this kind of code.
The root cause is that the regex use to normalize the code is too generic and is used on all namespace string, even this string is prefixed with (for example) a $ sign.
In this context, a solution is to use a look-behind assertion in the regex to exclude all namespace string which is not prefixed by $, ie. replacing '/namespace(.*?)\s*;/ by '/(?<!\$)namespace(.*?)\s*;/' (see PCRE PHP documentation for more information about assertion).
However, this fix does not handle correctly self::namespace, 'namespace', "namespace" and so on, and it seems to me very difficult to handle all cases in an efficient manner using regex.
In my opinion, the best solution is to transform the PHP tokenizer extension as a mandatory requierement to use Symfony and throwing an exception if it is not available.
Any through?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions