Re: [RFC] Class instances counter
| From: | Joe Watkins | Date: | Tue, 09 Apr 2013 10:30:34 +0000 |
| Subject: | Re: [RFC] Class instances counter | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-67015@lists.php.net to get a copy of this message | ||
On 04/09/2013 11:23 AM, Laruence wrote:
if a class need that, it can implement a interface like instance_counter, which will simply can implement like: class A {As mentioned in the RFC, that's an ugly and very intrusive solution, that is not always practical (you wouldn't want to wrap every internal class you wish to see the count of).public static $instance_counter = 0;public function __construct() { self::$instance_counter++; }public function __destruct() { self::$instance_counter--; };public static function get_counter() { return self::$instance_counter; }} thanks On Tue, Apr 9, 2013 at 6:18 PM, Frank Liepert <Frank.Liepert@gmx.de> wrote:Hello internals, I updated the RFC (https://wiki.php.net/rfc/instance_counter): - added support for a class name, so the function can be narrowed down to a specific class - added use case -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php