tzmfreedom / type-tracer
Installs: 9
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/tzmfreedom/type-tracer
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.