I have a folder with some classes and another with some functions.
Usually one class or function per file, but that is not always the case.
On a few occasions a class might be accompanied with a function or two and some functions might be grouped together.
I am reading each file and building a nice manual from the detailed comments each of them have.
I was thinking it would be nice to grab the code of the class or function as well.
But I have not found a way to do so.
Regular expressions are out of the question since they could only match simple functions.
I have found the PHP Tokenizer but I can't figure it out how could that help.
Google is no help also.
I am looking for a pure PHP solution if one exists.
Let's say I have a code like this:
class BaseClass {
function __construct() {
print "In BaseClass constructor\n";
}
}
class SubClass extends BaseClass {
function __construct() {
parent::__construct();
print "In SubClass constructor\n";
}
}
class OtherSubClass extends BaseClass {
// inherits BaseClass's constructor
}
function monkey() {
return new BaseClass();
}
function weasel() {
return new SubClass();
}
function dragon() {
return new OtherSubClass();
}
I want to parse it and get an array of 6 entries, one with each class and one with each function.