#45469 [NEW]: get_object_vars($this) varies from what documentation says

From: Date: Wed, 09 Jul 2008 17:42:52 +0000
Subject: #45469 [NEW]: get_object_vars($this) varies from what documentation says
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-938@lists.php.net to get a copy of this message
From: czaries at gmail dot com Operating system: WinXP PHP version: Irrelevant PHP Bug Type: Documentation problem Bug description: get_object_vars($this) varies from what documentation says 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 bug report at http://bugs.php.net/?id=45469&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45469&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45469&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45469&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=45469&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=45469&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=45469&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=45469&r=needscript Try newer version: http://bugs.php.net/fix.php?id=45469&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=45469&r=support Expected behavior: http://bugs.php.net/fix.php?id=45469&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=45469&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=45469&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=45469&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45469&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=45469&r=dst IIS Stability: http://bugs.php.net/fix.php?id=45469&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=45469&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=45469&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=45469&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=45469&r=mysqlcfg

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