PREG:
(?<CV>\$*\w+\s*)\s*\((\s*(?<PRM>(\g<0>)|(?<STRING>(?<Q>['"])[^(?P=Q)]*(?P=Q))|(\g<CV>))\s*([\,]\s*(\g<PRM>))*)?\s*\)
Here's a regex I wrote based on PCRE2. It matches most PHP functions, including more complex nested functions such as:
bar("",bar($str,CONST,func($s,o)))
But I ran into a problem: I couldn't solve the problem with mismatched double quotes like this:
bar("string"",bar($str,CONST,func($s,o))) //1
bar("string\",bar($str,CONST,func($s,o))) //2
bar("",bar($str,CONST,func($s,o))) //This regex is supported, but when I try to be compatible with both cases, the problem occurs