Removed reference to potentially undefined variable

This commit is contained in:
dantleech 2018-07-28 07:58:50 +02:00
Родитель 531d8bd5a2
Коммит c28b34b5e5
1 изменённых файлов: 8 добавлений и 2 удалений

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

@ -48,23 +48,29 @@ abstract class Node implements \JsonSerializable {
*/
public function getFullStart() : int {
foreach($this::CHILD_NAMES as $name) {
if (($child = $this->$name) !== null) {
if (\is_array($child)) {
if(!isset($child[0])) {
continue;
}
$child = $child[0];
}
if ($child instanceof Node) {
return $child->getFullStart();
} elseif ($child instanceof Token) {
}
if ($child instanceof Token) {
return $child->fullStart;
}
throw new \Exception("Unknown type in AST: " . \gettype($child));
}
};
throw new \Exception("Unknown type in AST: " . \gettype($child));
throw new \RuntimeException("Could not resolve full start position");
}
/**