ID:               46870
 Comment by:       crrodriguez at opensuse dot org
 Reported By:      alvin at livejournal dot dk
 Status:           Open
 Bug Type:         Scripting Engine problem
 Operating System: Linux
 PHP Version:      5.2.8
 New Comment:

looks like expected behavior...self::BAR is not defined, self::BAR
refers to the same __class__ constant "BAR" not to the __instance__ in
this case.


Previous Comments:
------------------------------------------------------------------------

[2008-12-15 15:30:43] alvin at livejournal dot dk

Description:
------------
If an abstract class attempts to access a class constant defined by its
parent, a fatal error is issued.

Reproduce code:
---------------
<?php
abstract class A
{
        public function foo ()
        {
                echo $this->bar; //works
                echo self::BAR; //fatal error
        }
}

class B extends A
{
        public $bar = 'foovar';
        const BAR = 'fooconst';
}

$x = new B;
$x->foo();
?>

Expected result:
----------------
foovarfooconst

Actual result:
--------------
foovar
Fatal error: Undefined class constant 'BAR' in...



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=46870&edit=1

Reply via email to