From 606819a8ad32aa33be2c060b2dcb1b4681f5a954 Mon Sep 17 00:00:00 2001 From: Tianfeng Han Date: Thu, 30 Jul 2026 20:20:25 +0800 Subject: [PATCH] Add phpt tests --- .../array/array-push-empty-unpack.phpt | 24 ++++++++++ .../static-closure-delayed-callback.phpt | 45 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 tests/compiler/array/array-push-empty-unpack.phpt create mode 100644 tests/compiler/closure/static-closure-delayed-callback.phpt diff --git a/tests/compiler/array/array-push-empty-unpack.phpt b/tests/compiler/array/array-push-empty-unpack.phpt new file mode 100644 index 00000000..a82e7656 --- /dev/null +++ b/tests/compiler/array/array-push-empty-unpack.phpt @@ -0,0 +1,24 @@ +--TEST-- +array_push retains its required array argument when an unpacked list is empty +--FILE-- + +--EXPECT-- +array(0) { +} +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} diff --git a/tests/compiler/closure/static-closure-delayed-callback.phpt b/tests/compiler/closure/static-closure-delayed-callback.phpt new file mode 100644 index 00000000..5bcda510 --- /dev/null +++ b/tests/compiler/closure/static-closure-delayed-callback.phpt @@ -0,0 +1,45 @@ +--TEST-- +static closure created in an instance method remains a valid delayed callback +--FILE-- +callback = $callback; + } + + public function invoke(): mixed + { + return ($this->callback)(); + } +} + +final class CallbackFactory +{ + public function create(): CallbackHolder + { + return new CallbackHolder( + static function (): never { + throw new LogicException('expected callback'); + }, + ); + } +} + +function main(): void +{ + $callback = (new CallbackFactory())->create(); + + try { + $callback->invoke(); + } catch (LogicException $error) { + echo $error->getMessage(), "\n"; + } +} +?> +--EXPECT-- +expected callback