Bug #79236 [NEW]: Uninitialized properties are hidden from get_object_vars
| From: | raincomplain at outlook dot com | Date: | Thu, 06 Feb 2020 16:09:21 +0000 |
| Subject: | Bug #79236 [NEW]: Uninitialized properties are hidden from get_object_vars | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-225392@lists.php.net to get a copy of this message | ||
From: raincomplain at outlook dot com
Operating system: Irrelevant
PHP version: 7.4.2
Package: Class/Object related
Bug Type: Bug
Bug description:Uninitialized properties are hidden from get_object_vars
Description:
------------
Little bit of hesitation on this one but I had to report it since no
answers were found on SO
https://stackoverflow.com/q/60087384/5999372
So uninitialized properties are hidden from get_object_vars but exposed
to get_class_vars like as Null
Test script:
---------------
class A {
public int $num1;
public $num2;
}
var_dump(get_object_vars(new A));
var_dump(get_class_vars('A'));
Expected result:
----------------
array(1) {
["num1"]=>
NULL
["num2"]=>
NULL
}
array(2) {
["num1"]=>
NULL
["num2"]=>
NULL
}
Here to be honest I'm not sure whether get_class_vars should not show
num1 and treat it as Null or whether get_object_class should show num1
either, but I assume they should output the same result especially since
the properties are public.
Actual result:
--------------
array(1) {
["num2"]=>
NULL
}
array(2) {
["num1"]=>
NULL
["num2"]=>
NULL
}
--
Edit bug report at https://bugs.php.net/bug.php?id=79236&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79236&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79236&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79236&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79236&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79236&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79236&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79236&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79236&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79236&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79236&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79236&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79236&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79236&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79236&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79236&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79236&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79236&r=mysqlcfg