Bug #70835 [Opn->Dup]: array cast returns unusable index

From: Date: Mon, 08 Aug 2016 12:13:15 +0000
Subject: Bug #70835 [Opn->Dup]: array cast returns unusable index
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203078@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70835&edit=1 ID: 70835 Updated by: cmb@php.net Reported by: phpbugs at elygor dot de Summary: array cast returns unusable index -Status: Open +Status: Duplicate Type: Bug Package: Arrays related Operating System: Linux PHP Version: Irrelevant -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: I'm marking this as duplicate of bug #71208, because the other ticket is already assigned. Previous Comments: ------------------------------------------------------------------------ [2016-02-02 05:32:26] sagar at aspl dot in get_object_vars in php7 also produces an array with in-accessible indices ------------------------------------------------------------------------ [2015-12-23 23:35:59] ajf@php.net It's even worse in PHP 7: get_object_vars() also produces an array with inaccessible indices. ------------------------------------------------------------------------ [2015-11-02 11:34:36] phpbugs at elygor dot de Description: ------------ Converting a stdClass object with (array) behaves different than get_object_vars() I tested this with PHP 5.4.45 5.5.18 and 5.6.2 Test script: --------------- $tmp = json_decode(json_encode( (object) array('cars' => (object) array("1" => "one")) )); // expected $cars = array("1" => "one"); $cars = (array) $tmp->cars; var_dump(array_key_exists("1", $cars)); // expected true, returns false var_dump(array_key_exists(1, $cars)); // expected true, returns false $cars = get_object_vars($tmp->cars); var_dump(array_key_exists("1", $cars)); // expected true, returns true var_dump(array_key_exists(1, $cars)); // expected true, returns true ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70835&edit=1

« previous php.bugs (#203078) next »