php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53565 OOP last state binding bug in get_called_class()
Submitted: 2010-12-17 21:22 UTC Modified: 2010-12-17 23:55 UTC
From: updates at mail dot ru Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3.4 OS: Linux 2.6.34-r1
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: updates at mail dot ru
New email:
PHP Version: OS:

 

 [2010-12-17 21:22 UTC] updates at mail dot ru
Description:
------------
Bug in get_called_class()

Test script:
---------------
class a
{
  function __construct()
  {
    $a = get_class($this);
    a::test();
  }

  function test()
  {
    var_dump(get_called_class());
  }
}

class b extends a
{
}

$a = new a();
$b = new b();

Expected result:
----------------
string(1) "a" string(1) "a" 

Actual result:
--------------
string(1) "a" string(1) "b" 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-17 21:27 UTC] updates at mail dot ru
This line does not affect the bug:
$a = get_class($this);

It can be removed.
 [2010-12-17 23:55 UTC] cataphract@php.net
-Status: Open +Status: Bogus
 [2010-12-17 23:55 UTC] cataphract@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Please read http://php.net/lsb
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Dec 03 12:00:01 2025 UTC