Syntax error in the PHP code generated from the ASTs of New FuncCall and New MethodCall
Chance-fyi opened this issue · comments
Chance commented
I need to convert this AST to PHP code, but I got syntax errors in the generated code.
$node = new New_(new FuncCall(new Name('get_class'), [
new Arg(new Variable('object')),
]), [
new Arg(new Variable('a')),
new Arg(new Variable('b')),
]);
echo (new Standard)->prettyPrint([$node]) . PHP_EOL;
// Expected
// new (get_class($object))($a, $b)
// Actual
// new get_class($object)($a, $b)
$node = new New_(new MethodCall(new Variable('this'), 'className', [
new Arg(new Variable('a')),
]), [
new Arg(new Variable('b')),
new Arg(new Variable('c')),
]);
echo (new Standard)->prettyPrint([$node]) . PHP_EOL;
// Expected
// new ($this->className($a))($b, $c)
// Actual
// new $this->className($a)($b, $c)
Nikita Popov commented
This was already fixed on the master branch, I have cherry-picked the relevant commits.