texthtml/object-reaper

对象被销毁时收到通知

dev-main 2024-09-10 22:28 UTC

This package is auto-updated.

Last update: 2024-09-20 13:31:27 UTC


README

允许您注册回调,当对象被销毁时会被调用。

安装

composer req texthtml/object-reaper

用法

$a = (object) [];

// Attach a callback to any object
// It will be called when the object is destroyed

Reaper::watch($a, function () { echo "Good Bye"; });

// "Good bye" will be printed when $a is destroyed