#30140 [Bgs->Opn]: Problem with array in static properties
| From: | guth at fiifo dot u-psud dot fr | Date: | Sat, 07 May 2005 00:51:05 +0000 |
| Subject: | #30140 [Bgs->Opn]: Problem with array in static properties | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-78735@lists.php.net to get a copy of this message | ||
ID: 30140
User updated by: guth at fiifo dot u-psud dot fr
Reported By: guth at fiifo dot u-psud dot fr
-Status: Bogus
+Status: Open
Bug Type: Zend Engine 2 problem
Operating System: *
PHP Version: 5CVS-2005-03-07
New Comment:
This bug is not related to bug #30934.
The following code works fine ($test is not initialized with an array)
:
<?php
class A {
public static $test = 'I Work fine';
public function set($var) {
self::$test = $var;
}
public static function view() {
var_dump(self::$test);
}
}
class B extends A {
public static function view() {
var_dump(self::$test);
}
}
$class = new B;
$class->set(array('key' => 'value'));
A::view();
B::view();
?>
Result :
array(1) { ["key"]=> string(5) "value" }
array(1) { ["key"]=> string(5) "value" }
Previous Comments:
------------------------------------------------------------------------
[2005-04-05 23:24:10] tony2001@php.net
Yet another duplicate of bug #30934.
------------------------------------------------------------------------
[2004-09-18 17:02:22] guth at fiifo dot u-psud dot fr
Description:
------------
[ sorry for english ]
There is a problem with static properties initialized as
an array in classes.
In the following code, if you replace "public static $test
= array();" by "public static $test;" or if you initialize
the property with not an array ("public static $test =
12;" for example), it works as expected.
Reproduce code:
---------------
<?
class A {
public static $test = array();
public function set($var) {
self::$test = $var;
}
public static function view() {
var_dump(self::$test);
}
}
class B extends A {
public static function view() {
var_dump(self::$test);
}
}
$class = new B;
$class->set(array('key' => 'value'));
A::view();
B::view();
?>
Expected result:
----------------
array(1) { ["key"]=> string(5) "value" }
array(1) { ["key"]=> string(5) "value" }
Actual result:
--------------
array(1) { ["key"]=> string(5) "value" }
array(0) { }
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30140&edit=1