Skip to content

Commit

Permalink
Small refactor in ExceptionReporter to avoid error suppression operat…
Browse files Browse the repository at this point in the history
…or (#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]>
  • Loading branch information
thomasnordahl-dk and vortrixs authored Sep 13, 2022
1 parent 871ee0d commit f8522f3
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/Extensions/ExceptionReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ protected function createStackTrace(array $trace): StackTrace
{
$frames = [];

foreach ($trace as $index => $entry) {
foreach ($trace as $entry) {
$frames[] = $this->createStackFrame($entry);
}

Expand All @@ -178,13 +178,9 @@ protected function createStackTrace(array $trace): StackTrace
*/
protected function createStackFrame(array $entry): StackFrame
{
$filename = isset($entry["file"])
? $entry["file"]
: self::NO_FILE;
$filename = $entry["file"] ?? self::NO_FILE;

$function = isset($entry["class"])
? $entry["class"] . @$entry["type"] . @$entry["function"]
: @$entry["function"];
$function = $this->getFunctionFromEntry($entry);

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

return "{{$type}}"; // "unknown type" and possibly unsupported (future) types
}

private function getFunctionFromEntry(array $entry)
{
$function = $entry["function"] ?? "";
$class = $entry["class"] ?? "";
$type = $entry["type"] ?? "";

if ($class !== "") {
return $class . $type . $function;
} else {
return $function;
}
}
}

0 comments on commit f8522f3

Please sign in to comment.