From:
Operating system: windows 7
PHP version: 5.3.3
Package: Class/Object related
Bug Type: Bug
Bug description:incorrect private property handling in extended class
Description:
------------
test script $t->priv2 throws
Notice: Undefined property: test::$priv2 error.
Test script:
---------------
class base {
private $priv = "private";
protected $prot = "protected";
public $pub = "public";
final public function __get($prop){
$cv = get_class_vars(__CLASS__); $ccv =
get_class_vars(get_called_class());
var_dump('GET--------------', $prop, get_called_class(),
__CLASS__,
$this, $cv, $ccv, isset($this->$prop), property_exists($this, $prop));
return $this->$prop;
}
final public function __set($prop, $value){
$cv = get_class_vars(__CLASS__); $ccv =
get_class_vars(get_called_class());
var_dump('SET--------------', $prop, get_called_class(),
__CLASS__,
$this, $cv, $ccv, isset($this->$prop), property_exists($this, $prop));
$this->$prop = $value;
}
}
class test extends base {
private $priv2 = "private";
protected $prot2 = "protected";
public $pub2 = "public";
}
// pub2 and prot2 works.
$t = new test();
echo $t->pub2; echo $t->prot2; echo $t->priv2;
Expected result:
----------------
like base class results:
// it works.
$b = new base();
echo $b->pub; echo $b->prot; echo $b->priv;
Actual result:
--------------
Inconsistent behaviour:
1) $this has 6 properties (pub, prot, priv, pub2, prot2, priv2): good
2) get_class_vars(get_called_class()) has 5, priv2 missing: wrong
3) isset($this->$prop) returns false in this case: wrong
4) property_exists($this, $prop)) returns true: good
maybe similar bug: #47808
--
Edit bug report at http://bugs.php.net/bug.php?id=52711&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=52711&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=52711&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=52711&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=52711&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=52711&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=52711&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=52711&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=52711&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=52711&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=52711&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=52711&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=52711&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=52711&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=52711&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52711&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52711&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=52711&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=52711&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=52711&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=52711&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=52711&r=mysqlcfg