Closed kstkn closed 5 years ago
This makes sense. Unless there is some valid reason why it was done this way. For performance or something, but I doubt it. Can you add a unit test?
@jwage test added
@guilhermeblanco can you take a look at this?
The static was added exactly for performance reasons, but can be addressed by using the private variable, for sure. We did that before because we could b using the same Lexer for multiple queries and didn't want to rebuild the regex every time (as Lexer in ORM is not shared).
Anyway, LGTM
@jwage
Method
\Doctrine\Common\Lexer\AbstractLexer::scan
contains static variable$regex
, which shares state between class instances. Consider following example, in which second instance ($lexer2
) has different catchable pattern ([a-z]+
), but still behaves like the first one: