Skip to content

Instantly share code, notes, and snippets.

@msjyoo
Last active November 25, 2015 06:42
Show Gist options
  • Save msjyoo/7eadd68ad8644614e3c8 to your computer and use it in GitHub Desktop.
Save msjyoo/7eadd68ad8644614e3c8 to your computer and use it in GitHub Desktop.
switch(get_class($node))
{
    case Assign::class:
        /** @var Assign $node */
        $var['name'] = $node->var;
        break;
    case Property::class:
        /** @var Property $node */
        $var['name'] = first($node->props);
        break;
    default:
        throw new \LogicException("Unimplemented var node detected!");
}
// No automatic completion on ->ame - doesn't know what first() does to $node->props.
// Super deep inspection of functions required.
$var['name'] = first($node->props)->name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment