|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77618 get_class_function() reports wrong class name in parent:: context
Submitted: 2019-02-14 09:03 UTC Modified: 2019-02-14 09:08 UTC
From: llmll at gmx dot de Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 7.2.15 OS: All
Private report: No CVE-ID: None
 [2019-02-14 09:03 UTC] llmll at gmx dot de
The function get_class_function() should always return the class name of the context in which it is called. Dynamic or Static context should make no difference.

When wrapped in a parent:: call it returns the child's class name not the parent's one.

Test script:
class A {
	public static function Name() {
		return get_called_class();
class B extends A {
	public static function NameOfParent() {
		return parent::Name();

echo B::Name();
echo B::NameOfParent();

Expected result:
should report "B" as Name() and "A" as NameOfParent().

Actual result:
return "B" twice, because parent doesn't change the context from B:: to A:: as it should.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-02-14 09:08 UTC]
-Status: Open +Status: Not a bug
 [2019-02-14 09:08 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

In both cases, the name of the called class is B:

echo B::Name();
echo B::NameOfParent();
 [2019-02-17 18:28 UTC] llmll at gmx dot de
And that ist wrong! Dont care what documentation says.
 [2019-02-17 18:30 UTC] llmll at gmx dot de
static::Name() should return "B"


parent::Name() must return "A"
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Jan 22 22:03:37 2022 UTC