Commit 3d8d44caf99 for php
commit 3d8d44caf999086ae416d977f1f24398692aae72
Author: Gina Peter Banyard <girgias@php.net>
Date: Sat Nov 7 17:36:35 2026 +0000
zend_test: add additional tests with zend_object_init_with_constructor()
diff --git a/ext/zend_test/tests/zend_object_init_with_constructor_classes_without_constructor.phpt b/ext/zend_test/tests/zend_object_init_with_constructor_classes_without_constructor.phpt
index 1adaaafaa19..9d113fa6084 100644
--- a/ext/zend_test/tests/zend_object_init_with_constructor_classes_without_constructor.phpt
+++ b/ext/zend_test/tests/zend_object_init_with_constructor_classes_without_constructor.phpt
@@ -98,6 +98,83 @@ public function __destruct() {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
+echo "\n#### Splatting arrays with string key ####\n";
+$a = ['unknown' => "hello"];
+echo "Userland class:\n";
+echo "Using new:\n";
+try {
+ $o = new TestUserWithoutConstructor(...$a);
+ var_dump($o);
+ unset($o);
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+echo "Using zend_object_init_with_constructor():\n";
+try {
+ $o = zend_object_init_with_constructor("TestUserWithoutConstructor", ...$a);
+ var_dump($o);
+ unset($o);
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+
+echo "Internal class:\n";
+echo "Using new:\n";
+try {
+ $o = new _ZendTestMagicCall(...$a);
+ var_dump($o);
+ unset($o);
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+echo "Using zend_object_init_with_constructor():\n";
+try {
+ $o = zend_object_init_with_constructor("_ZendTestMagicCall", ...$a);
+ var_dump($o);
+ unset($o);
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+
+
+echo "\n#### Splatting arrays with int key ####\n";
+$a = [1 => "hello"];
+echo "Userland class:\n";
+echo "Using new:\n";
+try {
+ $o = new TestUserWithoutConstructor(...$a);
+ var_dump($o);
+ unset($o);
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+echo "Using zend_object_init_with_constructor():\n";
+try {
+ $o = zend_object_init_with_constructor("TestUserWithoutConstructor", ...$a);
+ var_dump($o);
+ unset($o);
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+
+echo "Internal class:\n";
+echo "Using new:\n";
+try {
+ $o = new _ZendTestMagicCall(...$a);
+ var_dump($o);
+ unset($o);
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+echo "Using zend_object_init_with_constructor():\n";
+try {
+ $o = zend_object_init_with_constructor("_ZendTestMagicCall", ...$a);
+ var_dump($o);
+ unset($o);
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+
?>
--EXPECT--
#### Passing no args ####
@@ -147,3 +224,33 @@ public function __destruct() {
Error: Unknown named parameter $unknown_param
Using zend_object_init_with_constructor():
Error: Unknown named parameter $unknown_param
+
+#### Splatting arrays with string key ####
+Userland class:
+Using new:
+Error: Unknown named parameter $unknown
+Using zend_object_init_with_constructor():
+Error: Unknown named parameter $unknown
+Internal class:
+Using new:
+Error: Unknown named parameter $unknown
+Using zend_object_init_with_constructor():
+Error: Unknown named parameter $unknown
+
+#### Splatting arrays with int key ####
+Userland class:
+Using new:
+object(TestUserWithoutConstructor)#2 (0) {
+}
+Destructor for TestUserWithoutConstructor
+Using zend_object_init_with_constructor():
+object(TestUserWithoutConstructor)#2 (0) {
+}
+Destructor for TestUserWithoutConstructor
+Internal class:
+Using new:
+object(_ZendTestMagicCall)#2 (0) {
+}
+Using zend_object_init_with_constructor():
+object(_ZendTestMagicCall)#2 (0) {
+}