From bdea6f77cc989240a9bfc90e92ea3b5e58ab979d Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Tue, 13 Jan 2026 19:43:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=B1=BB=E7=9A=84=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/call3.php | 21 ++++++++++++++ tests/core/classes/__call_001.phpt | 41 ++++++++++++++++++++++++++++ tests/core/classes/__call_002.phpt | 20 ++++++++++++++ tests/core/classes/__call_003.phpt | 31 +++++++++++++++++++++ tests/core/classes/__call_004.phpt | 44 ++++++++++++++++++++++++++++++ tests/core/classes/__call_005.phpt | 40 +++++++++++++++++++++++++++ tests/core/classes/ctor_dtor.phpt | 39 ++++++++++++++++++++++++++ 7 files changed, 236 insertions(+) create mode 100644 examples/call3.php create mode 100644 tests/core/classes/__call_001.phpt create mode 100644 tests/core/classes/__call_002.phpt create mode 100644 tests/core/classes/__call_003.phpt create mode 100644 tests/core/classes/__call_004.phpt create mode 100644 tests/core/classes/__call_005.phpt create mode 100644 tests/core/classes/ctor_dtor.phpt diff --git a/examples/call3.php b/examples/call3.php new file mode 100644 index 00000000..086431c2 --- /dev/null +++ b/examples/call3.php @@ -0,0 +1,21 @@ +f($a); + $c->f($b); + + var_dump($a, $b); +} + diff --git a/tests/core/classes/__call_001.phpt b/tests/core/classes/__call_001.phpt new file mode 100644 index 00000000..84902429 --- /dev/null +++ b/tests/core/classes/__call_001.phpt @@ -0,0 +1,41 @@ +--TEST-- +ZE2 __call() +--FILE-- +x; + } +} + +function main() { + $foo = new Caller(); + $a = $foo->test(1, '2', 3.4, true); + var_dump($a); +} +?> +--EXPECT-- +Method test called: +array(4) { + [0]=> + int(1) + [1]=> + string(1) "2" + [2]=> + float(3.4) + [3]=> + bool(true) +} +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} diff --git a/tests/core/classes/__call_002.phpt b/tests/core/classes/__call_002.phpt new file mode 100644 index 00000000..ecf89d24 --- /dev/null +++ b/tests/core/classes/__call_002.phpt @@ -0,0 +1,20 @@ +--TEST-- +ZE2 __call() signature check +--SKIPIF-- + +--FILE-- +test(); +} + +?> +--EXPECTF-- +Fatal error: Method Test::__call() must take exactly 2 arguments in %s__call_002.php on line %d diff --git a/tests/core/classes/__call_003.phpt b/tests/core/classes/__call_003.phpt new file mode 100644 index 00000000..997740a6 --- /dev/null +++ b/tests/core/classes/__call_003.phpt @@ -0,0 +1,31 @@ +--TEST-- +Force pass-by-reference to __call (Incompatible) +--FILE-- +f($a); + $c->f($b); + + var_dump($a, $b); +} +?> +--EXPECT-- +array(1) { + [0]=> + string(7) "changed" +} +array(1) { + [0]=> + string(7) "changed" +} diff --git a/tests/core/classes/__call_004.phpt b/tests/core/classes/__call_004.phpt new file mode 100644 index 00000000..3dc2d609 --- /dev/null +++ b/tests/core/classes/__call_004.phpt @@ -0,0 +1,44 @@ +--TEST-- +When __call() is invoked via ::, ensure current scope's __call() is favoured over the specified class's __call(). +--SKIPIF-- + +--FILE-- +test(); +} +?> +--EXPECT-- +In B::__call(test1, array(1,a)) +object(B)#1 (0) { +} +In B::__call(test2, array(1,a)) +object(B)#1 (0) { +} +In B::__call(test3, array(1,a)) +object(B)#1 (0) { +} +In B::__call(test4, array(1,a)) +object(B)#1 (0) { +} diff --git a/tests/core/classes/__call_005.phpt b/tests/core/classes/__call_005.phpt new file mode 100644 index 00000000..589d0f5f --- /dev/null +++ b/tests/core/classes/__call_005.phpt @@ -0,0 +1,40 @@ +--TEST-- +When __call() is invoked via ::, ensure private implementation of __call() in superclass is accessed without error. +--SKIPIF-- + +--FILE-- +test(); +} +?> +--EXPECTF-- +Warning: The magic method A::__call() must have public visibility in %s__call_005.php on line 3 +In A::__call(test1, array(1,a)) +object(B)#1 (0) { +} +In A::__call(test2, array(1,a)) +object(B)#1 (0) { +} +In A::__call(test3, array(1,a)) +object(B)#1 (0) { +} +In A::__call(test4, array(1,a)) +object(B)#1 (0) { +} diff --git a/tests/core/classes/ctor_dtor.phpt b/tests/core/classes/ctor_dtor.phpt new file mode 100644 index 00000000..bcd73430 --- /dev/null +++ b/tests/core/classes/ctor_dtor.phpt @@ -0,0 +1,39 @@ +--TEST-- +ZE2 The new constructor/destructor is called +--FILE-- +__construct(); + unset($t); + $t = new late(); + //unset($t); delay to end of script + + echo "Done\n"; +} +?> +--EXPECT-- +early::__construct +early::__construct +early::__destruct +late::__construct +Done +late::__destruct