Skip to content

Commit 3c4359e

Browse files
authored
Merge pull request #34 from Kharhamel/fix/php7-compatibility
compatibility with php 7 (still compatible with 5.3)
2 parents 9f3ce9e + 2d82184 commit 3c4359e

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/Mouf/Mvc/Splash/Routers/ExceptionRouter.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,24 @@ public function __construct(Http500HandlerInterface $errorController, LoggerInte
4747
/**
4848
* Actually handle the exception depending.
4949
*
50-
* @param \Exception $e
50+
* @param \Throwable $throwable
5151
*
5252
* @return ResponseInterface
5353
*/
54-
private function handleException(\Exception $e, Request $request)
54+
private function handleException($throwable, Request $request)
5555
{
5656
if ($this->log != null) {
5757
$this->log->error('Exception thrown inside a controller.', array(
58-
'exception' => $e,
58+
'exception' => $throwable,
5959
));
6060
} else {
6161
// If no logger is set, let's log in PHP error_log
62-
error_log($e->getMessage().' - '.$e->getTraceAsString());
62+
error_log($throwable->getMessage().' - '.$throwable->getTraceAsString());
6363
}
6464

6565
$response = SplashUtils::buildControllerResponse(
66-
function () use ($e, $request) {
67-
return $this->errorController->serverError($e, $request);
66+
function () use ($throwable, $request) {
67+
return $this->errorController->serverError($throwable, $request);
6868
}
6969
);
7070

src/Mouf/Mvc/Splash/Utils/ExceptionUtils.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ private static function getHTMLBackTrace($backtrace)
5151
* Function called to display an exception if it occurs.
5252
* It will make sure to purge anything in the buffer before calling the exception displayer.
5353
*
54-
* @param Exception $exception
54+
* @param \Throwable $throwable
5555
*/
56-
public static function getHtmlForException(\Exception $exception)
56+
public static function getHtmlForException($throwable)
5757
{
5858
//global $sys_error_reporting_mail;
5959
//global $sys_error_messages;
@@ -63,9 +63,9 @@ public static function getHtmlForException(\Exception $exception)
6363

6464
$display_errors = ini_get('display_errors');
6565
$color = '#FF0000';
66-
$type = 'Uncaught '.get_class($exception);
67-
if ($exception->getCode() != null) {
68-
$type .= ' with error code '.$exception->getCode();
66+
$type = 'Uncaught '.get_class($throwable);
67+
if ($throwable->getCode() != null) {
68+
$type .= ' with error code '.$throwable->getCode();
6969
}
7070

7171
$msg .= "<tr><td colspan='3' style='background-color:$color; color:white; text-align:center'><b>$type</b></td></tr>";
@@ -74,10 +74,10 @@ public static function getHtmlForException(\Exception $exception)
7474
$msg .= "<td style='background-color:#AAAAAA; color:white; text-align:center'>File</td>";
7575
$msg .= "<td style='background-color:#AAAAAA; color:white; text-align:center'>Line</td></tr>";
7676

77-
$msg .= "<tr><td style='background-color:#EEEEEE; color:black'><b>".nl2br($exception->getMessage()).'</b></td>';
78-
$msg .= "<td style='background-color:#EEEEEE; color:black'>".self::displayFile($exception->getFile()).'</td>';
79-
$msg .= "<td style='background-color:#EEEEEE; color:black'>".$exception->getLine().'</td></tr>';
80-
$msg .= self::getHTMLBackTrace($exception->getTrace());
77+
$msg .= "<tr><td style='background-color:#EEEEEE; color:black'><b>".nl2br($throwable->getMessage()).'</b></td>';
78+
$msg .= "<td style='background-color:#EEEEEE; color:black'>".self::displayFile($throwable->getFile()).'</td>';
79+
$msg .= "<td style='background-color:#EEEEEE; color:black'>".$throwable->getLine().'</td></tr>';
80+
$msg .= self::getHTMLBackTrace($throwable->getTrace());
8181
$msg .= '</table>';
8282

8383
return $msg;

0 commit comments

Comments
 (0)