tzmfreedom / type-tracer
0.0.4
2024-11-17 12:12 UTC
Requires
- rector/rector: ^1.2
- webmozart/assert: ^1.11
Requires (Dev)
- phpunit/phpunit: ^11.4
README
Type Tracer is Rector Custom Rule to add type declaration.
Install
$ composer require --dev tzmfreedom/type-tracer
Usage
- Generate func trace files.
If you use Laravel, FuncTraceMiddleware is available for func trace.
- Aggregate func trace files.
$ vendor/bin/trace-aggregate 'App\' type-aggregate.json '/tmp/trace.*'
- Run Rector
<?php use Tzmfreedom\TypeTracer\Rector\TypeDeclarationRector; use Rector\Config\RectorConfig; return RectorConfig::configure() ->withConfiguredRule(TypeDeclarationRector::class, [ 'mixedTypeCount' => 4, 'file' => 'type-aggregate.json', ]);
How it works
- Record PHP function execution traces with arguments by Xdebug Func Trace.
- Aggregate function traces.
- Add type declaration with aggregated function traces by Rector.