php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73560 Incorrect object to array conversion with numerical properties names
Submitted: 2016-11-18 09:49 UTC Modified: 2016-11-18 10:28 UTC
From: anton at zebooka dot com Assigned:
Status: Duplicate Package: *General Issues
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2016-11-18 09:49 UTC] anton at zebooka dot com
Description:
------------
This bug is so old. I had reported it once, but couple of developers could not read carefully the description and closed it as bogus, still it is a bug.



Test script:
---------------
$o = new \stdClass(); 
$o->{123} = 456; 
$a = (array)$o; 
$a[123] = 777; 
var_dump($a);

Expected result:
----------------
array(1) {
  [123]=>
  int(777)
}

Actual result:
--------------
array(2) {
  ["123"]=>
  int(456)
  [123]=>
  int(777)
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-18 10:28 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2016-11-18 10:28 UTC] cmb@php.net
Duplicate of bug #66173.
 [2016-11-18 10:28 UTC] requinix@php.net
-Assigned To: cmb +Assigned To:
 [2016-11-18 10:28 UTC] requinix@php.net
Fixed in 7.2.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Jan 22 16:01:28 2019 UTC