Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #772 from BlaineSch/bug/tokenBleedingLine

Update bleeding line number to be less specific.
  • Loading branch information...
commit ad32f69330d6b5e0d715ef0b037051801c76d198 2 parents 0bb714a + 96f7e19
@nateabele nateabele authored
Showing with 12 additions and 3 deletions.
  1. +1 −3 analysis/Parser.php
  2. +11 −0 tests/cases/analysis/ParserTest.php
View
4 analysis/Parser.php
@@ -75,9 +75,7 @@ public static function tokenize($code, array $options = array()) {
}
$tokens[] = array('id' => $id, 'name' => $name, 'content' => $content, 'line' => $line);
- if ($id === T_WHITESPACE) {
- $line += count(preg_split('/\r\n|\r|\n/', $content)) - 1;
- }
+ $line += count(preg_split('/\r\n|\r|\n/', $content)) - 1;
}
if ($options['wrap'] && empty($options['include'])) {
View
11 tests/cases/analysis/ParserTest.php
@@ -153,6 +153,17 @@ public function testParserGuessesLineBleed() {
$this->assertIdentical(3, $tokens[13]['line']);
}
+ public function testParserGuessesLineBleedWithNonWhitespace() {
+ $code = <<<EOD
+if (false) {
+ // hello world
+}
+EOD;
+ $tokens = Parser::tokenize($code);
+ $this->assertIdentical('}', $tokens[9]['content']);
+ $this->assertIdentical(3, $tokens[9]['line']);
+ }
+
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.