|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-05-05 18:34 UTC] requinix@php.net
-Status: Open
+Status: Wont fix
[2018-05-05 18:34 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 04:00:02 2025 UTC |
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.