troelskn / php-tracer-weaver
- Source
- Commits
- Network (0)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
| name | age | message | |
|---|---|---|---|
| |
README.markdown | Mon Dec 21 04:00:16 -0800 2009 | |
| |
examples/ | Sat Dec 06 06:31:45 -0800 2008 | |
| |
reflector.inc.php | Sat Dec 06 16:08:38 -0800 2008 | |
| |
scanner.inc.php | Wed Dec 03 15:45:35 -0800 2008 | |
| |
signature.inc.php | Sat Dec 06 16:08:38 -0800 2008 | |
| |
test.php | Sat Dec 06 16:08:38 -0800 2008 | |
| |
trace.sh | Sat Dec 06 16:45:54 -0800 2008 | |
| |
transform.inc.php | Wed Dec 03 15:45:35 -0800 2008 | |
| |
weave.php | Sun Dec 07 15:50:04 -0800 2008 | |
| |
xtrace.inc.php | Sat Dec 06 16:08:38 -0800 2008 |
php-tracer-weaver
php-tracer-weaver is a tool for analysing parameter types in PHP code, using a combination of static and runtime analysis. It relies on the xdebug extension to trace function calls. The result of the analysis can then be used to generate docblock comments, with the proper type annotations.
Usage
The basic usage of tracer-weaver is to write a piece of code (If you have unit tests/examples, they would be a good candidate), that utilises the code to manipulate. Run this example with the tracer, then use the weaver to generate docblocks from the output of the tracer.
See under examples/ for some basic examples.
The project consists of two main tools:
trace.shweave.php
trace.sh
This is just a wrapper around php + xdebug. Use it in lieu of php to execute a php script. It will run normally, but the code is traced and the output is dumped in dumpfile.xt. You can also manually configure xdebug to generate the dumpfile.
Sample usage:
trace.sh test.php
weave.php
This tool takes a dumpfile (Generated by trace.sh) and a php-source file, and injects docblock comments into the php-source, using the type-information from the trace. The tool expects dumpfile.xt in the current directory, and takes the file to weave with as argument, printing the modified file to stdout. If you want to modify your code, pass the target file (can be the same as input) as second argument:
Sample usage:
weave.php somelibrary.php somelibrary.php
The same dumpfile can be used to weave multiple files, by calling weave.php for each.
