#29917 [NEW]: isset() always return

From: Date: Tue, 31 Aug 2004 14:00:43 +0000
Subject: #29917 [NEW]: isset() always return
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-65517@lists.php.net to get a copy of this message
From:             dasch at ulmail dot net
Operating system: Linux
PHP version:      5.0.1
PHP Bug Type:     Class/Object related
Bug description:  isset() always return

Description:
------------
When trying to determine whether or not a property in an overloaded object
is set, isset() always returns FALSE. This is not the case with objects
that isn't overloaded (doesn't have a __get() method defined).

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

class OO
{
	private $elem = array("a" => 1);
	
	public function __get ($prop)
	{
		if (isset($this->elem[$prop])) {
			return $this->elem[$prop];
		} else {
			return NULL;
		}
	}
	
	public function __set ($prop, $val)
	{
		$this->elem[$prop] = $val;
	}
}

$o = new OO();

echo isset($o->a) ? "yes\n" : "no\n";
echo isset($o->b) ? "yes\n" : "no\n";

echo is_null($o->a) ? "yes\n" : "no\n";
echo is_null($o->b) ? "yes\n" : "no\n";

?>

Expected result:
----------------
yes
no
no
yes

Actual result:
--------------
no
no
no
yes

-- 
Edit bug report at http://bugs.php.net/?id=29917&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=29917&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=29917&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=29917&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=29917&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=29917&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=29917&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=29917&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=29917&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=29917&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=29917&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=29917&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=29917&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=29917&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=29917&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=29917&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=29917&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=29917&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=29917&r=float


Thread (13 messages)

« previous php.bugs (#65517) next »