Refactor to use getStartPosition

This commit is contained in:
Tyson Andre 2021-04-29 17:19:15 -04:00
Родитель 465d02f146
Коммит 0b40640ac3
2 изменённых файлов: 3 добавлений и 17 удалений

Просмотреть файл

@ -7,7 +7,7 @@ an experiment and the start of a conversation.
![image](https://cloud.githubusercontent.com/assets/762848/19023070/4ab01c92-889a-11e6-9bb5-ec1a6816aba2.png)
This is the v1 branch, which changes data structures to support syntax added after the initial release for php 7.0.
This is the v0.1 branch, which changes data structures to support syntax added after the initial 0.0.x release line.
## Get Started
After you've [configured your machine](docs/GettingStarted.md), you can use the parser to generate and work

Просмотреть файл

@ -32,13 +32,7 @@ abstract class Node implements \JsonSerializable {
* @throws \Exception
*/
public function getStartPosition() : int {
$child = $this->getChildNodesAndTokens()->current();
if ($child instanceof Node) {
return $child->getStartPosition();
} elseif ($child instanceof Token) {
return $child->start;
}
throw new \Exception("Unknown type in AST");
return $this->getChildNodesAndTokens()->current()->getStartPosition();
}
/**
@ -58,15 +52,7 @@ abstract class Node implements \JsonSerializable {
$child = $child[0];
}
if ($child instanceof Node) {
return $child->getFullStartPosition();
}
if ($child instanceof Token) {
return $child->fullStart;
}
throw new \Exception("Unknown type in AST: " . \gettype($child));
return $child->getFullStartPosition();
}
};