Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:44109 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29464 invoked from network); 1 Jun 2009 01:56:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Jun 2009 01:56:42 -0000 Authentication-Results: pb1.pair.com header.from=shadda@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=shadda@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.187 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: shadda@gmail.com X-Host-Fingerprint: 209.85.216.187 mail-px0-f187.google.com Received: from [209.85.216.187] ([209.85.216.187:61320] helo=mail-px0-f187.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F2/07-20810-955332A4 for ; Sun, 31 May 2009 21:56:41 -0400 Received: by pxi17 with SMTP id 17so562903pxi.29 for ; Sun, 31 May 2009 18:56:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:cc:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer; bh=bB1fhIqj9C3grWciTIeph2HxmAzxlAILXPET4TtPsOI=; b=R8GJEQvZrLozznt+ayIvFmQ3MHuHDqHZtxFz+9TBcjc86oc7gllaTNxD3PqLquCk4o ufUQPhnGOJjNvUr6edBri9/L+NXrfmqliwACOLfn5HqjY3WDCXpZdfmLUpa4Ul4TBZCP 3ieiHp5T4vwzdASHmFHK2cJhi5MPp5ipDNyW4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=cc:message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=NEiW6JYQoEbK68OjXUOBBTakO5fXt6UMmd09ZJRj2rpglBQGZkSlYvlw5NRFXQ9laX 26dKkFm9w3izJSX3esi1unv5xD+Lw30haPOq6Hu9CL9UZLbxiujH1l9vY/VMBt1yDdIc Pl56dp+HzaHtk1LUO+zvdp2zH1GAh0oQFoOwY= Received: by 10.140.247.13 with SMTP id u13mr5504812rvh.288.1243821398733; Sun, 31 May 2009 18:56:38 -0700 (PDT) Received: from ?192.168.1.159? ([75.87.134.66]) by mx.google.com with ESMTPS id k37sm13364053rvb.28.2009.05.31.18.56.36 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 31 May 2009 18:56:37 -0700 (PDT) Cc: internals@lists.php.net Message-ID: <8F0784FF-AD51-4A97-9C3A-6B4A3F45D260@gmail.com> To: nrixham@gmail.com In-Reply-To: <4A23330D.4000205@gmail.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v935.3) Date: Sun, 31 May 2009 20:59:32 -0500 References: <32074276-E941-45C8-B1A1-9A6EB34F4D7E@gmail.com> <4A23330D.4000205@gmail.com> X-Mailer: Apple Mail (2.935.3) Subject: Re: [PHP-DEV] need inverted __sleep? From: shadda@gmail.com (Matt Wilson) 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 >>> >