public
Description: A combined runtime/static code-analysis tool, that can trace parameter types
Homepage:
Clone URL: git://github.com/troelskn/php-tracer-weaver.git
Troels Knak-Nielsen (author)
Sun Dec 07 06:51:28 -0800 2008
commit  89080b6a39771e03f2e74835753d6a724a5f1764
tree    bdbd71355c08fd682e9b99ad5b90d40cea366b68
parent  ebcae05b28a9d422ff4207001dc4b1b59a4d5302
name age message
file README.markdown Sat Dec 06 16:50:21 -0800 2008 documentation [Troels Knak-Nielsen]
directory examples/ Sat Dec 06 06:31:45 -0800 2008 Forgot to delete temp file from examples [Troels Knak-Nielsen]
file reflector.inc.php Sat Dec 06 16:08:38 -0800 2008 Now uses static type info to collate class types [Troels Knak-Nielsen]
file scanner.inc.php Wed Dec 03 15:45:35 -0800 2008 Initial commit [Troels Knak-Nielsen]
file signature.inc.php Sat Dec 06 16:08:38 -0800 2008 Now uses static type info to collate class types [Troels Knak-Nielsen]
file test.php Sat Dec 06 16:08:38 -0800 2008 Now uses static type info to collate class types [Troels Knak-Nielsen]
file trace.sh Sat Dec 06 16:45:54 -0800 2008 Added a readme [Troels Knak-Nielsen]
file transform.inc.php Wed Dec 03 15:45:35 -0800 2008 Initial commit [Troels Knak-Nielsen]
file weave.php Loading commit data...
file xtrace.inc.php Sat Dec 06 16:08:38 -0800 2008 Now uses static type info to collate class types [Troels Knak-Nielsen]
README.markdown

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.

The project consists of two main tools:

  • trace.sh
  • weave.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. You can pipe it back to the input file, if you want to actually modify your code.

Sample usage:

weave.php somelibrary.php > somelibrary.php

The same dumpfile can be used to weave multiple files, by calling weave.php for each.