Empty Catch Block (ARCH7150)
Ce contenu n’est pas encore disponible dans votre langue.
Key php.logging.empty-catch-block · Severity error · Category logging
A catch handler with an empty body (or only comments) silently swallows the exception and hides the failure, making the bug impossible to diagnose.
Incorrect
Section titled “Incorrect”<?phptry { $this->processPayment($order);} catch (\Throwable $e) { // ignore}Correct
Section titled “Correct”<?phptry { $this->processPayment($order);} catch (PaymentException $e) { $this->logger->error('Payment processing failed', ['exception' => $e]); throw $e;}Log the exception at minimum, or rethrow it; never swallow it silently.