code: public function shutdownFunction()
      {
          $error = error_get_last(); // note, stack trace is included in $error["message"]
  
          if (!isset($error)) {
              return;
          }
  
          $fatalErrorTypes = [E_USER_ERROR, E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING];
          if (in_array($error["type"], $fatalErrorTypes)) {
              $message = $this->generateMessageBodyCommon($error["type"], $error["message"], $error["file"], $error["line"]);
              $this->handleError($message, $error["type"], true);
          }
      }
docs: used in register_shutdown_function to see if a fatal error has occurred and handle it.
  note, this does not occur often in php7, as almost all errors are now exceptions and will be caught by the registered exception handler. fatal errors can still occur for conditions like out of memory: https://trowski.com/2015/06/24/throwable-exceptions-and-errors-in-php7/
  see also https://stackoverflow.com/questions/10331084/error-logging-in-a-smooth-way