php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #35266 __CLASS__ is not always right
Submitted: 2005-11-17 17:52 UTC Modified: 2005-11-17 17:55 UTC
From: markus at cultcom dot de Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 5.0.5 OS: Linux (Fedora Core 4)
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2005-11-17 17:52 UTC] markus at cultcom dot de
Description:
------------
__CLASS__ does not contain the correct class name in a generic class if method is called from a derived class.

Reproduce code:
---------------
<?php

class Generic
{
    public static function i_am()
    {
        print __CLASS__ . "\n";
    }
}

class Derived extends Generic
{
}

Generic::i_am();   // correct, print "Generic"
Derived::i_am();   // wrong, should print "Derived"

?>

Expected result:
----------------
If I call a method which was implemented in a parent class I need in any way access to the name of the class which actually was asked to execute the method...


Actual result:
--------------
Always the name of the class that actualy implements the method.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-17 17:55 UTC] tony2001@php.net
__CLASS__ is replaced with it's value during compile time.
Also, I would consider it's right, because this method actually belong to the parent class, not to the derived one.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 21:01:30 2024 UTC