public static function closeOutputBuffers(int $targetLevel, bool $flush): void
    {
        $status = ob_get_status(true);
        $level  = \count($status);
        // PHP_OUTPUT_HANDLER_* are not defined on HHVM 3.3
        $flags = \defined('PHP_OUTPUT_HANDLER_REMOVABLE')
            ? PHP_OUTPUT_HANDLER_REMOVABLE | ($flush
                ? PHP_OUTPUT_HANDLER_FLUSHABLE
                : PHP_OUTPUT_HANDLER_CLEANABLE)
            : -1;

        while (
            $level-- > $targetLevel && ($s = $status[$level]) &&
            ($s['del'] ?? ! isset($s['flags']) || $flags === ($s['flags'] & $flags))
        ) {
            if ($flush) {
                ob_end_flush();
            } else {
                ob_end_clean();
            }
        }
    }
public static function closeOutputBuffers(int $targetLevel, bool $flush): void
    {
        $status = ob_get_status(true);
        $level  = \count($status);
        // PHP_OUTPUT_HANDLER_* are not defined on HHVM 3.3
        $flags = \defined('PHP_OUTPUT_HANDLER_REMOVABLE')
            ? PHP_OUTPUT_HANDLER_REMOVABLE | ($flush
                ? PHP_OUTPUT_HANDLER_FLUSHABLE
                : PHP_OUTPUT_HANDLER_CLEANABLE)
            : -1;

        while (
            $level-- > $targetLevel && ($s = $status[$level]) &&
            ($s['del'] ?? ! isset($s['flags']) || $flags === ($s['flags'] & $flags))
        ) {
            if ($flush) {
                ob_end_flush();
            } else {
                ob_end_clean();
            }
        }
    }
public static function closeOutputBuffers ( int $ targetLevel , bool $ flush ) : void { $ status = ob_get_status ( true ) ; $ level = \ count ( $ status ) ; // PHP_OUTPUT_HANDLER_* are not defined on HHVM 3.3 $ flags = \ defined ( 'PHP_OUTPUT_HANDLER_REMOVABLE' ) ? PHP_OUTPUT_HANDLER_REMOVABLE | ( $ flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE ) : - 1 ; while ( $ level -- > $ targetLevel && ( $ s = $ status [ $ level ] ) && ( $ s [ 'del' ] ?? ! isset ( $ s [ 'flags' ] ) || $ flags === ( $ s [ 'flags' ] & $ flags ) ) ) { if ( $ flush ) { ob_end_flush ( ) ; } else { ob_end_clean ( ) ; } } }
Cleans or flushes output buffers up to target level.

Resulting level can be greater than target level if a non-removable
buffer has been encountered.

@param int  $targetLevel The target output buffering level
@param bool $flush       Whether to flush or clean the buffers

@return void
Cleans or flushes output buffers up to target level .