Skip to content

Commit 8f2e65b

Browse files
committed
Add destructors
1 parent e66bb11 commit 8f2e65b

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

ext/zend_test/tests/zend_object_init_with_constructor.phpt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,36 @@ class PrivateUser {
1010
private function __construct() {
1111
return new stdClass();
1212
}
13+
public function __destruct() {
14+
echo 'Destructor for ', __CLASS__, PHP_EOL;
15+
}
1316
}
1417

1518
class ThrowingUser {
1619
public function __construct() {
1720
throw new Exception("Don't construct");
1821
}
22+
public function __destruct() {
23+
echo 'Destructor for ', __CLASS__, PHP_EOL;
24+
}
1925
}
2026

2127
abstract class AbstractClass {
2228
public function __construct() {
2329
return new stdClass();
2430
}
31+
public function __destruct() {
32+
echo 'Destructor for ', __CLASS__, PHP_EOL;
33+
}
2534
}
2635

2736
class TestUser {
2837
public function __construct(int $int_param, string $string_param) {
2938
return new stdClass();
3039
}
40+
public function __destruct() {
41+
echo 'Destructor for ', __CLASS__, PHP_EOL;
42+
}
3143
}
3244

3345
echo "Testing impossible initializations\n";
@@ -102,10 +114,15 @@ Error: Cannot instantiate trait _ZendTestTrait
102114
Error: Cannot instantiate enum ZendTestUnitEnum
103115
Error: Cannot instantiate abstract class AbstractClass
104116
Error: Cannot directly construct SysvMessageQueue, use msg_get_queue() instead
117+
Destructor for PrivateUser
105118
Error: Call to private PrivateUser::__construct() from global scope
119+
Destructor for ThrowingUser
106120
Exception: Don't construct
107121
Testing param passing
122+
Destructor for TestUser
108123
ArgumentCountError: Too few arguments to function TestUser::__construct(), 0 passed and exactly 2 expected
124+
Destructor for TestUser
109125
TypeError: TestUser::__construct(): Argument #1 ($int_param) must be of type int, string given
110-
object(TestUser)#1 (0) {
126+
object(TestUser)#3 (0) {
111127
}
128+
Destructor for TestUser

0 commit comments

Comments
 (0)