From acc
Detects null pointer dereferences in PHP code including missing null checks after find(), chained method calls on nullables, first()/last() without handling, Doctrine/Eloquent relationship nulls, and optional chaining gaps.
How this skill is triggered — by the user, by Claude, or both
Slash command
/acc:find-null-pointer-issuesThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Analyze PHP code for null pointer dereference issues.
Analyze PHP code for null pointer dereference issues.
// BUG: No null check after find
$user = $repository->find($id);
$user->getName(); // May be null
// BUG: Chained calls on nullable
$order = $this->orderRepository->findByUser($userId);
$order->getItems()->first()->getProduct(); // Multiple null risks
// BUG: Direct access to optional array key
$name = $data['user']['name']; // May not exist
// FIXED:
$name = $data['user']['name'] ?? 'default';
// Type hint: public function getUser(): ?User
// BUG: No null handling
$user = $service->getUser();
echo $user->getEmail(); // $user may be null
// FIXED:
$user = $service->getUser();
if ($user !== null) {
echo $user->getEmail();
}
// BUG: first() on potentially empty collection
$items = $repository->findByStatus('active');
$first = $items->first(); // Returns false/null if empty
$first->process(); // Crash if empty
// FIXED:
$first = $items->first();
if ($first !== null) {
$first->process();
}
// BUG: Inconsistent null safety
$name = $user?->getProfile()->getName(); // getProfile may return null
// FIXED:
$name = $user?->getProfile()?->getName();
// BUG: Uninitialized property access
class Order {
private ?Customer $customer;
public function getCustomerName(): string {
return $this->customer->getName(); // $customer not initialized
}
}
// BUG: Relationship may be null
$order->getCustomer()->getAddress(); // Customer may be null
// BUG: Collection method on null relation
$user->getOrders()->filter(...); // getOrders may return null
# Nullable return types
Grep: "function\s+\w+\([^)]*\)\s*:\s*\?" --glob "**/*.php"
# find() without null check
Grep: "->find\([^)]+\)\s*;" --glob "**/*.php"
# Chained calls after nullable
Grep: "\?>\w+\([^)]*\)->\w+" --glob "**/*.php"
# first()/last() usage
Grep: "->(first|last)\(\)\s*->" --glob "**/*.php"
| Pattern | Severity |
|---|---|
| find() without null check | 🟠 Major |
| Chained calls on nullable | 🟠 Major |
| first()/last() on collection | 🟡 Minor |
| Missing null coalescing | 🟡 Minor |
| Uninitialized property | 🔴 Critical |
### Null Pointer: [Description]
**Severity:** 🔴/🟠/🟡
**Location:** `file.php:line`
**Type:** [Nullable Return|Missing Check|Chained Access|...]
**Issue:**
Variable may be null when accessed.
**Code:**
```php
// Problematic code
Fix:
// With null check
npx claudepluginhub dykyi-roman/awesome-claude-code --plugin accDetects type safety issues in PHP code including implicit coercion, loose comparisons, unsafe casting, mixed types, return mismatches, and array/JSON problems. Useful for refactoring legacy PHP or enforcing strict typing.
Review PHP code using PhpStorm inspections. Use when editing PHP files, reviewing code quality, fixing PHP issues, or when asked about PHP best practices.
Detects N+1 query patterns in custom WordPress theme/plugin PHP code using High/Medium/Low confidence tiers. Skips third-party plugins and provides rewrite suggestions with extracted variable names.