Re: [PHP-DEV] need inverted __sleep?

2009-06-01 Thread Nathan Rixham
Jonathan Tapicer wrote: Hi, Matt's approach works also for your usecase, casting to array returns all the properties of the class and base classes, but it has some problems: for private properties the class name is added before the property name, and for protected properties * is added, both

Re: [PHP-DEV] need inverted __sleep?

2009-06-01 Thread Kalle Sommer Nielsen
Hi 2009/6/1 Nathan Rixham nrix...@gmail.com: 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 I've recently fixed the manual about get_class_vars, since PHP 5.0.5 get_class_vars,

[PHP-DEV] need inverted __sleep?

2009-05-31 Thread Nathan Rixham
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: ?php class base { private $notToBeSerialized; public function __sleep() { // TODO code return instance properties

Re: [PHP-DEV] need inverted __sleep?

2009-05-31 Thread Matt Wilson
get_class_vars + array_diff 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: ?php class base { private

Re: [PHP-DEV] need inverted __sleep?

2009-05-31 Thread Nathan Rixham
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

Re: [PHP-DEV] need inverted __sleep?

2009-05-31 Thread Matt Wilson
mwil...@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

Re: [PHP-DEV] need inverted __sleep?

2009-05-31 Thread Nathan Rixham
matt.. that's public properties on a single class - see the usecase use case: ?php class base { private $notToBeSerialized; public function __sleep() { // TODO code return instance properties excluding $notToBeSerialized } } class foo extends base { private $bar; } class poo

Re: [PHP-DEV] need inverted __sleep?

2009-05-31 Thread Jonathan Tapicer
Hi, Matt's approach works also for your usecase, casting to array returns all the properties of the class and base classes, but it has some problems: for private properties the class name is added before the property name, and for protected properties * is added, both things added are between