Skip to content

Commit

Permalink
#209 - fix class names that match [a-z]+[0-9]+\-
Browse files Browse the repository at this point in the history
  • Loading branch information
TRPB committed Feb 2, 2020
1 parent 49fd3e4 commit ad9c666
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Parser/Tokenizer/Literals.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,25 @@ public function tokenize(TokenizedString $str, Tokens $tokens) {
}
}

private function isRealSubtract($n, $str) {
$n--;
// allow foo(2-5)
//but not data(foo2-5)
while (is_numeric($str->read($n))) {
$n--;
}

if ($n == 0) return false;
if (in_array($str->read($n), ['(', "\n", ' ', '['])) return true;

return false;
}

private function isLiteral($n, $str) {
//Is it a normal literal character
return ($str->has($n) && ($str->identifyChar($n, $str) === Tokenizer::NAME
//but a subtract can be part of a class name or a mathematical operation
|| $str->identifyChar($n) == Tokenizer::SUBTRACT && !is_numeric($str->read($n-1)))
|| $str->identifyChar($n) == Tokenizer::SUBTRACT && !$this->isRealSubtract($n, $str))
);
}

Expand Down

0 comments on commit ad9c666

Please sign in to comment.