proteins/deferred

Ensure deferred execution of code, even in case of fatal error.

Installs: 4

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/proteins/deferred

1.0.3 2019-05-28 14:30 UTC

This package is auto-updated.

Last update: 2025-09-29 02:21:14 UTC


README

Protein | Deferred

Ensure deferred execution of code, even in case of fatal error.

Install

composer require proteins/deferred

Require the class via :

use Proteins\Deferred;

Run code at function end or in case of error.

The passed callback will be queued for execution on Deferred object destruction.

function duel(){
	echo "A: I will have the last word!\n";

	echo "B: Wanna bet?\n";

	$defer_B_last_word = new Deferred(function(){
		echo "B: Haha! Gotcha!\n";
	});
	
	die("A: I WIN!\n"); // Hahaha!

	echo "B: WUT?\n";
}

duel();
A: I will have the last word!
B: Wanna bet?
A: I WIN!
B: Haha! Gotcha!