[php-src] PHP-8.5: zend_test: add additional tests with zend_object_init_with_constructor()
| From: | Gina Peter Banyard | Date: | Sun, 08 Nov 2026 07:45:28 +0000 |
| Subject: | [php-src] PHP-8.5: zend_test: add additional tests with zend_object_init_with_constructor() | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143414@lists.php.net to get a copy of this message | ||
Author: Gina Peter Banyard (Girgias)
Date: 2026-11-08T07:32:57Z
Commit: https://github.com/php/php-src/commit/3d8d44caf999086ae416d977f1f24398692aae72
Raw diff: https://github.com/php/php-src/commit/3d8d44caf999086ae416d977f1f24398692aae72.diff
zend_test: add additional tests with zend_object_init_with_constructor()
Changed paths:
M ext/zend_test/tests/zend_object_init_with_constructor_classes_without_constructor.phpt
Diff:
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 1adaaafaa195..9d113fa6084f 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 @@ try {
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 @@ Using new:
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) {
+}