File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 36
36
</para >
37
37
<note >
38
38
<simpara >
39
- Due to current limitations it is not possible to switch fibers in the destructor of an object.
39
+ Prior to PHP 8.4.0, switching fibers during the execution of an object
40
+ <link linkend =" language.oop5.decon.destructor" >destructor</link > was not
41
+ allowed.
40
42
</simpara >
41
43
</note >
42
44
Original file line number Diff line number Diff line change @@ -343,6 +343,26 @@ $obj = new MyDestructableClass();
343
343
<function >exit</function >. Calling <function >exit</function > in a destructor
344
344
will prevent the remaining shutdown routines from executing.
345
345
</para >
346
+ <para >
347
+ If a destructor creates new references to its object, it will not be called
348
+ a second time when the reference count reaches zero again or during the
349
+ shutdown sequence.
350
+ </para >
351
+ <para >
352
+ As of PHP 8.4.0, when
353
+ <link linkend =" features.gc.collecting-cycles" >cycle collection</link >
354
+ occurs during the execution of a
355
+ <link linkend =" language.fibers" >Fiber</link >, the destructors of objects
356
+ scheduled for collection are executed in a separate Fiber, called the
357
+ <literal >gc_destructor_fiber</literal >.
358
+ If this Fiber is suspended, a new one will be created to execute any
359
+ remaining destructors.
360
+ The previous <literal >gc_destructor_fiber</literal > will no longer be
361
+ referenced by the garbage collector and may be collected if it is not
362
+ referenced elsewhere.
363
+ Objects whose destructor are suspended will not be collected until the
364
+ destructor returns or the Fiber itself is collected.
365
+ </para >
346
366
<note >
347
367
<para >
348
368
Destructors called during the script shutdown have HTTP headers already
You can’t perform that action at this time.
0 commit comments