Skip to content

Commit 0b40640

Browse files
committed
Refactor to use getStartPosition
1 parent 465d02f commit 0b40640

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ an experiment and the start of a conversation.
77

88
![image](https://cloud.githubusercontent.com/assets/762848/19023070/4ab01c92-889a-11e6-9bb5-ec1a6816aba2.png)
99

10-
This is the v1 branch, which changes data structures to support syntax added after the initial release for php 7.0.
10+
This is the v0.1 branch, which changes data structures to support syntax added after the initial 0.0.x release line.
1111

1212
## Get Started
1313
After you've [configured your machine](docs/GettingStarted.md), you can use the parser to generate and work

src/Node.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,7 @@ public function getNodeKindName() : string {
3232
* @throws \Exception
3333
*/
3434
public function getStartPosition() : int {
35-
$child = $this->getChildNodesAndTokens()->current();
36-
if ($child instanceof Node) {
37-
return $child->getStartPosition();
38-
} elseif ($child instanceof Token) {
39-
return $child->start;
40-
}
41-
throw new \Exception("Unknown type in AST");
35+
return $this->getChildNodesAndTokens()->current()->getStartPosition();
4236
}
4337

4438
/**
@@ -58,15 +52,7 @@ public function getFullStartPosition() : int {
5852
$child = $child[0];
5953
}
6054

61-
if ($child instanceof Node) {
62-
return $child->getFullStartPosition();
63-
}
64-
65-
if ($child instanceof Token) {
66-
return $child->fullStart;
67-
}
68-
69-
throw new \Exception("Unknown type in AST: " . \gettype($child));
55+
return $child->getFullStartPosition();
7056
}
7157
};
7258

0 commit comments

Comments
 (0)