Chris@13: name instanceof Identifier ? $node->name->toString() : $node->name; Chris@13: $args = [ Chris@13: $node->var, Chris@17: \is_string($name) ? new String_($name) : $name, Chris@13: ]; Chris@13: Chris@13: return $this->prepareCall(self::PROPERTY_FETCH, $args); Chris@13: } elseif ($node instanceof Assign && $node->var instanceof PropertyFetch) { Chris@13: $target = $node->var; Chris@13: $name = $target->name instanceof Identifier ? $target->name->toString() : $target->name; Chris@13: $args = [ Chris@13: $target->var, Chris@17: \is_string($name) ? new String_($name) : $name, Chris@13: $node->expr, Chris@13: ]; Chris@13: Chris@13: return $this->prepareCall(self::PROPERTY_ASSIGN, $args); Chris@13: } elseif ($node instanceof MethodCall) { Chris@13: $name = $node->name instanceof Identifier ? $node->name->toString() : $node->name; Chris@13: $args = $node->args; Chris@17: \array_unshift($args, new Arg(\is_string($name) ? new String_($name) : $name)); Chris@17: \array_unshift($args, new Arg($node->var)); Chris@13: Chris@13: // not using prepareCall because the $node->args we started with are already Arg instances Chris@13: return new StaticCall(new FullyQualifiedName(self::SUDO_CLASS), self::METHOD_CALL, $args); Chris@13: } elseif ($node instanceof StaticPropertyFetch) { Chris@13: $class = $node->class instanceof Name ? $node->class->toString() : $node->class; Chris@13: $name = $node->name instanceof Identifier ? $node->name->toString() : $node->name; Chris@13: $args = [ Chris@17: \is_string($class) ? new String_($class) : $class, Chris@17: \is_string($name) ? new String_($name) : $name, Chris@13: ]; Chris@13: Chris@13: return $this->prepareCall(self::STATIC_PROPERTY_FETCH, $args); Chris@13: } elseif ($node instanceof Assign && $node->var instanceof StaticPropertyFetch) { Chris@13: $target = $node->var; Chris@13: $class = $target->class instanceof Name ? $target->class->toString() : $target->class; Chris@13: $name = $target->name instanceof Identifier ? $target->name->toString() : $target->name; Chris@13: $args = [ Chris@17: \is_string($class) ? new String_($class) : $class, Chris@17: \is_string($name) ? new String_($name) : $name, Chris@13: $node->expr, Chris@13: ]; Chris@13: Chris@13: return $this->prepareCall(self::STATIC_PROPERTY_ASSIGN, $args); Chris@13: } elseif ($node instanceof StaticCall) { Chris@13: $args = $node->args; Chris@13: $class = $node->class instanceof Name ? $node->class->toString() : $node->class; Chris@13: $name = $node->name instanceof Identifier ? $node->name->toString() : $node->name; Chris@17: \array_unshift($args, new Arg(\is_string($name) ? new String_($name) : $name)); Chris@17: \array_unshift($args, new Arg(\is_string($class) ? new String_($class) : $class)); Chris@13: Chris@13: // not using prepareCall because the $node->args we started with are already Arg instances Chris@13: return new StaticCall(new FullyQualifiedName(self::SUDO_CLASS), self::STATIC_CALL, $args); Chris@13: } elseif ($node instanceof ClassConstFetch) { Chris@13: $class = $node->class instanceof Name ? $node->class->toString() : $node->class; Chris@13: $name = $node->name instanceof Identifier ? $node->name->toString() : $node->name; Chris@13: $args = [ Chris@17: \is_string($class) ? new String_($class) : $class, Chris@17: \is_string($name) ? new String_($name) : $name, Chris@13: ]; Chris@13: Chris@13: return $this->prepareCall(self::CLASS_CONST_FETCH, $args); Chris@13: } Chris@13: } Chris@13: Chris@13: private function prepareCall($method, $args) Chris@13: { Chris@17: return new StaticCall(new FullyQualifiedName(self::SUDO_CLASS), $method, \array_map(function ($arg) { Chris@13: return new Arg($arg); Chris@13: }, $args)); Chris@13: } Chris@13: }