Skip to content

Instantly share code, notes, and snippets.

@EclipseGc
Last active September 9, 2016 21:26
Show Gist options
  • Save EclipseGc/6e9d6d4b58224aefa946042191fdf106 to your computer and use it in GitHub Desktop.
Save EclipseGc/6e9d6d4b58224aefa946042191fdf106 to your computer and use it in GitHub Desktop.
<?php
$code = file_get_contents($file);
$tokens = token_get_all($code);
$tree = new \EclipseGc\Ast\Tree;
foreach ($tokens as $id => $token) {
if (is_array($token)) {
$tree->addNode($nodeDictionary->createInstance($token[0], $token[1], $id, $tokens);
}
else {
$tree->addNode($nodeDictionary->getInstance($token);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment