I have below regex to match all function statements in any php
file. But it matches the function definitions as well.
[a-zA-Z]+\([^\)]*\)(\.[^\)]*\))?
Now I need to modify this regex to match only function calls(not definition/declaration) that are called like $this->funcName(
or $anyObject->funcName(
or self::funcName(
or parent::funcName(
.
I tried modifying the regex, but it breaks when I use $
in it. Can someone help out ?
A sufficient regex would be:
(?:\$[A-Za-z_]\w*->|self::|parent::)[A-Za-z_]\w*\([^)]*\)
This also asserts that the variables and functions follow correct naming syntax:
$
.