MediaWiki  master
PHPErrorReporter.php
Go to the documentation of this file.
1 <?php
2 
4 
7 use Throwable;
8 
13 class PHPErrorReporter implements ErrorReporter {
14 
16  private $level;
17 
21  public function __construct( $level = E_USER_WARNING ) {
22  $this->level = $level;
23  }
24 
30  public function reportError( Throwable $error, Handler $handler, RequestInterface $request ) {
31  $firstLine = preg_split( '#$#m', (string)$error, 0 )[0];
32  trigger_error( $firstLine, $this->level );
33  }
34 
35 }
Base class for REST route handlers.
Definition: Handler.php:19
Error reporter based on php's native trigger_error() method.
reportError(Throwable $error, Handler $handler, RequestInterface $request)
An ErrorReporter internally reports an error that happened during the handling of a request.
A request interface similar to PSR-7's ServerRequestInterface.
Copyright (C) 2011-2020 Wikimedia Foundation and others.