@@ -24,7 +24,7 @@ class FilePositionMap {
2424 /** @var int the 0-based byte offset of the most recent request for a line number. */
2525 private $ currentOffset ;
2626
27- /** @var int the line number for $this->currentOffset (updated whenever currentOffset is updated) */
27+ /** @var int the 1-based line number for $this->currentOffset (updated whenever currentOffset is updated) */
2828 private $ lineForCurrentOffset ;
2929
3030 public function __construct (string $ file_contents ) {
@@ -45,7 +45,7 @@ public function getNodeStartLine(Node $node) : int {
4545 }
4646
4747 /**
48- * @param Node $node the node to get the start line for.
48+ * @param Token $token the token to get the start line for.
4949 */
5050 public function getTokenStartLine (Token $ token ) : int {
5151 return $ this ->getLineNumberForOffset ($ token ->start );
@@ -86,19 +86,23 @@ public function getEndLine($node) : int {
8686 * Similar to getStartLine but includes the column
8787 */
8888 public function getEndLineCharacterPositionForOffset ($ node ) : LineCharacterPosition {
89- return $ this ->getLineCharacterPositionForOffset ($ node );
89+ return $ this ->getLineCharacterPositionForOffset ($ node-> getEndPosition () );
9090 }
9191
9292 /**
93- * @param Node|Token $node
94- * Similar to getStartLine but includes the column
93+ * @param int $offset
94+ * Similar to getStartLine but includes both the line and the column
9595 */
9696 public function getLineCharacterPositionForOffset (int $ offset ) : LineCharacterPosition {
9797 $ line = $ this ->getLineNumberForOffset ($ offset );
9898 $ character = $ this ->getColumnForOffset ($ offset );
9999 return new LineCharacterPosition ($ line , $ character );
100100 }
101101
102+ /**
103+ * @param int $offset - A 0-based byte offset
104+ * @return int - gets the 1-based line number for $offset
105+ */
102106 public function getLineNumberForOffset (int $ offset ) : int {
103107 if ($ offset < 0 ) {
104108 $ offset = 0 ;
@@ -117,7 +121,8 @@ public function getLineNumberForOffset(int $offset) : int {
117121 }
118122
119123 /**
120- * @return int - gets the 1-based column offset
124+ * @param int $offset - A 0-based byte offset
125+ * @return int - gets the 1-based column number for $offset
121126 */
122127 public function getColumnForOffset (int $ offset ) : int {
123128 $ length = $ this ->fileContentsLength ;
0 commit comments