|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-09-20 10:38 UTC] nikic@php.net
-Status: Open
+Status: Wont fix
[2013-09-20 10:38 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 00:00:01 2025 UTC |
Description: ------------ There already exists __destruct(), but if you need to clean up mappings that use an object's identifier to cache results etc, there isn't a smooth way of doing this. It would be nice to tie a callback to an object's lifespan. The catch would of course be that you can't reference the object in the callback because of circular references, or maybe you can, I'm not that intimate with PHP's garbage collection. Test script: --------------- $x = (object)[]; register_destructor($x,function($x){ // extra cleanup operations with $x, // or instead an spl_object_hash() could be precalculated and closed over // if using $x would cause circular death });