[DOC-CVS] [doc-en] master: Closure: Mention non-serializability of Closure objects (#5363)

[email protected] (Mikhail Alferov via GitHub) Sat, 16 May 2026 08:09:22 +0000
Newsgroups php.doc.cvs
Message-ID <[email protected]>
Author: Mikhail Alferov (mmalferov)
Committer: GitHub (web-flow)
Pusher: jordikroon
Date: 2026-05-16T10:09:19+02:00

Commit: https://github.com/php/doc-en/commit/a97672ab04d97f510faee2abe8d961014f77f96d
Raw diff: https://github.com/php/doc-en/commit/a97672ab04d97f510faee2abe8d961014f77f96d.diff

Closure: Mention non-serializability of Closure objects (#5363)

* Mention non-serializability of Closure objects

Co-authored-by: Jordi Kroon <[email protected]>

Changed paths:
  M  language/predefined/closure.xml


Diff:

diff --git a/language/predefined/closure.xml b/language/predefined/closure.xml
index 246019789b89..dafaee47dbfd 100644
--- a/language/predefined/closure.xml
+++ b/language/predefined/closure.xml
@@ -76,6 +76,17 @@
    </informaltable>
   </section>
 
+  <section role="notes">
+   &reftitle.notes;
+   <note>
+    <simpara>
+     <classname>Closure</classname> objects cannot be serialized
+     as closures may contain bound variables and a specific execution context.
+     Attempting to serialize a closure will throw an <exceptionname>Exception</exceptionname>.
+    </simpara>
+   </note>
+  </section>
+
  </partintro>
 
  &language.predefined.closure.construct;