fix-phpstan

Diagnose and fix PHPStan and Larastan static-analysis errors at their root cause until clean.

Updated Aug 1, 2026
One-click install
npx skills add https://github.com/dxiiren/project-skeleton --skill fix-phpstan-dxiiren
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fix-phpstan
Source: https://github.com/dxiiren/project-skeleton/tree/main/.claude/skills-optional/fix-phpstan
Command: npx skills add https://github.com/dxiiren/project-skeleton --skill fix-phpstan-dxiiren

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? PHPStan or Larastan failures block commits and CI, and fixing them by hand means reading cryptic type errors, tracing them to the real source, and re-running the analyzer repeatedly. This Skill automates that loop: it captures the full error list, fixes the root cause in the PHP source, and re-runs the analysis until it reports no errors. ## Core Features & Use Cases - Root-cause fixing: Reads the actual PHP files and their dependencies (models, migrations, requests, services) before editing, fixing types at their definition rather than at every call site. - Pattern library: Maps common errors to correct fixes, including Collection generics, Larastan relation generics (BelongsTo/HasMany), undefined model properties, nullable access, and array shape mismatches. - Strict guardrails: Never suppresses errors with @phpstan-ignore annotations, never adds baseline entries for newly introduced errors, and never weakens types to mixed just to pass. - Use Case: A git commit fails on a phpstan pre-commit hook after merging a branch. Invoke this Skill to read the reported errors, apply minimal type fixes across the affected files, and paste the clean [OK] No errors result as proof. ## Quick Start Ask the assistant to fix the phpstan errors reported by the project's static-analysis command and re-run it until it passes cleanly.

Frequently Asked Questions about fix-phpstan

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix PHPStan errors in a Laravel project?

Run the full phpstan command to capture every error, then read each reported PHP file and its dependencies before editing. Apply minimal fixes such as generic PHPDoc annotations, return types, and null guards, then re-run until the analyzer reports no errors.

How to fix Larastan relation generic type errors?

Type-hint relation methods with Larastan's generic contract, such as BelongsTo<Related, self> or HasMany<Related, self>. Fixing the type at the relation definition resolves the error at every call site instead of patching each usage.

Can I use @phpstan-ignore-line to make PHPStan pass?

No, suppressing errors with @phpstan-ignore-line or baseline entries hides real type problems instead of fixing them. The correct approach is to fix the underlying type, reserving ignore annotations only for genuinely wrong third-party types with an explanatory comment.

Why does PHPStan report undefined property on my Eloquent model?

PHPStan cannot see attributes resolved through Eloquent's magic __get method. Add the property to the model's @property PHPDoc block, or define it as a real attribute or relation so static analysis can verify it.

When should I regenerate a PHPStan baseline file?

Regenerate a baseline only to warehouse pre-existing debt after draining old entries or bumping the analysis level. Never add baseline entries for errors your own change introduced; those must be fixed directly.