ID:               28176
 Updated by:       [EMAIL PROTECTED]
 Reported By:      benjcarson at digitaljunkies dot ca
-Status:           Bogus
+Status:           Open
 Bug Type:         Zend Engine 2 problem
 Operating System: Linux
 PHP Version:      5CVS-2004-04-27 (dev)
 New Comment:

Hum. I think it's a good idea to modify isset() to call 
__get() and __set().

Otherwise, it breaks the principle of encapsulation. As 
a user of the class, I'm not supposed to know/care if 
I'm accessing the properties directly or if the 
developer has overloaded the property handler.

Besides, how else as a user can I check if a property is 
set if I can't use isset()?


Previous Comments:
------------------------------------------------------------------------

[2004-04-27 08:31:59] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is correct behavior, isset() does not call the __get and __set
handlers.

------------------------------------------------------------------------

[2004-04-27 03:57:42] benjcarson at digitaljunkies dot ca

Description:
------------
isset() returns false for variables that are returned using the __get()
method, even though the variables are set and their values are returned
properly.

Reproduce code:
---------------
<?php

class Foo { var $arr; function __get($var) { return $this->arr[$var]; }
}
class Bar { var $var; function __get($tmp) { return $this->var; } }

$f = new Foo();
$f->arr["key"] = "val";

var_dump($f->key);           // Value returned correctly
var_dump(isset($f->key));    // isset() disagrees

$b = new Bar();
$b->var = "blah";

var_dump($b->dummy);         // Value returned correctly
var_dump(isset($b->dummy));  // isset() returns false
?>

Expected result:
----------------
string(3) "val"
bool(true)
string(4) "blah"
bool(true)


Actual result:
--------------
string(3) "val"
bool(false)
string(4) "blah"
bool(false)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=28176&edit=1

Reply via email to