#39166 [Opn->Bgs]: array_key_exists() and magic __isset() method with objects

From: Date: Mon, 16 Oct 2006 13:08:31 +0000
Subject: #39166 [Opn->Bgs]: array_key_exists() and magic __isset() method with objects
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-103588@lists.php.net to get a copy of this message
ID: 39166 Updated by: tony2001@php.net Reported By: peters at yandex dot ru -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: Windows and Linux PHP Version: 5.1.6 New Comment: ARRAY_key_exists() first converts it to ARRAY and then continues working, which is expected. Previous Comments: ------------------------------------------------------------------------ [2006-10-16 12:57:40] peters at yandex dot ru Description: ------------ array_key_exists() may take object as second parameter and in such case I think it should use __isset() magic function of the object (if any), but it seems not to do so. The isset() and array_key_exists() may return different results for the same object, which is not good :) Reproduce code: --------------- class TestObject { function __isset($nm) { return true; } } $A = new TestObject(); var_dump(array_key_exists('test', $A)); var_dump(isset($A->test)); Expected result: ---------------- true true Actual result: -------------- false true ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39166&edit=1

« previous php.bugs (#103588) next »