|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-07-09 18:13 UTC] felipe@php.net
[2008-07-18 14:57 UTC] czaries at gmail dot com
[2008-11-05 10:42 UTC] vrana@php.net
[2020-02-07 06:10 UTC] phpdocbot@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 09:00:02 2026 UTC |
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 )