Doc #80019 [Opn->Nab]: get_object_vars() does not return uninitialized properties
| From: | cmb@php.net | Date: | Fri, 28 Aug 2020 08:28:15 +0000 |
| Subject: | Doc #80019 [Opn->Nab]: get_object_vars() does not return uninitialized properties | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-17830@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80019&edit=1
ID: 80019
Updated by: cmb@php.net
Reported by: brego at hey dot com
Summary: get_object_vars() does not return uninitialized
properties
-Status: Open
+Status: Not a bug
Type: Documentation Problem
Package: Documentation problem
Operating System: macOS 10.15.6
PHP Version: 7.4.9
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
The documentation states:
| Gets the accessible non-static properties of the given object
| according to scope.
$baz is not accessible[1], though.
[1] <https://3v4l.org/A0jIq>
Previous Comments:
------------------------------------------------------------------------
[2020-08-26 10:22:16] brego at hey dot com
Description:
------------
---
From manual page: https://php.net/function.get-object-vars
---
I realize the code works as intended#1 however the documentation of get_object_vars does not mention
that uninitialized object properties will not be returned.
#1: https://bugs.php.net/bug.php?id=79236
Test script:
---------------
class A {
public function get() {
var_dump(get_object_vars($this));
}
}
class B extends A {
public $foo;
public $bar = 'bar';
public string $baz;
}
$b = new B;
$b->get();
Expected result:
----------------
array(3) {
["foo"]=>
NULL
["bar"]=>
string(3) "bar"
["baz"]=>
uninitialized // <- or something different?
}
Actual result:
--------------
array(2) {
["foo"]=>
NULL
["bar"]=>
string(3) "bar"
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80019&edit=1