Bug #70835 [Com]: array cast returns unusable index

From: Date: Tue, 02 Feb 2016 05:32:28 +0000
Subject: Bug #70835 [Com]: array cast returns unusable index
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-198998@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 Comment by: sagar at aspl dot in Reported by: phpbugs at elygor dot de Summary: array cast returns unusable index Status: Open Type: Bug Package: Arrays related Operating System: Linux PHP Version: Irrelevant Block user comment: N Private report: N New Comment: get_object_vars in php7 also produces an array with in-accessible indices Previous Comments: ------------------------------------------------------------------------ [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 (#198998) next »