Casting of objects to array exports private/protected data

From: Date: Sat, 17 Jan 2004 15:44:29 +0000
Subject: Casting of objects to array exports private/protected data
Groups: php.internals 
Request: Send a blank email to internals+get-7152@lists.php.net to get a copy of this message
Hi internals, casting an object to array gives the possibility to get the values of protected/private member variables : <?php class some {
        public $pub = 1;
        protected $prot = 2;
        private $priv = 3;
} var_dump((array)new some()); ?> Produces : array(3) { ["pub"]=> int(1) ["*prot"]=> int(2) ["somepriv"]=> int(3) } IMO, when casting to array with (array) only the public-ly visible members should returned. Andrey

« previous php.internals (#7152) next »