Skip to content

Commit 7dbeab5

Browse files
author
Oleksii Didenko
committed
Fix non-object warning
1 parent 3ec914b commit 7dbeab5

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/PHPUnit/Listeners/NaughtyTestListener.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,14 @@ private function formatValue($value)
205205
try {
206206
$encoded = json_encode($value, true);
207207
if (json_last_error() !== 0) {
208-
$encoded = sprintf('Object<%s>', get_class($value));
208+
throw new \Exception(json_last_error_msg());
209209
}
210210
} catch (Exception $exception) {
211-
$encoded = sprintf('Object<%s>', get_class($value));
211+
if (is_object($value)) {
212+
$encoded = sprintf('Object<%s>', get_class($value));
213+
} else {
214+
$encoded = gettype($value);
215+
}
212216
}
213217
}
214218

0 commit comments

Comments
 (0)