Some checks failed
🚀 Build & Deploy Image / Determine Build Necessity (push) Failing after 10m14s
🚀 Build & Deploy Image / Build Runtime Base Image (push) Has been skipped
🚀 Build & Deploy Image / Build Docker Image (push) Has been skipped
🚀 Build & Deploy Image / Run Tests & Quality Checks (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Staging (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Production (push) Has been skipped
Security Vulnerability Scan / Check for Dependency Changes (push) Failing after 11m25s
Security Vulnerability Scan / Composer Security Audit (push) Has been cancelled
- Remove middleware reference from Gitea Traefik labels (caused routing issues) - Optimize Gitea connection pool settings (MAX_IDLE_CONNS=30, authentication_timeout=180s) - Add explicit service reference in Traefik labels - Fix intermittent 504 timeouts by improving PostgreSQL connection handling Fixes Gitea unreachability via git.michaelschiemer.de
119 lines
2.5 KiB
PHP
119 lines
2.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Framework\ExceptionHandling\ValueObjects;
|
|
|
|
use IteratorAggregate;
|
|
use Countable;
|
|
use Throwable;
|
|
|
|
/**
|
|
* Stack Trace Collection für strukturierte Stack Trace Darstellung
|
|
*
|
|
* Enthält eine Sammlung von StackItems und bietet Formatierungsmethoden
|
|
* für HTML, Console und JSON-Ausgabe.
|
|
*/
|
|
final readonly class StackTrace implements IteratorAggregate, Countable
|
|
{
|
|
/**
|
|
* @param StackItem[] $items
|
|
*/
|
|
public function __construct(
|
|
private array $items
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* Erstellt StackTrace aus Throwable
|
|
*/
|
|
public static function fromThrowable(Throwable $exception): self
|
|
{
|
|
$items = [];
|
|
$trace = $exception->getTrace();
|
|
|
|
foreach ($trace as $frame) {
|
|
$items[] = StackItem::fromArray($frame);
|
|
}
|
|
|
|
return new self($items);
|
|
}
|
|
|
|
/**
|
|
* Begrenzt Anzahl der Frames
|
|
*/
|
|
public function limit(int $maxFrames): self
|
|
{
|
|
return new self(array_slice($this->items, 0, $maxFrames));
|
|
}
|
|
|
|
/**
|
|
* Formatiert für HTML-Ausgabe
|
|
*/
|
|
public function formatForHtml(): string
|
|
{
|
|
$lines = [];
|
|
foreach ($this->items as $index => $item) {
|
|
$formatted = sprintf(
|
|
'#%d %s',
|
|
$index,
|
|
htmlspecialchars($item->formatForDisplay(), ENT_QUOTES | ENT_HTML5, 'UTF-8')
|
|
);
|
|
$lines[] = $formatted;
|
|
}
|
|
|
|
return implode("\n", $lines);
|
|
}
|
|
|
|
/**
|
|
* Formatiert für Console-Ausgabe
|
|
*/
|
|
public function formatForConsole(): string
|
|
{
|
|
$lines = [];
|
|
foreach ($this->items as $index => $item) {
|
|
$lines[] = sprintf(
|
|
'#%d %s',
|
|
$index,
|
|
$item->formatForDisplay()
|
|
);
|
|
}
|
|
|
|
return implode("\n", $lines);
|
|
}
|
|
|
|
/**
|
|
* Konvertiert zu Array für JSON-Serialisierung
|
|
*
|
|
* @return array<int, array<string, mixed>>
|
|
*/
|
|
public function toArray(): array
|
|
{
|
|
return array_map(
|
|
fn(StackItem $item) => $item->toArray(),
|
|
$this->items
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Gibt alle StackItems zurück
|
|
*
|
|
* @return StackItem[]
|
|
*/
|
|
public function getItems(): array
|
|
{
|
|
return $this->items;
|
|
}
|
|
|
|
public function getIterator(): \Traversable
|
|
{
|
|
return new \ArrayIterator($this->items);
|
|
}
|
|
|
|
public function count(): int
|
|
{
|
|
return count($this->items);
|
|
}
|
|
}
|
|
|