For anyone who is interested... I have figured it out.
To install run in the command line:
sudo pear install channel://pear.php.net/PHP_Beautifier-0.1.13
Then very basic usage is:
require "PHP/Beautifier.php";
$oBeaut= new PHP_Beautifier();
$oBeaut->setInputFile('messy.php');
$oBeaut->setOutputFile('beautified.php');
$oBeaut->process();
$oBeaut->save();
See the documentation on their site for more advanced useage.
Hope someone finds this useful!🙂