#47291 [NEW]: get and set are not fixed
From: ies_clan at hotmail dot com
Operating system: Windows XP
PHP version: 5.2.8
PHP Bug Type: Class/Object related
Bug description: get and set are not fixed
Description:
------------
get and set are not fixed: http://bugs.php.net/bug.php?id=39449
Reproduce code:
---------------
<?php
error_reporting(E_ALL | E_STRICT);
abstract class Property {
protected $vars = array();
public function &__get($Key)
{
if(array_key_exists($Key, $this->vars)){
return $this->vars[$Key];
}
}
public function __set($Key, $Value)
{
$this->vars[$Key] = $Value;
}
}
class Human extends Property {}
class Pet extends Property {}
$Pet = new Pet();
$Pet->Name = 'I am a pet';
$Human = new Human();
$Human->Mypet = $Pet;
$Human->Mypet->Options['HumanID'] = 1;
print_r($Human);
?>
Expected result:
----------------
Human Object
(
[vars:protected] => Array
(
[Mypet] => Pet Object
(
[vars:protected] => Array
(
[Name] => I am a pet
)
)
)
)
Actual result:
--------------
Notice: Only variable references should be returned by reference in
D:\apache\htdocs\phpbug\index.php on line 15
Notice: Indirect modification of overloaded property Pet::$Options has no
effect in D:\apache\htdocs\phpbug\index.php on line 31
Human Object
(
[vars:protected] => Array
(
[Mypet] => Pet Object
(
[vars:protected] => Array
(
[Name] => I am a pet
)
)
)
)
--
Edit bug report at http://bugs.php.net/?id=47291&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47291&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47291&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47291&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=47291&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47291&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=47291&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=47291&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=47291&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=47291&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=47291&r=support
Expected behavior: http://bugs.php.net/fix.php?id=47291&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=47291&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=47291&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=47291&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47291&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=47291&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=47291&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=47291&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=47291&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=47291&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=47291&r=mysqlcfg
Thread (1 message)
- ies_clan at hotmail dot com