/** * Capture output * * @param lang.Runnable r * @param array<string, string> initial * @return array<string, string> */ public static function capture(Runnable $r, $initial = []) { self::$streams = $initial; stream_wrapper_unregister('php'); stream_wrapper_register('php', __CLASS__); try { $r->run(); } finally { stream_wrapper_restore('php'); } return self::$streams; }
/** * Capture output * * @param lang.Runnable r * @param array<string, string> initial * @return array<string, string> */ public static function capture(Runnable $r, $initial = array()) { self::$streams = $initial; stream_wrapper_unregister('php'); stream_wrapper_register('php', __CLASS__); try { $r->run(); } catch (\Exception $e) { } ensure($e); stream_wrapper_restore('php'); if ($e) { throw $e; } return self::$streams; }