メソッドの引数の名前を取得したい

メモ。

<?php
$matches = array();
$params = array();

$content = file_get_contents('Foo.php');
preg_match_all('/function execute\((.*)\)/', $content, $matches);

if (count($matches) > 0) {
    $param_str = $matches[1][0];
    if (trim($param_str) !== '') {
        foreach (explode(',', $param_str) as $param) {
            $params[] = trim($param, '&$ ');
        }
    }
}
?>

ファイルをテキストとして取得、正規表現で検索。格好悪い。