Bug #78954 [NEW]: get_object_vars not returning typed empty properties
From: thomas dot wiringa at gmail dot com
Operating system: Arch Linux / Linux 5.4.2
PHP version: 7.4.0
Package: Scripting Engine problem
Bug Type: Bug
Bug description:get_object_vars not returning typed empty properties
Description:
------------
When using typed properties such as public string $foo; or `public
?string $foo; get_object_vars does not return [ 'foo' => NULL ]` if
this property was never set. However, pre-7.4 it would return the
property in the array if it was defined as public $foo; but never
set/changed.
Test script:
---------------
https://3v4l.org/eg6o0
Expected result:
----------------
string(20) "bar exists in $vars"
string(28) "foobar exists in $vars"
string(20) "foo exists in $vars"
Actual result:
--------------
string(19) "bar exists in $vars"
Warning: assert(): assert(array_key_exists('foobar', $vars)) failed in
/in/eg6o0 on line 12
string(30) "foobar does not exist in $vars"
Warning: assert(): assert(array_key_exists('foo', $vars)) failed in
/in/eg6o0 on line 13
string(27) "foo does not exist in $vars"
--
Edit bug report at https://bugs.php.net/bug.php?id=78954&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=78954&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78954&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78954&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78954&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78954&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78954&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78954&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78954&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78954&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78954&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78954&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=78954&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78954&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78954&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78954&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78954&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78954&r=mysqlcfg
Thread (3 messages)
- thomas dot wiringa at gmail dot com