delphi / parser-scoperesolver
PHPParser Visitor to resolve and set scope
Installs: 9
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/delphi/parser-scoperesolver
Requires
- delphi/parser-fileresolver: dev-main
- delphi/parserutils: dev-main
- nikic/php-parser: ^4
Requires (Dev)
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2025-10-18 01:39:24 UTC
README
Tracks the currently active scope to maintain a registry of variables
Usage
$scopeResolver = new ScopeResolver(); $t = new \PhpParser\NodeTraverser(); $t->addVisitor($scopeResolver); /** @var \delphi\Parser\Scope\Helper\Scope $scope */ $scope = $node->getAttribute(ScopeResolver::ATTRIBUTE_KEY); if ($scope->hasVariable('foo')) { /** @var \PhpParser\Node\Expr $value The expression that defined the variable itself */ $value = $scope->getVariable('foo'); } /** @var \PhpParser\Node $definingNode The node that defined this scope (class, function, etc) */ $definingNode = $scope->getDefiningNode(); /** * Scope that contains the given scope, or null if already the global scope * @var \delphi\Parser\Scope\Helper\Scope | null $parentScope */ $parentScope = $scope->getParentScope();