I asked ChatGPT for advice on this and after initially suggesting a solution using regular expressions, I then asked it to refine the answer using nikic/php-parser
and with a little tweaking I got a working response.
I can't post the result on Stack Overflow as it's against the site policy https://stackoverflow.com/help/gen-ai-policy but the short version of this is:
Node\Stmt\ClassMethod
nodesNode\Stmt\Return_
node then add it to a listHere's the working code: https://gist.github.com/gurubobnz/2ae85e5010158896789e75f3ea375803
There will be an issue here in that there is no execution guarantee of the return, e.g. if (false) { return []; }
will still be considered a return, but it is good enough for me to make a start on my corpus of source files.