Newsgroups: php.internals,php.internals Path: news.php.net Xref: news.php.net php.internals:44110 php.internals:44111 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30879 invoked from network); 1 Jun 2009 02:02:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Jun 2009 02:02:06 -0000 X-Host-Fingerprint: 82.41.135.70 82-41-135-70.cable.ubr02.grth.blueyonder.co.uk Received: from [82.41.135.70] ([82.41.135.70:13779] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 81/57-20810-D96332A4 for ; Sun, 31 May 2009 22:02:06 -0400 To: internals@lists.php.net,Matt Wilson Message-ID: <4A23367A.9070804@gmail.com> Date: Mon, 01 Jun 2009 03:01:30 +0100 User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 CC: internals@lists.php.net References: <32074276-E941-45C8-B1A1-9A6EB34F4D7E@gmail.com> <4A23330D.4000205@gmail.com> <8F0784FF-AD51-4A97-9C3A-6B4A3F45D260@gmail.com> In-Reply-To: <8F0784FF-AD51-4A97-9C3A-6B4A3F45D260@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 82.41.135.70 Subject: Re: [PHP-DEV] need inverted __sleep? From: nrixham@gmail.com (Nathan Rixham) matt.. that's public properties on a single class - see the usecase use case: mwilson@MattW-Mac:~$ php -r 'class a { public $a, $b, $c, $d; public > function __sleep() { return array_diff( array_keys( (array) $this), > array("b","c")); } } $a = new a; var_dump($a->__sleep());' > array(2) { > [0]=> > string(1) "a" > [3]=> > string(1) "d" > } > > On May 31, 2009, at 8:46 PM, Nathan Rixham wrote: > >> Matt Wilson wrote: >>> get_class_vars + array_diff >> >> cheers but nope; as the manual says >> "Returns an associative array of default public properties of the class" >> >> need private and inherited private >> >>> On May 31, 2009, at 8:04 PM, Nathan Rixham wrote: >>>> Hi All, >>>> >>>> hoping somebody can help me here.. >>>> >>>> I need to implement an inverted __sleep method, by which I mean to >>>> specify what variables should not be included. >>>> >>>> use case: >>>> >>> class base >>>> { >>>> private $notToBeSerialized; >>>> >>>> public function __sleep() >>>> { >>>> // TODO code return instance properties excluding $notToBeSerialized >>>> } >>>> >>>> } >>>> >>>> class foo extends base >>>> { >>>> private $bar; >>>> } >>>> >>>> class poo extends foo >>>> { >>>> private $baz; >>>> } >>>> >>>> $p = new poo; >>>> echo serialize($p); >>>> >>>> ---- >>>> >>>> I've tried using get_object_vars($this), and ReflectionObject($this) >>>> both of which don't include all the properties of the instance. >>>> >>>> the only way I can see to get all the properties of the instance is >>>> to serialize($this) then parse the string, but that's just wrong and >>>> what would sleep return on the first call to serialize. >>>> >>>> any help greatly appreciated. >>>> >>>> regards, >>>> >>>> nathan >>>> >>>> -- >>>> PHP Internals - PHP Runtime Development Mailing List >>>> To unsubscribe, visit: http://www.php.net/unsub.php >>>> >> >