2017 © Pedro Peláez
 

library scope-resolver

Scope Resolver for PHP-Parser

image

sekjun9878/scope-resolver

Scope Resolver for PHP-Parser

  • Saturday, November 7, 2015
  • by sekjun9878
  • Repository
  • 0 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

ScopeResolver for PHP-Parser

This is a NodeVisitor component for nikic/PHP-Parser that resolves the scope of classes, functions, namespace and closures, and appends them to every node as an attribute., (*1)

This can be useful if you need a unique scope identifier for anything, e.g. checking the scope of a variable., (*2)

Currently, only PHP5 is supported but I'm working on PHP7 support., (*3)

Usage

Usage is really really really simple., (*4)

use sekjun9878\ScopeResolver\NodeVisitor\ScopeResolver;

$parser        = (new ParserFactory)->create(ParserFactory::PREFER_PHP5);
$traverser     = new NodeTraverser;

// Add the ScopeResolver visitor
$traverser->addVisitor(new ScopeResolver);

$stmts = $parser->parse($code);
$stmts = $traverser->traverse($stmts);

// Now every node will have a "scope" attribute attached.

The Versions

07/11 2015

dev-master

9999999-dev

Scope Resolver for PHP-Parser

  Sources   Download

MIT

The Requires