PHP Reflecting code from a file
Posted: Mon Feb 21, 2011 1:15 pm
Hi,
I've been trying to find information on how to use reflection on a file that doesn't necessarily contain class definitions or OO code. I'd like to be able to read any file (not with include obviously because you don't want the code to execute) but be able to read the different functions, variables, classes that are defined in it and use that reflection class to analyse the content of the file.
There is an extension proposition for the zend framework but i can't see if there is a way to download it and i'd prefer a native php extension or class set cause i hate using Zend Framework, don't ask me why, i just don't like it... Is there an extension that can do that? The reflection core API for PHP is good but only works on information in memory, not on information that is not loaded...
The reasons for this are large, i'd like to create some kind of code analysis tool but i also see a good way of securing pluggins for applications with this. Load the reflection from the file, analyse the code, are there free instructions floating in the code that will execute when i include this file, is the code in this file defining a class? Is this class extending or implementing a specific other class or interface?
Thanks
I've been trying to find information on how to use reflection on a file that doesn't necessarily contain class definitions or OO code. I'd like to be able to read any file (not with include obviously because you don't want the code to execute) but be able to read the different functions, variables, classes that are defined in it and use that reflection class to analyse the content of the file.
There is an extension proposition for the zend framework but i can't see if there is a way to download it and i'd prefer a native php extension or class set cause i hate using Zend Framework, don't ask me why, i just don't like it... Is there an extension that can do that? The reflection core API for PHP is good but only works on information in memory, not on information that is not loaded...
The reasons for this are large, i'd like to create some kind of code analysis tool but i also see a good way of securing pluggins for applications with this. Load the reflection from the file, analyse the code, are there free instructions floating in the code that will execute when i include this file, is the code in this file defining a class? Is this class extending or implementing a specific other class or interface?
Thanks