I want to create a function which receives a single argument that holds the path to a PHP file and then parses the given file and returns something like this:
class NameOfTheClass
function Method1($arg1, $arg2, $arg2)
private function Method2($arg1, $arg2, $arg2)
public function Method2($arg1, $arg2, $arg2)
abstract class AnotherClass
function Method1($arg1, $arg2, $arg2)
private function Method2($arg1, $arg2, $arg2)
public function Method2($arg1, $arg2, $arg2)
function SomeFunction($arg1, $arg2, $arg3)
This function should return all the classes, methods and function that exist in the given file with all the defined identifiers (abstract, public, private, protected, static, extends, interfaces, ...).
My first tought was to use regular expressions to do this, however these behave quite badly with comments, ie: /* this function returns(max(salary)) */ and become quite complex if I want to properly support scopes.
Another possible solution was to use the following built-in PHP functions:
get_declared_classes
get_declared_interfaces
get_defined_functions
get_class_methods
However these functions don't allow me to see the file where the classes / methods / functions are defined and thus it's not very useful.
I believe the Tokenizer extension is the solution for my problem, however I have never used this extension before and was hoping someone could give some advice and help me out with a basic implementation example.