title: Parsing Classes, Functions and Arguments in PHP
body: <p>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:</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>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, ...).</p>
  
  <p>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.</p>
  
  <p>Another possible solution was to use the following built-in PHP functions:</p>
  
  <pre><code>get_declared_classes
  get_declared_interfaces
  get_defined_functions
  get_class_methods
  </code></pre>
  
  <p>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.</p>
  
  <p>I believe the Tokenizer extension is the solution for my problem, however I have never used this extension before.</p>