Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64640 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77856 invoked from network); 7 Jan 2013 17:10:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Jan 2013 17:10:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=nathan.bruer@starin.biz; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=nathan.bruer@starin.biz; sender-id=unknown Received-SPF: error (pb1.pair.com: domain starin.biz from 207.198.105.69 cause and error) X-PHP-List-Original-Sender: nathan.bruer@starin.biz X-Host-Fingerprint: 207.198.105.69 hawk.starindns.com Received: from [207.198.105.69] ([207.198.105.69:44098] helo=hawk.starindns.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 70/B0-08897-D810BE05 for ; Mon, 07 Jan 2013 12:10:37 -0500 Received: from 173-167-160-145-illinois.hfc.comcastbusiness.net ([173.167.160.145]:52913 helo=NathanBruerHP) by hawk.starindns.com with esmtpa (Exim 4.80) (envelope-from ) id 1TsGDZ-00078z-As for internals@lists.php.net; Mon, 07 Jan 2013 11:10:33 -0600 Sender: "Nathan Bruer" To: Date: Mon, 7 Jan 2013 11:10:27 -0600 Message-ID: <102501cdecf9$e427d540$ac777fc0$@starin.biz> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_1026_01CDECC7.998F6110" X-Mailer: Microsoft Outlook 14.0 Thread-Index: Ac3s9P24LQFOsJEFQruZrtWoJd6H9g== Content-Language: en-us X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - hawk.starindns.com X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - starin.biz X-Get-Message-Sender-Via: hawk.starindns.com: authenticated_id: nathan.bruer@starin.biz Subject: new Class ReflectionZVal From: nathan@starin.biz ------=_NextPart_000_1026_01CDECC7.998F6110 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 ------=_NextPart_000_1026_01CDECC7.998F6110--