matesofmate / phpstan-extension
PHPStan extension for Symfony Mate providing AI assistants with efficient static analysis tools
Package info
github.com/MatesOfMate/phpstan-extension
Type:symfony-ai-mate
pkg:composer/matesofmate/phpstan-extension
Requires
- php: >=8.2
- matesofmate/common: ^0.4 || ^0.6
- phpstan/phpstan: ^2.0
- symfony/ai-mate: ^0.12 || dev-main
- symfony/process: ^6.4|^7.0|^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/phpstan-phpunit: ^2.0
- phpunit/phpunit: ^10.0
- rector/rector: ^2.0
Suggests
- helgesverre/toon: Install for TOON-encoded MCP responses; JSON remains the fallback when it is not available
Provides
None
Conflicts
None
Replaces
None
README
Token-efficient PHPStan analysis tools for AI assistants. This package runs PHPStan and returns encoded structured results geared toward debugging and iteration.
Features
- analyse the full project or a selected file or directory
- clear PHPStan result cache
- three consistent compact output modes
- automatic configuration detection
Installation
composer require --dev matesofmate/phpstan-extension vendor/bin/mate init
In current Mate setups, extension discovery is handled automatically after Composer install and update. Run vendor/bin/mate discover when you want to refresh discovery artifacts such as mate/AGENT_INSTRUCTIONS.md.
Useful Mate commands:
vendor/bin/mate debug:extensions vendor/bin/mate debug:capabilities vendor/bin/mate tools:list --extension=matesofmate/phpstan-extension
Run a tool directly:
vendor/bin/mate tools:call phpstan-analyse --mode=summary
Custom Command Configuration
If PHPStan must run through Docker or another wrapper command, configure matesofmate_phpstan.custom_command.
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; return static function (ContainerConfigurator $container): void { $container->parameters()->set('matesofmate_phpstan.custom_command', [ 'docker', 'compose', 'exec', 'php', 'vendor/bin/phpstan', ]); };
Requirements
- PHP 8.2+
- Symfony Mate 0.13+ required
- PHPStan 2.x in the target project
Available Tools
phpstan-analysephpstan-analysis-detailphpstan-clear-cache
This package returns encoded strings through Mate's core ResponseEncoder. Install the suggested helgesverre/toon package if you want TOON responses; otherwise the same payload falls back to JSON.
Agent Skills
The extension ships Agent Skills that Mate installs into the project as mate-<name>:
phpstan-static-analysis: scoping a run, reading the error list, and when to clear the result cache
vendor/bin/mate skills:list
Output Modes
defaultsummarydetailed
Development
composer install
composer test
composer lint
composer fix
License
MIT