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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2021 The PHP Group
All rights reserved.
Last updated: Wed Dec 08 13:03:41 2021 UTC