#36214 [NEW]: Conditional operator fails to work properly when both __set and __get are set
| From: | pexu at lyseo dot edu dot ouka dot fi | Date: | Mon, 30 Jan 2006 18:34:56 +0000 |
| Subject: | #36214 [NEW]: Conditional operator fails to work properly when both __set and __get are set | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-92654@lists.php.net to get a copy of this message | ||
From: pexu at lyseo dot edu dot ouka dot fi
Operating system: Windows XP
PHP version: 5.1.2
PHP Bug Type: Scripting Engine problem
Bug description: Conditional operator fails to work properly when both __set and __get are set
Description:
------------
When both __set and __get are set, conditional operator "?" fails to work
when used to return variables from __get when working with arrays.
A normal if .. else clause however works fine. With non-array variables
there's no problem, either.
If __set is not used, this bug doesn't seem to appear.
Reproduce code:
---------------
class overload
{
private $array = array();
public function __set($key, $value)
{
$this->array[$key] = $value;
}
public function __get($key)
{
return isset($this->array[$key])
? $this->array[$key]
: null;
}
}
$ol = new overload; $ol->arr = array();
array_push($ol->arr, "element");
var_dump($ol->arr);
Expected result:
----------------
array(1) {
[0]=>
string(7) "element"
}
Actual result:
--------------
array(0) {
}
--
Edit bug report at http://bugs.php.net/?id=36214&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36214&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36214&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36214&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=36214&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=36214&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=36214&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=36214&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=36214&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=36214&r=support
Expected behavior: http://bugs.php.net/fix.php?id=36214&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=36214&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=36214&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=36214&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36214&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=36214&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=36214&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=36214&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=36214&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=36214&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=36214&r=mysqlcfg