php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62292 Casting object to array brokes isset on numerical keys
Submitted: 2012-06-11 13:56 UTC Modified: 2015-12-23 23:13 UTC
Votes:5
Avg. Score:3.2 ± 0.7
Reproduced:5 of 5 (100.0%)
Same Version:2 (40.0%)
Same OS:2 (40.0%)
From: hosiplan at gmail dot com Assigned:
Status: Duplicate Package: Class/Object related
PHP Version: 5.3.13 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: hosiplan at gmail dot com
New email:
PHP Version: OS:

 

 [2012-06-11 13:56 UTC] hosiplan at gmail dot com
Description:
------------
Casting object to array brokes isset on numerical keys

Test script:
---------------
$obj = json_decode('{"100":[10],"120":[20]}');
$map = (array)$obj;

var_dump(
	isset($obj->{100}),
	isset($obj->{"100"}),
	isset($map[100]),
	isset($map["100"])
);

Expected result:
----------------
bool(false)
bool(true)
bool(false)
bool(true)

Actual result:
--------------
bool(true)
bool(true)
bool(false)
bool(false)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-05-23 09:57 UTC] p dot scheit at ps-webforge dot com
this seems to be a possible duplicate of https://bugs.php.net/bug.php?id=45959
 [2015-12-23 23:13 UTC] ajf@php.net
-Status: Open +Status: Duplicate
 [2015-12-23 23:13 UTC] ajf@php.net
Duplicate of https://bugs.php.net/bug.php?id=66173
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun May 04 21:01:31 2025 UTC