phanalist

E0011: Detect Error Suppression Symbol (@)

In plain English: The @ symbol in PHP suppresses errors and warnings from being reported. This rule flags and forbids its use.

Why it matters: Using @ hides underlying problems (such as failed file reads, undefined indexes, or connection errors). Instead of fixing the root cause or handling exceptions/conditionals properly, error suppression sweeps bugs under the rug, making debugging extremely difficult when things fail silently in production.

❌ The Bad Example

// Suppressing errors when reading a file or calling a risky function
$content = @file_get_contents($filename);
@$this->connectDatabase();

✅ The Good Example

// Handle errors explicitly using conditionals, try/catch, or validation
if (file_exists($filename)) {
    $content = file_get_contents($filename);
} else {
    throw new FileNotFoundException("File not found: $filename");
}

try {
    $this->connectDatabase();
} catch (DatabaseException $e) {
    Log::error("Database connection failed: " . $e->getMessage());
}

What the rule checks

When it does not report

How to fix

Configuration

E0011 has no configuration options and is enabled by default.

Junior Engineer’s Rule of Thumb:

Never use the @ error suppression operator. If an operation can fail, check for failure or catch the exception explicitly!