From c8454271e10008d34e4fdc0b9d2e17d72834a931 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 18 Apr 2015 21:20:45 +0200 Subject: [PATCH] Make column info 1-based --- lib/PhpParser/Error.php | 6 ++--- test/PhpParser/ErrorTest.php | 24 +++++++++---------- .../parser/expr/newWithoutClass.test-fail | 2 +- .../code/parser/stmt/class/modifier.test-fail | 2 +- test/code/parser/stmt/class/name.test-fail | 22 ++++++++--------- .../parser/stmt/function/variadic.test-fail | 2 +- .../stmt/haltCompilerOutermostScope.test-fail | 2 +- .../code/parser/stmt/namespace/name.test-fail | 8 +++---- .../parser/stmt/namespace/nested.test-fail | 2 +- 9 files changed, 35 insertions(+), 35 deletions(-) diff --git a/lib/PhpParser/Error.php b/lib/PhpParser/Error.php index 4cdf108..21d67d5 100644 --- a/lib/PhpParser/Error.php +++ b/lib/PhpParser/Error.php @@ -93,7 +93,7 @@ class Error extends \RuntimeException } /** - * Gets the start column (0-based) into the line where the error started. + * Gets the start column (1-based) into the line where the error started. * * @param string $code Source code of the file * @return int @@ -107,7 +107,7 @@ class Error extends \RuntimeException } /** - * Gets the end column (0-based) into the line where the error ended. + * Gets the end column (1-based) into the line where the error ended. * * @param string $code Source code of the file * @return int @@ -130,7 +130,7 @@ class Error extends \RuntimeException $lineStartPos = -1; } - return $pos - $lineStartPos - 1; + return $pos - $lineStartPos; } /** diff --git a/test/PhpParser/ErrorTest.php b/test/PhpParser/ErrorTest.php index a94e542..781eeb3 100644 --- a/test/PhpParser/ErrorTest.php +++ b/test/PhpParser/ErrorTest.php @@ -49,21 +49,21 @@ class ErrorTest extends \PHPUnit_Framework_TestCase public function provideTestColumnInfo() { return array( // Error at "bar" - array("