From:             
Operating system: Any
PHP version:      5.3.5
Package:          Reflection related
Bug Type:         Feature/Change Request
Bug description:Add possibility to reflect on a file not loaded in memory

Description:
------------
I'd like to see a ReflectionFile class added to the Reflection api that
would allow you to reflect on the content of a file instead of a loaded
information.



The reason for this can be varied but in my current case is to reflect the
class and code information inside of a file to display to a user. I'm
building a web IDE that will display the class information of a file in a
web project. I don't want to load that file because it could be a security
issue and launch code that i don't want to launch.



Other uses for this is to validate that a file contains a specific class or
reflect on the classes in the file to find if the classes do implement an
interface or a specific class without having to load the code into
execution space.



Finaly, if a file contains non encapsulated code that  could be executed
when including the file, the ReflectionFile class could be used to detect
that and you could refuse using the class file. For example, a whiz tries
to place a statement hidden between two class definitions that could
compromise your application, then you could detect it with:



if($myReflectedFile->hasExecutableStatements()){

//Refuse usage of this file

}else{

include($myReflectedFile->filename);

}



The number of implications for this class are large, they allow many other
options such as documentation extraction from a code file. Many of us are
aware that if bytecode caching is active on a server you won't be able to
detect document comments, reading it from the file instead from the memory
could allow many more comment extraction to be possible.


-- 
Edit bug report at http://bugs.php.net/bug.php?id=54066&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=54066&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=54066&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=54066&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=54066&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=54066&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=54066&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=54066&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=54066&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=54066&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=54066&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=54066&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=54066&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=54066&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=54066&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=54066&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=54066&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=54066&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=54066&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=54066&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=54066&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=54066&r=mysqlcfg

Reply via email to