Bug #72254 [Opn->Csd]: get_object_vars() returns unusable result when keys are numeric

From: Date: Mon, 14 Nov 2016 18:33:28 +0000
Subject: Bug #72254 [Opn->Csd]: get_object_vars() returns unusable result when keys are numeric
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-205369@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72254&edit=1 ID: 72254 Updated by: ajf@php.net Reported by: unirgy at gmail dot com Summary: get_object_vars() returns unusable result when keys are numeric -Status: Open +Status: Closed Type: Bug Package: Scripting Engine problem Operating System: Any PHP Version: 7.0.6 -Assigned To: +Assigned To: ajf Block user comment: N Private report: N New Comment: The fix for this bug has been committed. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. For Windows: http://windows.php.net/snapshots/ Thank you for the report, and for helping us make PHP better. Fixed by: https://wiki.php.net/rfc/convert_numeric_keys_in_object_array_casts Previous Comments: ------------------------------------------------------------------------ [2016-10-17 07:45:00] ajf@php.net Related To: Bug #66173 ------------------------------------------------------------------------ [2016-06-02 12:32:04] cmb@php.net > Our manual is not correct about object to array cast. It does > not have to be inaccessible like above. When casting from array to object, and casting back to array, numeric keys are indeed accessible. However, constructing an object with numeric keys, and casting to array, makes numeric keys inaccessible, see <https://3v4l.org/Gsjtv>. While this is somewhat inconsistent for itself, json's behavior is consistent with this inconsistent behavior. ------------------------------------------------------------------------ [2016-05-25 00:12:01] yohgaki@php.net I'm not sure why JSON does special(?) thing. In general, array with numeric index should be able to be accessed. https://3v4l.org/VIhtW Our manual is not correct about object to array cast. It does not have to be inaccessible like above. We should avoid inconsistent behavior. It seems some overhead is required fix this inconsistency. Question would be "is it too severe or not?". ------------------------------------------------------------------------ [2016-05-24 10:37:57] cmb@php.net Isn't this basically the same issue as bug #70925? ------------------------------------------------------------------------ [2016-05-23 01:37:52] yohgaki@php.net IMO. 5.6's behavior is right one. If $var is array and has 1 as key, it must be accessible as $var[1] and/or $var['1'] ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=72254 -- Edit this bug report at https://bugs.php.net/bug.php?id=72254&edit=1

« previous php.bugs (#205369) next »