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