Skip to content

Commit 3684fc1

Browse files
committed
Clarify that exceptions cannot be cloned
Fixes #3418
1 parent 0f4bc7c commit 3684fc1

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

language/exceptions.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ class Exception implements Throwable
419419
420420
public function __construct($message = '', $code = 0, ?Throwable $previous = null);
421421
422-
final private function __clone(); // Inhibits cloning of exceptions.
422+
private function __clone(); // Inhibits cloning of exceptions.
423423
424424
final public function getMessage(); // message of exception
425425
final public function getCode(); // code of exception

language/predefined/exception/clone.xml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
<modifier>private</modifier> <type>void</type><methodname>Exception::__clone</methodname>
1313
<void/>
1414
</methodsynopsis>
15-
<para>
16-
<classname>Exception</classname>s cannot be cloned,
17-
and attempting to do so will throw an <classname>Error</classname>.
18-
</para>
15+
<warning>
16+
<simpara>
17+
<classname>Exception</classname>s cannot be cloned.
18+
Attempting to clone an exception will throw an
19+
<classname>Error</classname>.
20+
</simpara>
21+
</warning>
1922
</refsect1>
2023

2124
<refsect1 role="parameters">
@@ -51,7 +54,10 @@
5154
<row>
5255
<entry>8.1.0</entry>
5356
<entry>
54-
<methodname>Exception::__clone</methodname> is no longer final.
57+
<methodname>Exception::__clone</methodname> is no longer
58+
<modifier>final</modifier>. However, exceptions still cannot
59+
be cloned; the <modifier>final</modifier> modifier was removed
60+
because <literal>private final</literal> is logically redundant.
5561
</entry>
5662
</row>
5763
</tbody>

0 commit comments

Comments
 (0)