diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index 55061c2d..af85c588 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -3178,7 +3178,7 @@ class CompilerBase extends \PhpAot\Core\Translator protected function parsePrint(Expr\Print_ $expr): string { - return 'php::echo(' . $this->parseExpr($expr->expr) . ')'; + return 'php::print(' . $this->parseExpr($expr->expr) . ')'; } protected function parseDo(Node\Stmt\Do_ $v): string diff --git a/tests/aot/functions/print.phpt b/tests/aot/functions/print.phpt new file mode 100644 index 00000000..ec512144 --- /dev/null +++ b/tests/aot/functions/print.phpt @@ -0,0 +1,30 @@ +--TEST-- +any +--FILE-- +p); + } +} + +readonly class B implements I { + function __construct(private array $i) {} + function o(): string { + return sprintf("%d its", count($this->i)); + } +} + +function main(): void { + $x = [new G(1999.99), new B(["A","B","C"])]; + array_map(fn(I $i) => print($i->o() . "\n"), $x); +} +?> +--EXPECT-- +$1999.99 +3 its