use PhpParser\Node;
use PhpParser\Node\Name;
use PhpParser\Node\Name\FullyQualified as FullyQualifiedName;
-use PhpParser\Node\Stmt\GroupUse as GroupUseStmt;
-use PhpParser\Node\Stmt\Namespace_ as NamespaceStmt;
-use PhpParser\Node\Stmt\Use_ as UseStmt;
+use PhpParser\Node\Stmt\GroupUse;
+use PhpParser\Node\Stmt\Namespace_;
+use PhpParser\Node\Stmt\Use_;
/**
* Provide implicit use statements for subsequent execution.
* ... which it then applies implicitly to all future evaluated code, until the
* current namespace is replaced by another namespace.
*/
-class UseStatementPass extends NamespaceAwarePass
+class UseStatementPass extends CodeCleanerPass
{
private $aliases = array();
private $lastAliases = array();
*/
public function enterNode(Node $node)
{
- if ($node instanceof NamespaceStmt) {
+ if ($node instanceof Namespace_) {
// If this is the same namespace as last namespace, let's do ourselves
// a favor and reload all the aliases...
if (strtolower($node->name) === strtolower($this->lastNamespace)) {
*/
public function leaveNode(Node $node)
{
- if ($node instanceof UseStmt) {
+ if ($node instanceof Use_) {
// Store a reference to every "use" statement, because we'll need
// them in a bit.
foreach ($node->uses as $use) {
}
return false;
- } elseif ($node instanceof GroupUseStmt) {
+ } elseif ($node instanceof GroupUse) {
// Expand every "use" statement in the group into a full, standalone
// "use" and store 'em with the others.
foreach ($node->uses as $use) {
}
return false;
- } elseif ($node instanceof NamespaceStmt) {
+ } elseif ($node instanceof Namespace_) {
// Start fresh, since we're done with this namespace.
$this->lastNamespace = $node->name;
$this->lastAliases = $this->aliases;