Skip to content

Commit e66bb11

Browse files
committed
Test abstract class initialization failure
1 parent b1bc00a commit e66bb11

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

ext/zend_test/tests/zend_object_init_with_constructor.phpt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ class ThrowingUser {
1818
}
1919
}
2020

21+
abstract class AbstractClass {
22+
public function __construct() {
23+
return new stdClass();
24+
}
25+
}
26+
2127
class TestUser {
2228
public function __construct(int $int_param, string $string_param) {
2329
return new stdClass();
@@ -43,6 +49,12 @@ try {
4349
} catch (\Throwable $e) {
4450
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
4551
}
52+
try {
53+
$o = zend_object_init_with_constructor("AbstractClass");
54+
var_dump($o);
55+
} catch (\Throwable $e) {
56+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
57+
}
4658
try {
4759
$o = zend_object_init_with_constructor("SysvMessageQueue");
4860
var_dump($o);
@@ -88,11 +100,12 @@ Testing impossible initializations
88100
Error: Cannot instantiate interface _ZendTestInterface
89101
Error: Cannot instantiate trait _ZendTestTrait
90102
Error: Cannot instantiate enum ZendTestUnitEnum
103+
Error: Cannot instantiate abstract class AbstractClass
91104
Error: Cannot directly construct SysvMessageQueue, use msg_get_queue() instead
92105
Error: Call to private PrivateUser::__construct() from global scope
93106
Exception: Don't construct
94107
Testing param passing
95108
ArgumentCountError: Too few arguments to function TestUser::__construct(), 0 passed and exactly 2 expected
96109
TypeError: TestUser::__construct(): Argument #1 ($int_param) must be of type int, string given
97-
object(TestUser)#3 (0) {
110+
object(TestUser)#1 (0) {
98111
}

0 commit comments

Comments
 (0)