kayw-geek

See the full type-inference chain of any value in PHPStan, not just a single snapshot.

10
0
89% credibility
Found May 22, 2026 at 10 stars -- GitGems finds repos before they trend. Get early access to the next one.
Sign Up Free
AI Analysis
PHP
AI Summary

This is a developer tool that acts like a detective for variable types in PHP code. When you're debugging why PHPStan thinks a variable has a 'mixed' type, this extension shows you the complete history of that variable — where it started, every time it was assigned a new value, and how its type changed through your code. It works in two ways: you can ask about any variable from the command line without changing your code, or you can add a special marker function directly in your code that shows the type chain when you run your normal analysis. The tool is designed to help developers understand complex type behavior, fix type-related bugs, and write better-typed PHP code.

How It Works

1
🤔 The Mystery of the 'mixed' Type

You're working on your PHP project and PHPStan keeps complaining about a variable being 'mixed' — you have no idea how it got that way.

2
📦 Installing the Type Detective

You add this extension to your project — it installs automatically and becomes part of your type-checking workflow.

3
🔍 Two Ways to Investigate

You can either ask about any variable from the command line, or drop a special marker right in your code where you want answers.

4
Choose Your Investigation Style
💻
Command Line Quick Check

Ask about any variable at any line without changing your code — just run a simple command.

✍️
Add a Code Marker

Drop traceType($myVar) into your code, run your normal analysis, and see the answer appear as a message.

5
🔗 The Type Chain Reveals All

You see exactly how your variable's type evolved: where it started, every change it went through, and why it ended up where it did.

No More Type Mystery

You finally understand your code's type behavior and can confidently fix issues, add proper types, or explain to teammates what's happening.

Sign up to see the full architecture

4 more

Sign Up Free

Star Growth

See how this repo grew from 10 to 10 stars Sign Up Free
Repurpose This Repo

Repurpose is a Pro feature

Generate ready-to-use prompts for X threads, LinkedIn posts, blog posts, YouTube scripts, and more -- with full repo context baked in.

Unlock Repurpose
AI-Generated Review

What is phpstan-type-trace?

This is a PHPStan extension that reconstructs the complete type-inference chain for any variable in your codebase. Instead of seeing just the final type snapshot, you get a chronological view of every type mutation: from parameter entry through assignments, compound operations, and reads. It solves the frustrating "why does PHPStan think this is mixed?" problem by exposing the full lineage of each type decision.

You can use it two ways. The CLI lets you inspect any variable at any line with zero source changes. Or you drop `traceType($var)` inline in your code and the chain appears as a PHPStan error on your next run. JSON output is available for tooling integration.

Why is it gaining traction?

The killer feature is that it makes PHPStan's internal type reasoning visible without requiring you to understand PHPStan's internals. The inline `traceType()` approach is particularly clever -- it is a runtime no-op, so stray calls in production code do nothing, but during static analysis they emit full type chains as errors.

It also ships as a Claude Code plugin, which is a significant hook. AI coding assistants often guess at types when fixing PHPStan errors; with this extension installed, Claude gets real upstream type evidence instead of pattern-matching.

Who should use this?

PHP developers who maintain large codebases with complex type narrowing -- especially those hitting "mixed" errors they cannot explain. Teams running Larastan or custom PHPStan rules will find it invaluable for debugging type inference failures. AI-assisted developers using Claude Code will benefit most, since the plugin integration gives the AI grounded type evidence for its fixes.

Verdict

This is a genuinely useful tool with a clever dual-mode design. The credibility score of 0.8999999761581421% reflects its early stage -- only 10 stars and limited community feedback. The implementation looks solid and the documentation is clear, but treat it as a developer tool for investigation, not a production dependency. Worth installing as a dev tool to have in your belt when PHPStan type errors get puzzling.

Sign up to read the full AI review Sign Up Free

Similar repos coming soon.