Skip to content

Commit ad9c666

Browse files
committed
#209 - fix class names that match [a-z]+[0-9]+\-
1 parent 49fd3e4 commit ad9c666

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/Parser/Tokenizer/Literals.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,25 @@ public function tokenize(TokenizedString $str, Tokens $tokens) {
2828
}
2929
}
3030

31+
private function isRealSubtract($n, $str) {
32+
$n--;
33+
// allow foo(2-5)
34+
//but not data(foo2-5)
35+
while (is_numeric($str->read($n))) {
36+
$n--;
37+
}
38+
39+
if ($n == 0) return false;
40+
if (in_array($str->read($n), ['(', "\n", ' ', '['])) return true;
41+
42+
return false;
43+
}
44+
3145
private function isLiteral($n, $str) {
3246
//Is it a normal literal character
3347
return ($str->has($n) && ($str->identifyChar($n, $str) === Tokenizer::NAME
3448
//but a subtract can be part of a class name or a mathematical operation
35-
|| $str->identifyChar($n) == Tokenizer::SUBTRACT && !is_numeric($str->read($n-1)))
49+
|| $str->identifyChar($n) == Tokenizer::SUBTRACT && !$this->isRealSubtract($n, $str))
3650
);
3751
}
3852

0 commit comments

Comments
 (0)