#30642 [Opn->Bgs]: static variables not inherited by other classes when extended
| From: | tony2001@php.net | Date: | Fri, 19 Nov 2004 16:35:00 +0000 |
| Subject: | #30642 [Opn->Bgs]: static variables not inherited by other classes when extended | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-69270@lists.php.net to get a copy of this message | ||
ID: 30642
Updated by: tony2001@php.net
Reported By: keith dot ward at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: *
PHP Version: 5.*
Assigned To: helly
New Comment:
Nope, #30451 has nothing to do with it.
And yes, var_dump() DOES NOT show static members (see #30820, this
issue is correctly reported there).
I'm closing this report, as there is no sense in keeping duplicates.
Previous Comments:
------------------------------------------------------------------------
[2004-11-03 17:34:06] ashk06 at dsl dot pipex dot com
http://bugs.php.net/bug.php?id=30451
Seems to be a duplicate of this .
------------------------------------------------------------------------
[2004-11-02 01:52:15] keith dot ward at gmail dot com
This is NOT BOGUS , had you bothered to read the results , you would
see that var_dump , did indeed return the static member myvar( from
class A ) .
If returning static members with var_dump was not to be supported
(that's what it sounds like) it should not show up in the first
var_dump either !.
In Addition ... using echo parent::$myvar; or echo $this->myvar within
class B , also returns nothing . So this bug is perfectly valid .
------------------------------------------------------------------------
[2004-11-01 11:51:48] helly@php.net
var_dump() doesn't show static members.
And don't reopen this report - check your code
------------------------------------------------------------------------
[2004-11-01 04:53:01] keith dot ward at gmail dot com
Description:
------------
When using extend to extend a class . Static variables are not
inherited .
Reproduce code:
---------------
class a
{
public static $myvar;
public function __construct()
{
$this->myvar = '1';
echo ' Set myvar to 1 ... ' . "\n";
var_dump($this);
}
}
$a = new a();
class b extends a
{
function __construct()
{
echo 'DUmping from class b' . "\n";
var_dump($this);
}
}
$a = new b();
?>
Expected result:
----------------
Set myvar to 1 ...
object(a)#1 (1) {
["myvar"]=>
string(1) "1"
}
Dumping from class b
object(b)#2 (1) {
["myvar"]=>
string(1) "1"
}
Actual result:
--------------
Set myvar to 1 ...
object(a)#1 (1) {
["myvar"]=>
string(1) "1"
}
Dumping from class b
object(b)#2 (0) {
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30642&edit=1