callback = $callback; } /** * Trigger a scoped callback and destroy it. * This is the same is just setting it to null. * * @param ScopedCallback $sc */ public static function consume( ScopedCallback &$sc = null ) { $sc = null; } /** * Destroy a scoped callback without triggering it * * @param ScopedCallback $sc */ public static function cancel( ScopedCallback &$sc = null ) { if ( $sc ) { $sc->callback = null; } $sc = null; } /** * Trigger the callback when this leaves scope */ function __destruct() { if ( $this->callback !== null ) { call_user_func( $this->callback ); } } }