I want to create a function that takes a single argument that contains the path to a PHP file, and then parse the given file and return 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 classes, methods and functions that exist in this file with all defined identifiers (abstract, public, private, protected, static, extensible, interfaces, etc.).
My first problem was to use regular expressions for this, however they are very bad at comments, i.e. / * this function returns (max (salary)) * / and becomes quite complicated if I want to properly support areas.
Another possible solution was to use the following PHP built-in functions:
get_declared_classes
get_declared_interfaces
get_defined_functions
get_class_methods
, // , , .
, Tokenizer , .