Rector is an opensource tool that parses code into a syntax tree and makes automated changes based on predefined rulesets.
Joachim recounts how he used Rector to convert older procedural hooks into new Object Oriented hook implementations and how he cleaned up the code so it conforms to Drupal Code Standards.