#45469 [Opn->Csd]: get_object_vars($this) varies from what documentation says

From: Date: Wed, 09 Jul 2008 18:13:39 +0000
Subject: #45469 [Opn->Csd]: get_object_vars($this) varies from what documentation says
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-939@lists.php.net to get a copy of this message
ID: 45469 Updated by: felipe@php.net Reported By: czaries at gmail dot com -Status: Open +Status: Closed Bug Type: Documentation problem Operating System: WinXP PHP Version: Irrelevant New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2008-07-09 17:42:51] czaries at gmail dot com Description: ------------ The documentation for the get_object_vars() function clearly states "Gets the public properties of the given object", however this function will actually return all the properties it has ACCESS TO, including properties within the protected and private scope. This is most clearly evident when using "get_object_vars($this)" inside an object instance. Either the documentation needs to be changed to reflect the actual behavior of this function, or a boolean flag needs to be added that will alter the behavior of this function to produce the expected result without breaking backwards compatibility. I would really like to see a second parameter added to this function, because I was intending to use this function to get only the public properties of an object, as the documentation stated. Reproduce code: --------------- <?php class Testing { private $dontShowMe = true; protected $dontShowMeEither = true; public $showMe = true; public function getData() { return get_object_vars($this); } } $test = new Testing(); print_r($test->getData()); ?> Expected result: ---------------- Array ( [showMe] => 1 ) Actual result: -------------- Array ( [dontShowMe] => 1 [dontShowMeEither] => 1 [showMe] => 1 ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45469&edit=1

« previous php.doc.bugs (#939) next »