Swallowed Exception (ARCH7151)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Key php.logging.swallowed-exception · Severity warning · Category logging
Catching an exception and silently returning null/false hides the failure. Unlike an empty block, the body exists but the exception is still discarded.
Incorrect
Section titled “Incorrect”<?phppublic function loadConfig(string $path): ?array{ try { return json_decode(file_get_contents($path), true); } catch (\Throwable $e) { return null; }}Correct
Section titled “Correct”<?phppublic function loadConfig(string $path): ?array{ try { return json_decode(file_get_contents($path), true); } catch (\Throwable $e) { $this->logger->error('Config load failed', ['path' => $path, 'exception' => $e]); throw $e; }}Log or rethrow the exception instead of silently converting it to a return value.