-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Description
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?