/** * Use pager set in the environment (i.e. $_ENV['PAGER']). * * @param string $output Output (from the output buffer). * @param int $mode Mode (from the output buffer). * @param string $type Type. Please, see self::LESS or self::MORE. * @return string */ public static function pager($output, $mode, $type = null) { static $process = null; if ($mode & PHP_OUTPUT_HANDLER_START) { $pager = null !== $type ? Console\Processus::locate($type) : (isset($_ENV['PAGER']) ? $_ENV['PAGER'] : null); if (null === $pager) { return $output; } $process = new Console\Processus($pager, null, [['pipe', 'r']]); $process->open(); } $process->writeAll($output); if ($mode & PHP_OUTPUT_HANDLER_FINAL) { $process->close(); } return null; }