Let's say we have a function,
dosomething(string $text) : string
And suppose that we want to programmatically find and list all occurrences of this function within a project with arguments. Given that $text could be any string, how would we do this?
I was thinking about using a regex, such as the pattern
dosomething([^)]+)
in order to search to the trailing ), but $text could be a string such as "lorem ipsum (but with this)", and that would match prematurely. Searching for " or ' seems to not work either, as we could have a variable
dosomething($string)
instead of a string as an argument. What would be the best way to go about this?