Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Register a function for execution on shutdown
<?php register_shutdown_function(callable $callback, mixed ...$args): void
<?php set_exception_handler($this->forwardsTo('handleException'));
register_shutdown_function($this->forwardsTo('handleShutdown'));
if (! $app->environment('testing')) {
ini_set('display_errors', 'Off');
<?php $output,
);
register_shutdown_function(fn () => $kernel->shutdown());
foreach (self::BOOTSTRAPPERS as $bootstrapper) {
$bootstrapper = Container::getInstance()->get($bootstrapper);
<?php test('deletes file after all', function () use ($file) {
file_put_contents($file, 'foo');
$this->assertFileExists($file);
register_shutdown_function(function () {
});
});
<?php $foo->afterAll = true;
});
register_shutdown_function(function () use ($foo) {
assertFalse($foo->beforeAll);
assertFalse($foo->beforeEach);
assertFalse($foo->afterEach);
assertFalse($foo->afterAll);
});
<?php $shutdownRegistered = true;
register_shutdown_function(function () {
$lastError = error_get_last();
if ($lastError && $lastError['message'] &&
(strpos($lastError['message'], 'Allowed memory') !== false /*Zend PHP out of memory error*/ ||
strpos($lastError['message'], 'exceeded memory') !== false /*HHVM out of memory errors*/)) {
echo "\n". 'Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.';
}
});
}
$this->io = new NullIO();
<?php if (self::$scheduler === null || self::$scheduler->isTerminated()) {
self::$scheduler = new \Fiber(static fn() => Loop::run());
\register_shutdown_function(static function (): void {
if (self::$scheduler->isSuspended()) {
self::$scheduler->resume();
}
});
}
return (self::$scheduler->isStarted() ? self::$scheduler->resume() : self::$scheduler->start())();
<?php });
$stopped =& self::$stopped;
register_shutdown_function(function () use ($loop, &$hasRun, &$stopped) {
$error = error_get_last();
if ((isset($error['type']) ? $error['type'] : 0) & (E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR)) {
return;
}
if (!$hasRun && !$stopped) {
$loop->run();
}
});
return self::$instance;