From 51af1642bae5b2c94efb4be4880bc20417aa1ba3 Mon Sep 17 00:00:00 2001 From: Olivier Dolbeau Date: Tue, 1 Apr 2014 10:16:08 +0200 Subject: [PATCH] Add a way to override modifiers --- lib/Doctrine/Common/Lexer/AbstractLexer.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/Common/Lexer/AbstractLexer.php b/lib/Doctrine/Common/Lexer/AbstractLexer.php index 869b08d..7625d99 100644 --- a/lib/Doctrine/Common/Lexer/AbstractLexer.php +++ b/lib/Doctrine/Common/Lexer/AbstractLexer.php @@ -247,8 +247,12 @@ protected function scan($input) static $regex; if ( ! isset($regex)) { - $regex = '/(' . implode(')|(', $this->getCatchablePatterns()) . ')|' - . implode('|', $this->getNonCatchablePatterns()) . '/i'; + $regex = sprintf( + '/(%s)|%s/%s', + implode(')|(', $this->getCatchablePatterns()), + implode('|', $this->getNonCatchablePatterns()), + $this->getModifiers() + ); } $flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE; @@ -288,6 +292,16 @@ public function getLiteral($token) return $token; } + /** + * Regex modifiers + * + * @return string + */ + protected function getModifiers() + { + return 'i'; + } + /** * Lexical catchable patterns. *