Bug #77618 [Opn->Nab]: get_class_function() reports wrong class name in parent:: context

From: Date: Thu, 14 Feb 2019 09:08:52 +0000
Subject: Bug #77618 [Opn->Nab]: get_class_function() reports wrong class name in parent:: context
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219572@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77618&edit=1 ID: 77618 Updated by: krakjoe@php.net Reported by: llmll at gmx dot de Summary: get_class_function() reports wrong class name in parent:: context -Status: Open +Status: Not a bug Type: Bug Package: Arrays related Operating System: All PHP Version: 7.2.15 Block user comment: N Private report: N New Comment: 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 In both cases, the name of the called class is B: echo B::Name(); echo B::NameOfParent(); Previous Comments: ------------------------------------------------------------------------ [2019-02-14 09:03:47] llmll at gmx dot de Description: ------------ 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. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77618&edit=1

« previous php.bugs (#219572) next »