From: vyk2rr at gmail dot com
Operating system: Ubuntu 8.10
PHP version: 5.2.9
PHP Bug Type: Scripting Engine problem
Bug description: Problem "Overloading" arrays with __set.
Description:
------------
I can't add values to an array using __set($k, $v){...}
This look like this other bug http://bugs.php.net/bug.php?id=39449 but is
not the same
This is the same bug http://bugs.php.net/bug.php?id=33941 but is closed
:S
So I'm researching in the manual
(http://www.php.net/manual/en/language.oop5.overloading.php), but there is
nothing about it
Reproduce code:
---------------
<?php
class test {
private $vars = array();
public function __set($k, $v) { $this->vars[$k] = $v; }
public function showAll(){
echo "<pre>";
foreach($this->vars as $k=>$v){
echo "$k: ";
print_r($v); echo "<br />";
}
echo "</pre>";
}
}
$t = new test();
$t->a = 'one';
$t->b = 'two';
$t->c = array('one','two');
$t->c[] = 'three';
$t->c[] = 'four';
$t->d = array( );
$t->d[] = 'one';
$t->e = 'three';
$t->showAll();
?>
Expected result:
----------------
a: one
b: two
c: Array
(
[0] => one
[1] => two
[2] => three
[3] => four
)
d: Array
(
[0] => one
)
e: three
Actual result:
--------------
a: one
b: two
c: Array
(
[0] => one
[1] => two
)
d: Array
(
)
e: three
--
Edit bug report at http://bugs.php.net/?id=47567&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=47567&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=47567&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=47567&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=47567&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=47567&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=47567&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=47567&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=47567&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=47567&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=47567&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=47567&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=47567&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=47567&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=47567&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47567&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=47567&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=47567&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=47567&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=47567&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=47567&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=47567&r=mysqlcfg