Question

Background:

PHPDoc ( http://www.phpdoc.org/ ) is a brilliant tool for extracting html documentation of your classes or methods from comments in your files. Adding PHPDoc comments also has other advantages - if you use an IDE like Zend or Netbeans, it will use the PHPDocs to show you autocompletion tips.

Most Issue trackers have a feature where you can commit into your version control system with a special comment, and it will automatically link that commit to that issue.

So here's what I want in a system: I commit some code with a special comment, my issue tracker links it to an issue. It then looks at the commit and works out what Methods and Classes I have changed. It then says "If you are looking for documentation around this issue, try these bits of PHPDoc: ClassX.FunctionY, ClassZ.VariableP". It automatically points users to documentation that might be relevant. I think this would be a great feature.

Question:

So the piece that is missing is something to take a PHP code diff, and work out what classes and methods have changed. Anyone got any pointers on some code that can do that?

Thanks in advance, James

Was it helpful?

Solution 3

http://uk3.php.net/reflection

PHP5 has methods to take a class apart and examine all the methods, including giving me the line numbers I need to match against the diff. Using this I can start to hand roll my own solution.

OTHER TIPS

If you are using subversion, you can see a diff of all the files that have changed in the project. And see how they are different.

There are software with integrated subversion support, like Trac.

Here's a picture of TracDiff

You need a tool that understands the structure of PHP deeply, that is, can parse the PHP source text just like the PHP engine does.

Our "Smart Diff" does this, enabling one compare pairs of PHP files that you know are the original and changed version. It compares ASTs and finds the minimal edits to map one into another. If the old and new methods are at all similar, it will discover that and tell you how one was edited to get the other. See http://www.semdesigns.com/Products/SmartDifferencer/index.html

you can write a post commit script that receives the files modiefied and looks into them to do what you want

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top