Bug #71950 [NEW]: static variables are incorrect after call parent::method()
| From: | michael dot bilcot at gmail dot com | Date: | Sun, 03 Apr 2016 18:18:47 +0000 |
| Subject: | Bug #71950 [NEW]: static variables are incorrect after call parent::method() | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-200327@lists.php.net to get a copy of this message | ||
From: michael dot bilcot at gmail dot com
Operating system: Windows 10 64
PHP version: Irrelevant
Package: Class/Object related
Bug Type: Bug
Bug description:static variables are incorrect after call parent::method()
Description:
------------
When you call parent::method() and there is a static variable in this,
the value returned to all inherited objects is the same
Test script:
---------------
class A
{
function a()
{
static $i;
if (!$i)
{
$i = $this->value;
}
return $i;
}
}
class B extends A
{
public $value = 'B';
}
class C extends A
{
public $value = 'C';
function a()
{
return parent::a();
}
}
$b = new B;
echo $b->a();
$c = new C;
echo $c->a();
Expected result:
----------------
BC
Actual result:
--------------
BB
--
Edit bug report at https://bugs.php.net/bug.php?id=71950&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71950&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71950&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71950&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=71950&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=71950&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=71950&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=71950&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=71950&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=71950&r=support
Expected behavior: https://bugs.php.net/fix.php?id=71950&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=71950&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=71950&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=71950&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71950&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=71950&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=71950&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=71950&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71950&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=71950&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=71950&r=mysqlcfg