find-null-pointer-issues

Detect null-pointer issues in PHP code. Identify accesses to properties or methods on null, missing null checks, unhandled nullable return values, and absent optional chaining.

Last repository push
GitHub Stars
109
Forks
26
Issues / PRs
1

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "find-null-pointer-issues" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-c5babc2152b1f1ab71dc4565e8bf79c68af2e1d8d6713a06c40a77e47312c622. Verify the upstream source and version against https://github.com/dykyi-roman/awesome-claude-code before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Detect null-pointer issues in PHP code. Identify accesses to properties or methods on null, missing null checks, unhandled nullable return values, and absent optional chaining.

0 Downloads

Introduction source: third_party · dykyi-roman · 0.0.1 Reference

SkillPi interpretation

Tasks
Detects null pointer issues in PHP code. Finds property/method access on null, missing null checks, nullable returns without handling, optional chaining gaps.
Inputs and outputs
```markdown
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: find-null-pointer-issues
description: Detects null pointer issues in PHP code. Finds property/method access on null, missing null checks, nullable returns without handling, optional chaining gaps.

Null Pointer Detection

Analyze PHP code for null pointer dereference issues.

Detection Patterns

1. Nullable Return Without Check

// 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

2. Missing Null Coalescing

// BUG: Direct access to optional array key
$name = $data['user']['name']; // May not exist

// FIXED:
$name = $data['user']['name'] ?? 'default';

3. Method Calls on Nullable Type

// 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();
}

4. Collection First/Last on Empty

// 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();
}

5. Optional Chaining Gaps

// BUG: Inconsistent null safety
$name = $user?->getProfile()->getName(); // getProfile may return null

// FIXED:
$name = $user?->getProfile()?->getName();

6. Constructor Null Assignment

// BUG: Uninitialized property access
class Order {
    private ?Customer $customer;

    public function getCustomerName(): string {
        return $this->customer->getName(); // $customer not initialized
    }
}

7. Doctrine/Eloquent Relationship Nulls

// 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

Grep Patterns

# 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"

Severity Classification

Pattern Severity
find() without null check 🟠 Major
Chained calls on nullable 🟠 Major
first()/last() on collection 🟡 Minor
Missing null coalescing 🟡 Minor
Uninitialized property 🔴 Critical

Output Format

### 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

Current listing version

0.0.1

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value75/100

Highlights

  • 针对 PHP 开发者常见痛点,提供实用的空指针检测方案
  • 覆盖多种实际开发场景,具有明确的实用价值
Trigger Precision85/100

Highlights

  • 触发描述清晰完整,覆盖多种空指针场景变体
  • 边界定义明确,不易与其他代码分析工具混淆
Structure and Standards90/100

Highlights

  • 结构层次清晰,包含检测模式、grep 命令、严重性分级
  • 提供完整的问题示例和修复方案,便于理解执行
Execution Reliability80/100

Areas to improve

  • 缺少工具依赖说明 Reported severity: Minor

    未说明执行 grep 命令所需的环境或工具依赖

    Recommendation: 建议补充说明所需工具(如 grep 版本)或提供替代方案

Highlights

  • 提供具体的 grep 命令可直接执行
  • 覆盖主要异常场景并有对应修复示例
Evidence Verifiability (mean of the first four)83/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.