find-type-issues

Detect type issues in PHP code. Identify implicit type coercions, mixed-type comparisons, unsafe type casts, and return type mismatches.

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-type-issues" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-ac761ea4a483d480ad84b6d3805aca76dfe5f019207d168f2611536855d06049. 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 type issues in PHP code. Identify implicit type coercions, mixed-type comparisons, unsafe type casts, and return type mismatches.

0 Downloads

Introduction source: third_party · dykyi-roman · 0.0.1 Reference

SkillPi interpretation

Tasks
Detects type issues in PHP code. Finds implicit type coercion, mixed types in comparisons, unsafe casting, type mismatches in returns.
Inputs and outputs
```markdown
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: find-type-issues
description: Detects type issues in PHP code. Finds implicit type coercion, mixed types in comparisons, unsafe casting, type mismatches in returns.

Type Issue Detection

Analyze PHP code for type safety issues.

Detection Patterns

1. Implicit Type Coercion

// BUG: String to int coercion
$count = '10abc'; // PHP converts to 10
$total = $count + 5; // 15, not error

// BUG: Array comparison
$a = [1, 2, 3];
$b = '1,2,3';
if ($a == $b) { } // Unexpected comparison

// BUG: Boolean context
if ($string) { } // '0' is falsy, but non-empty

2. Loose Comparison Issues

// BUG: == instead of ===
if ($status == 0) { } // null, '', '0' and false all pass;
                      // 'active' == 0 is FALSE since PHP 8

// BUG: in_array without strict
if (in_array($value, $array)) { } // Type coercion
// FIXED: in_array($value, $array, true)

// BUG: array_search
$key = array_search($value, $array); // Returns false or key
if ($key) { } // Key 0 is falsy!

3. Unsafe Type Casting

// BUG: Casting truncates
$float = 10.9;
$int = (int) $float; // 10, not 11

// BUG: String to array casting
$array = (array) $object; // May include private properties

// BUG: Object casting
$stdClass = (object) $array; // Loses type information

4. Mixed Type Parameters

// BUG: Function accepts anything
function process($data) { // No type hint
    return $data['key']; // Assumes array
}

// BUG: Union type issues
function handle(string|int $id): void {
    echo strlen($id); // Fails if int
}

5. Return Type Mismatches

// BUG: Inconsistent return types
function getValue(): int {
    if ($condition) {
        return '42'; // String, not int
    }
    return 0;
}

// BUG: Nullable inconsistency
function find(): User { // Not nullable
    if (!$found) {
        return null; // Type error
    }
}

6. Array Type Issues

// BUG: Assuming array structure
/** @param array $data */
function process(array $data): void {
    foreach ($data['items'] as $item) { // 'items' may not exist
        echo $item['name']; // 'name' may not exist
    }
}

// BUG: Mixed array types
$mixed = [1, 'two', new User()]; // Hard to type

7. Numeric String Issues

// NOT a bug: two numeric strings are compared NUMERICALLY
$a = '10';
$b = '9';
if ($a > $b) { } // true — '10' and '9' are numeric strings, so 10 > 9

// REAL BUG: one side is not a numeric string → string comparison
$version = '10';
if ($version > 'v9') { } // false — falls back to byte-wise comparison

// REAL BUG: version-like strings never compare numerically
if ('1.10' > '1.9') { } // false — '1.10' as a number is 1.1

// FIXED: compare with an explicit, intended semantics
if ((int) $a > (int) $b) { }          // numeric intent
if (version_compare('1.10', '1.9', '>')) { } // version intent

8. JSON Type Issues

// BUG: Assuming JSON structure
$data = json_decode($json, true);
$name = $data['user']['name']; // May not exist

// BUG: JSON encoding failures
$result = json_encode($data); // May return false

9. DateTime Type Issues

// BUG: String date comparison
if ($date > '2024-01-01') { } // String comparison

// BUG: DateTime vs DateTimeImmutable
function setDate(DateTime $date): void { }
$immutable = new DateTimeImmutable();
$this->setDate($immutable); // Type error

Grep Patterns

# Loose comparison with 0
Grep: "==\s*0[^.]|0\s*==" --glob "**/*.php"

# in_array without strict
Grep: "in_array\([^,]+,[^,]+\)" --glob "**/*.php"

# Casting with (int) or (string)
Grep: "\(int\)\s*\$|\(string\)\s*\$|\(array\)\s*\$" --glob "**/*.php"

# Mixed parameter types
Grep: "function\s+\w+\(\$\w+[,)]" --glob "**/*.php"

Severity Classification

Pattern Severity
Loose comparison with sensitive data 🔴 Critical
Return type mismatch 🟠 Major
Missing strict in_array 🟠 Major
Untyped parameters 🟡 Minor
Implicit coercion 🟡 Minor

Best Practices

Use Strict Types

declare(strict_types=1);

Use Strict Comparison

if ($status === 0) { }
if (in_array($value, $array, true)) { }

Type Hints Everywhere

function process(array $items): int
{
    return count($items);
}

Use instanceof

if ($object instanceof User) {
    $object->getName();
}

Output Format

### Type Issue: [Description]

**Severity:** 🔴/🟠/🟡
**Location:** `file.php:line`
**Type:** [Coercion|Loose Comparison|Unsafe Cast|...]

**Issue:**
[Description of the type safety problem]

**Code:**
```php
// Problematic code

Fix:

// Type-safe version

Current listing version

0.0.1

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 提供 PHP 代码类型问题检测能力,覆盖隐式类型转换、松散比较、不安全类型转换、返回值类型不匹配等常见问题
  • 具有明确的实用价值,适用于 PHP 开发者日常代码质量保障
Trigger Precision95/100

Highlights

  • description 明确描述了功能,并列举了具体问题类型,触发词精准完整,边界清晰
Structure and Standards90/100

Highlights

  • 文档结构清晰,包含 Detection Patterns、Grep Patterns、Severity Classification、Best Practices、Output Format 等章节
  • 步骤划分明确,有多个端到端代码示例,frontmatter 完整
Execution Reliability88/100

Highlights

  • 提供了具体的检测模式、grep 模式、严重性分类和最佳实践,逻辑完整
  • 工具来源(grep)明确,参数正确,覆盖了主要异常场景,并提供了修复建议
Evidence Verifiability (mean of the first four)90/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.