I wanted some thought from you guys about the idea of giving PHP scripts the ability to read some internal information about variables such as ZVals.
The idea of how this reflection class would work would be something like: Class ReflectionZVal { // Retains info about the variable referenced function __construct(&$variable); // Returns if the referenced variable function valueExists(); // Returns a ref to the variable or throws error if value is gone. function &getValue(); // Returns the reference count of the variable function getRefCount(); // Returns the current type associated with the referenced variable function getType(); // Returns bool of if getValueReflection() is callable. (see note below) function isValueReflectable(); // Returns a new instance of ReflectionZVal for the value of variable passed in construct. (returns null and throws error if value is not a ref of a variable) function getValueReflection(); } The idea of this class would give PHP the ability to read reference count info and have read-only access to values stored in variables without causing PHP to not be able to use the internal garbage collector. An example of how this could be useful would be if you had a class structure that matched a database table structure. Every time a new record of the table was returned it constructed a new object. It is more practical to have the class store each object that was constructed into a static variable attached to each class structure and when a new record is requested it first checks to see if the object with the same row has already been constructed and use/update that object instead of making (possibly) many duplicates. This gives the code structure the ability that if the same record was requested then later in the execution the same row was requested again and modified it would also modify it everywhere that object/row was already requested. The issue with this structure is that php's garbage collector will never clean up those constructed objects because the class needs a reference to them and cannot know if other places in the code has references to them. If a reflection like this one was available it would give the ability to contain a reference to variables/pointers without increasing the reference count. It would allow a class structure (like stated above) to call it's own garbage collector every once in a while to clean up those ReflectionZVal objects by checking the result of ReflectionZVal:: valueExists (). Is there anything obvious (limitation wise) that I am missing or is this RFC'able? Software Developer Nathan Bruer