[PHP-BUG] Req #51391 [NEW]: Static methods called as self::fun() always resolve to class of its declaration

[email protected] ("byoung at bigbluehat dot com")
Newsgroups php.bugs
Message-ID <[email protected]>
From:             
Operating system: Mac OS X
PHP version:      5.3.2
Package:          Class/Object related
Bug Type:         Feature/Change Request
Bug description:Static methods called as self::fun() always resolve to class of its declaration

Description:
------------
Static methods called using self::fun() resolve the parent class's method
even called from the child class. Sample code provided here (and below):
http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php#49541

Test script:
---------------
<?php

class ExampleSuperclass
{
    static function classType()
    {
        return "superclass";
    }

    static function doSomething()
    {
        echo "doing something with " . self::classType();
    }
}

class ExampleClass extends ExampleSuperclass
{
    static function classType()
    {
        return "subclass";
    }
}

ExampleClass::doSomething();
// output is "doing something with superclass"!

?>

Expected result:
----------------
Expected behavior is to output "doing something with subclass."

Actual result:
--------------
Output is currently (in PHP 5.3.2) "doing something with superclass"!

-- 
Edit bug report at http://bugs.php.net/bug.php?id=51391&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=51391&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=51391&r=trysnapshot53
Try a snapshot (PHP 6.0):            http://bugs.php.net/fix.php?id=51391&r=trysnapshot60
Fixed in SVN:                        http://bugs.php.net/fix.php?id=51391&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51391&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=51391&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=51391&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=51391&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=51391&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=51391&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=51391&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=51391&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=51391&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=51391&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51391&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51391&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=51391&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=51391&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=51391&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=51391&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=51391&r=mysqlcfg
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.