Bug fix knowledge base. Provides bug categories, symptoms, fix patterns, and minimal intervention principles for PHP 8.4 projects.
From accnpx claudepluginhub dykyi-roman/awesome-claude-code --plugin accThis skill uses the workspace's default tool permissions.
Comprehensive knowledge for diagnosing and fixing bugs in PHP applications following DDD, CQRS, and Clean Architecture patterns.
Symptoms:
Common Causes:
> instead of >=, && instead of ||!$condition vs $condition)< count vs <= count)break in switch statementsFix Pattern:
// Before: Logic error
if ($amount > $limit) { // Should be >=
throw new LimitExceededException();
}
// After: Fixed
if ($amount >= $limit) {
throw new LimitExceededException();
}
Symptoms:
Common Causes:
Fix Pattern:
// Before: Null pointer risk
$user = $this->userRepository->find($id);
$email = $user->getEmail(); // Crashes if user is null
// After: Safe with null check
$user = $this->userRepository->find($id);
if ($user === null) {
throw new UserNotFoundException($id);
}
$email = $user->getEmail();
// Alternative: Null coalescing
$email = $user?->getEmail() ?? throw new UserNotFoundException($id);
Symptoms:
Common Causes:
Fix Pattern:
// Before: Boundary issue
$firstItem = $items[0]; // Crashes if empty
// After: Safe boundary check
if ($items === []) {
throw new EmptyCollectionException('items');
}
$firstItem = $items[0];
// Alternative: Using first() with default
$firstItem = $items[0] ?? throw new EmptyCollectionException('items');
Symptoms:
Common Causes:
Fix Pattern:
// Before: Race condition
if (!$this->repository->exists($id)) {
$this->repository->save($entity); // Another process might insert between check and save
}
// After: Atomic operation with locking
$this->lockManager->acquire("entity:$id");
try {
if (!$this->repository->exists($id)) {
$this->repository->save($entity);
}
} finally {
$this->lockManager->release("entity:$id");
}
// Alternative: Database-level uniqueness
// Use UNIQUE constraint + INSERT ... ON DUPLICATE KEY
Symptoms:
Common Causes:
Fix Pattern:
// Before: Resource leak
$handle = fopen($path, 'r');
$content = fread($handle, filesize($path));
// Missing fclose()
// After: Proper resource management
$handle = fopen($path, 'r');
try {
$content = fread($handle, filesize($path));
} finally {
fclose($handle);
}
// Better: Use high-level functions
$content = file_get_contents($path);
Symptoms:
Common Causes:
Fix Pattern:
// Before: Swallowed exception
try {
$this->service->process($data);
} catch (Exception $e) {
// Silent failure - bug hidden
}
// After: Proper exception handling
try {
$this->service->process($data);
} catch (ValidationException $e) {
throw new ProcessingFailedException(
"Failed to process data: {$e->getMessage()}",
previous: $e
);
}
Symptoms:
Common Causes:
Fix Pattern:
// Before: Type issue
function calculate($amount) { // No type hint
return $amount * 1.1; // Fails if string passed
}
// After: Strict typing
declare(strict_types=1);
function calculate(float $amount): float {
return $amount * 1.1;
}
Symptoms:
Common Causes:
Fix Pattern:
// Before: SQL injection vulnerability
$query = "SELECT * FROM users WHERE email = '$email'";
// After: Parameterized query
$query = "SELECT * FROM users WHERE email = :email";
$stmt = $pdo->prepare($query);
$stmt->execute(['email' => $email]);
Symptoms:
Common Causes:
Fix Pattern:
// Before: Potential infinite loop
while ($item = $queue->pop()) {
$this->process($item);
// If process() adds items back to queue, infinite loop
}
// After: Safe with limit
$maxIterations = 10000;
$iterations = 0;
while ($item = $queue->pop()) {
if (++$iterations > $maxIterations) {
throw new MaxIterationsExceededException($maxIterations);
}
$this->process($item);
}
Before applying a fix, verify:
Reproduction Test Exists
Minimal Change
No Regressions
Code Quality
Documentation
| Error Message | Likely Bug | Quick Fix |
|---|---|---|
| "Call to member function on null" | Null pointer | Add null check |
| "Undefined array key" | Boundary issue | Check array_key_exists |
| "Type error: Argument X" | Type issue | Add type validation |
| "Maximum execution time" | Infinite loop | Add iteration limit |
| "Allowed memory exhausted" | Resource leak | Close resources in finally |
| "Integrity constraint violation" | Race condition | Add locking/transaction |
| "Cannot modify readonly property" | Immutability violation | Create new instance |
Provides UI/UX resources: 50+ styles, color palettes, font pairings, guidelines, charts for web/mobile across React, Next.js, Vue, Svelte, Tailwind, React Native, Flutter. Aids planning, building, reviewing interfaces.