Re: Casting of objects to array exports private/protected data

From: Date: Sat, 17 Jan 2004 16:05:48 +0000
Subject: Re: Casting of objects to array exports private/protected data
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-7153@lists.php.net to get a copy of this message
On Sat, 17 Jan 2004 16:44:29 +0100 Andrey Hristov <php@hristov.com> wrote: > IMO, when casting to array with (array) only the public-ly visible > members should returned. Dunno, E_STRICT (as you can access them without notice/warning without this flag)? In the same manner: <?php error_reporting(E_STRICT); class some { public $pub = 1; protected $prot = 2; private $priv = 3; } class any extends some { public $pub1 = 1; function dump() { var_dump($this); } } var_dump((array)new any()); $a = new any; $a->dump(); ?> a var_dump should dump protected props from the parent class as they are visible. Note the "funny" thing is that var_dump() alone do not display the public|protected props, whatever is the context call. IMHO, that sounds not very consistent, but only imho... pierre

« previous php.internals (#7153) next »