Skip to content

Commit e7131a4

Browse files
committed
Remove redundant Exception::__clone() method
Exceptions already prohibit cloning by setting clone_obj to NULL (which is integrated with reflection). No need to additionally define a dummy __clone() method.
1 parent 28edeb2 commit e7131a4

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

Zend/zend_exceptions.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,6 @@ static zend_object *zend_error_exception_new(zend_class_entry *class_type) /* {{
251251
}
252252
/* }}} */
253253

254-
/* {{{ proto Exception|Error Exception|Error::__clone()
255-
Clone the exception object */
256-
ZEND_COLD ZEND_METHOD(exception, __clone)
257-
{
258-
/* Should never be executable */
259-
zend_throw_exception(NULL, "Cannot clone object using __clone()", 0);
260-
}
261-
/* }}} */
262-
263254
/* {{{ proto Exception|Error::__construct(string message, int code [, Throwable previous])
264255
Exception constructor */
265256
ZEND_METHOD(exception, __construct)
@@ -772,7 +763,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_exception___construct, 0, 0, 0)
772763
ZEND_END_ARG_INFO()
773764

774765
static const zend_function_entry default_exception_functions[] = {
775-
ZEND_ME(exception, __clone, NULL, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
776766
ZEND_ME(exception, __construct, arginfo_exception___construct, ZEND_ACC_PUBLIC)
777767
ZEND_ME(exception, __wakeup, NULL, ZEND_ACC_PUBLIC)
778768
ZEND_ME(exception, getMessage, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)

sapi/cli/tests/005.phpt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ var_dump(`"$php" -n --rc exception`);
1515

1616
echo "Done\n";
1717
?>
18-
--EXPECT--
18+
--EXPECTF--
1919
string(40) "Exception: Class unknown does not exist
2020
"
21-
string(183) "Class [ <internal:Core> class stdClass ] {
21+
string(%d) "Class [ <internal:Core> class stdClass ] {
2222

2323
- Constants [0] {
2424
}
@@ -37,7 +37,7 @@ string(183) "Class [ <internal:Core> class stdClass ] {
3737
}
3838

3939
"
40-
string(1607) "Class [ <internal:Core> class Exception implements Throwable ] {
40+
string(%d) "Class [ <internal:Core> class Exception implements Throwable ] {
4141

4242
- Constants [0] {
4343
}
@@ -58,10 +58,7 @@ string(1607) "Class [ <internal:Core> class Exception implements Throwable ] {
5858
Property [ <default> private $previous ]
5959
}
6060

61-
- Methods [11] {
62-
Method [ <internal:Core> final private method __clone ] {
63-
}
64-
61+
- Methods [10] {
6562
Method [ <internal:Core, ctor> public method __construct ] {
6663

6764
- Parameters [3] {

0 commit comments

Comments
 (0)