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

From: Date: Fri, 18 Jul 2008 14:57:18 +0000
Subject: #45469 [Csd->Opn]: get_object_vars($this) varies from what documentation says
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-963@lists.php.net to get a copy of this message
ID: 45469 User updated by: czaries at gmail dot com Reported By: czaries at gmail dot com -Status: Closed +Status: Open Bug Type: Documentation problem Operating System: WinXP PHP Version: Irrelevant New Comment: Thanks for the update and for altering the language in the documentation. You did miss one line though :) http://www.php.net/get_object_vars get_object_vars (PHP 4, PHP 5) get_object_vars — Gets the public properties of the given object Description array get_object_vars ( object $object ) Gets the accessible non-static properties of the given object according to scope. The descriptor line above the blue boxes has not been updated like the one in the "Description" blue box has. Previous Comments: ------------------------------------------------------------------------ [2008-07-09 18:13:36] felipe@php.net 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. ------------------------------------------------------------------------ [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 (#963) next »