neversight/learn-skills.dev/phpstan-fixer
Claude Code and agent skill by neversight/learn-skills.dev
- community
Checking that the SKILL.md file is still in the repository.
Fix PHPStan static analysis errors by adding type annotations and PHPDocs. Use when encountering PHPStan errors, type mismatches, missing type hints, or static analysis failures. Never ignores errors without user approval.
Install
npx vskill@latest install neversight/learn-skills.dev/phpstan-fixerSKILL.md
PHPStan Error Fixer
Fix PHPStan static analysis errors through proper type annotations, PHPDocs, and code improvements. This skill teaches agents how to resolve errors without suppressing them, respecting the project's configured strictness level.
Core Principles
- Never suppress errors as first resort — Fix the root cause with proper
types and annotations
- Respect user configuration — Never modify
phpstan.neonsettings
(level, paths, parameters)
- No silent ignoring — Never add
ignoreErrorsto config without explicit
user approval
- Context-aware fixes — Understand the project type (Laravel, Symfony,
vanilla PHP) before proposing solutions
- Ask before ignoring — If a legitimate ignore is needed, explain why and
get user approval first
- Don't fix third-party code — Never modify files in
vendor/. Use stub
files instead to override wrong types
Workflow
Step 1: Understand the Project Context
Before fixing errors, identify the project type:
Key information to extract:
- PHPStan level (0-10, or max)
- Installed PHPStan extensions (larastan, phpstan-strict-rules, etc.)
- Framework-specific helpers (Laravel IDE Helper, Symfony plugin)
- Project-specific type conventions
Step 2: Analyze the Error
PHPStan errors have this structure:
Extract:
- Error identifier (e.g.,
parameter.type,missingType.return) - Error location (file, line number)
- Context (what's the code trying to do?)
Step 3: Apply the Right Fix
Use the error identifier to determine the fix strategy:
Step 4: Verify the Fix
After applying fixes, run PHPStan again to confirm:
Important:
- If new errors appear, the fix may have been incorrect. Re-analyze the error and try a different approach.
- If the same error persists, the fix wasn't applied correctly. Double-check the code.
- If errors are resolved, mark the fix as successful and move to the next error.
Common Error Fixes
Type-Related Errors
missingType.parameter — Missing parameter type
Error:
Fix — Add native type:
Fix — Use PHPDoc for complex types:
missingType.return — Missing return type
Error:
Fix — Add native return type:
Fix — Use PHPDoc for union/intersection types:
argument.type — Wrong argument type
Error:
Fix — Cast the argument:
Fix — Narrow the type earlier:
return.type — Wrong return type
Error:
Fix — Adjust return type:
Fix — Ensure non-null with assertion:
Property Errors
property.notFound — Undefined property access
Error:
Fix — Add property declaration:
Fix — Document magic property:
Fix (Laravel) — Use IDE Helper:
property.onlyWritten — Property written but never read
Error:
Fix — Remove unused property or add getter:
Method Errors
method.notFound — Undefined method call
Error:
Fix — Add method:
Fix — Document magic method:
Fix (Laravel) — Add to `@mixin` for query builders:
Array/Offset Errors
offsetAccess.notFound — Undefined array offset
Error:
Fix — Use array shape PHPDoc:
Fix — Add existence check:
Fix — Use null coalescing:
Generics Errors
missingType.generics — Missing generic type
Error:
Fix — Specify generic type in PHPDoc:
Fix (Laravel) — Use IDE Helper stubs for collections.
Dead Code Errors
deadCode.unreachable — Unreachable code
Error:
Fix — Remove dead code:
identical.alwaysTrue / identical.alwaysFalse — Condition is always true/false
Error:
Fix — Remove useless condition or fix type:
Framework-Specific Fixes
Laravel
Install Larastan for Laravel-aware analysis:
Check `phpstan.neon` includes Larastan (ask user to add if missing):
Common Laravel fixes:
Symfony
Install Symfony PHPStan extension:
Check `phpstan.neon` includes Symfony extension (ask user to add if missing):
Common Symfony fixes:
When Ignoring is Acceptable (Last Resort)
Sometimes a legitimate ignore is needed. Always ask the user first using the Question tool:
Step 1: Explain the situation
Step 2: Use Question tool to get user choice
Example Question tool usage:
Valid reasons for ignoring:
- Third-party library with wrong types (and no stub file available)
- Reflection-based code that's correct but PHPStan can't understand
- Complex business logic that's type-safe at runtime but not provably so statically
- Temporary during large refactoring (use baseline)
How to ignore (if approved):
Never do this without approval:
Debugging Types
Use \PHPStan\dumpType() to see what PHPStan thinks:
Troubleshooting
PHPStan doesn't recognize a valid type
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingdata/skills-md/marcelorodrigo/agent-skills/phpstan-fixer/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/neversight/learn-skills.dev/phpstan-fixer)