#47384 [NEW]: self and parent aren't using the class where defined
From: alreece45 at gmail dot com
Operating system: Linux/Windows
PHP version: Irrelevant
PHP Bug Type: Documentation problem
Bug description: self and parent aren't using the class where defined
Description:
------------
When defining properties using constants with parent or self, they are
resolved using computed classes instead of defined classes.
This behavior appears to have existed since PHP 5.0.5 and still exists in
PHP 5.3beta3, a 5.3 CVS snapshot (200902122000), and 5.2 CVS snapshot
(200902121200).
Someone has brought this up before in php-internals:
http://marc.info/?l=php-internals&m=118839969729862&w=2
Reproduce code:
---------------
<?php
class Father {
const my_name = 'Father';
public $name = self::my_name;
}
class Son extends Father {
const my_name = 'Son';
public $daddy = parent::my_name;
}
class GrandSon extends Son {
const my_name = 'Grandchild';
}
$older = new GrandSon;
echo "{$older->name}\n";
echo "{$older->daddy}\n";
?>
Expected result:
----------------
Father
Father
Actual result:
--------------
Grandchild
Son
--
Edit bug report at http://bugs.php.net/?id=47384&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47384&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47384&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47384&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=47384&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47384&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=47384&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=47384&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=47384&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=47384&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=47384&r=support
Expected behavior: http://bugs.php.net/fix.php?id=47384&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=47384&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=47384&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=47384&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47384&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=47384&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=47384&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=47384&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=47384&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=47384&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=47384&r=mysqlcfg
Thread (8 messages)
- alreece45 at gmail dot com