Skip to content

Commit c0dfee5

Browse files
committed
Fix PHP 7 compatibility
ref #111
1 parent b5ead84 commit c0dfee5

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

src/PhpConsole/Dispatcher/Errors.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public function dispatchError($code = null, $text = null, $file = null, $line =
6868

6969
/**
7070
* Send exception message to client
71-
* @param \Exception $exception
71+
* @param \Exception|\Throwable $exception
7272
*/
73-
public function dispatchException(\Exception $exception) {
73+
public function dispatchException($exception) {
7474
if($this->isActive()) {
7575
if($this->dispatchPreviousExceptions && $exception->getPrevious()) {
7676
$this->dispatchException($exception->getPrevious());

src/PhpConsole/EvalProvider.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public function evaluate($code) {
4141
try {
4242
$result->return = static::executeCode($code, $this->sharedVars);
4343
}
44+
catch(\Throwable $exception) {
45+
$result->exception = $exception;
46+
}
4447
catch(\Exception $exception) {
4548
$result->exception = $exception;
4649
}

src/PhpConsole/Handler.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,9 @@ protected function isHandlingDisabled() {
208208

209209
/**
210210
* Handle exception object
211-
* @param \Exception $exception
211+
* @param \Exception|\Throwable $exception
212212
*/
213-
public function handleException(\Exception $exception) {
213+
public function handleException($exception) {
214214
if(!$this->isStarted || $this->isHandlingDisabled()) {
215215
return;
216216
}
@@ -221,6 +221,9 @@ public function handleException(\Exception $exception) {
221221
call_user_func($this->oldExceptionsHandler, $exception);
222222
}
223223
}
224+
catch(\Throwable $internalException) {
225+
$this->handleException($internalException);
226+
}
224227
catch(\Exception $internalException) {
225228
$this->handleException($internalException);
226229
}

src/PhpConsole/OldVersionAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function handleError($code = null, $message = null, $file = null, $line =
9797
$this->getHandler()->handleError($code, $message, $file, $line, null, 1);
9898
}
9999

100-
public function handleException(\Exception $exception) {
100+
public function handleException($exception) {
101101
$this->getHandler()->handleException($exception);
102102
}
103103

src/PhpConsole/PsrLogger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function log($level, $message, array $context = array()) {
6262
$this->connector->getDebugDispatcher()->dispatchDebug($message, static::$debugLevels[$level], $this->ignoreTraceCalls);
6363
}
6464
elseif(isset(static::$errorsLevels[$level])) {
65-
if(isset($context['exception']) && $context['exception'] instanceof \Exception) {
65+
if(isset($context['exception']) && ($context['exception'] instanceof \Exception || $context['exception'] instanceof \Throwable)) {
6666
$this->connector->getErrorsDispatcher()->dispatchException($context['exception']);
6767
}
6868
else {

0 commit comments

Comments
 (0)