#30694 [Opn->Asn]: array_key_exists doesn't work with protected properties
| From: | tony2001@php.net | Date: | Tue, 09 Nov 2004 16:16:13 +0000 |
| Subject: | #30694 [Opn->Asn]: array_key_exists doesn't work with protected properties | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-68852@lists.php.net to get a copy of this message | ||
ID: 30694
Updated by: tony2001@php.net
Reported By: guth at fiifo dot u-psud dot fr
-Status: Open
+Status: Assigned
Bug Type: Zend Engine 2 problem
Operating System: Linux
PHP Version: 5.0.2
-Assigned To:
+Assigned To: andi
New Comment:
Assigning to Andi.
But I'd like to add that using objects as arrays of properties should
be deprecated IMO, as there are plenty of functions respecting scope
(see get_object_vars(), for example) and personally I do not see any
sense in duplicating their functionality.
Previous Comments:
------------------------------------------------------------------------
[2004-11-05 17:40:36] guth at fiifo dot u-psud dot fr
Description:
------------
Hello,
array_key_exists should return true for protected and
private vars if the are called from that scope.
Bad english to explain more, so look at the code.
Vincent Guth
Reproduce code:
---------------
<?php
class A {
protected $b = 'test';
public $c = 'test';
public function __construct() {
var_dump(array_key_exists('b', $this));
var_dump(array_key_exists('c', $this));
}
}
new A;
?>
Expected result:
----------------
bool(true)
bool(true)
Actual result:
--------------
bool(false)
bool(true)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30694&edit=1