Skip to content

Commit f8522f3

Browse files
Small refactor in ExceptionReporter to avoid error suppression operator (#7)
* Temporarily added PHP 7.4 to Travis * Set up Codeception * Ported tests from mindplay/testies to Codeception 5. Also adjusted tests breaking on PHP 7.4+ * Updated composer.lock * Changed travis versions to 8.0 and 8.1 * Removed legacy flag from composer command. Changed PHP requirements in composer.json to >=8.0 and removed phpbrowser package * Removing composer.lock to avoid locking symfony packages at php >=8.1 * Small refactor in ExceptionReporter to avoid error suppression operator Co-authored-by: Hans Erik Jepsen <[email protected]>
1 parent 871ee0d commit f8522f3

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/Extensions/ExceptionReporter.php

+16-7
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ protected function createStackTrace(array $trace): StackTrace
162162
{
163163
$frames = [];
164164

165-
foreach ($trace as $index => $entry) {
165+
foreach ($trace as $entry) {
166166
$frames[] = $this->createStackFrame($entry);
167167
}
168168

@@ -178,13 +178,9 @@ protected function createStackTrace(array $trace): StackTrace
178178
*/
179179
protected function createStackFrame(array $entry): StackFrame
180180
{
181-
$filename = isset($entry["file"])
182-
? $entry["file"]
183-
: self::NO_FILE;
181+
$filename = $entry["file"] ?? self::NO_FILE;
184182

185-
$function = isset($entry["class"])
186-
? $entry["class"] . @$entry["type"] . @$entry["function"]
187-
: @$entry["function"];
183+
$function = $this->getFunctionFromEntry($entry);
188184

189185
$lineno = array_key_exists("line", $entry)
190186
? (int) $entry["line"]
@@ -430,4 +426,17 @@ protected function formatValue($value): string
430426

431427
return "{{$type}}"; // "unknown type" and possibly unsupported (future) types
432428
}
429+
430+
private function getFunctionFromEntry(array $entry)
431+
{
432+
$function = $entry["function"] ?? "";
433+
$class = $entry["class"] ?? "";
434+
$type = $entry["type"] ?? "";
435+
436+
if ($class !== "") {
437+
return $class . $type . $function;
438+
} else {
439+
return $function;
440+
}
441+
}
433442
}

0 commit comments

Comments
 (0)