Bug #77618 [Com]: get_class_function() reports wrong class name in parent:: context
| From: | llmll at gmx dot de | Date: | Sun, 17 Feb 2019 18:30:21 +0000 |
| Subject: | Bug #77618 [Com]: get_class_function() reports wrong class name in parent:: context | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-219618@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
Comment by: llmll at gmx dot de
Reported by: llmll at gmx dot de
Summary: get_class_function() reports wrong class name in
parent:: context
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:
static::Name() should return "B"
BUT
parent::Name() must return "A"
Previous Comments:
------------------------------------------------------------------------
[2019-02-17 18:28:59] llmll at gmx dot de
And that ist wrong! Dont care what documentation says.
------------------------------------------------------------------------
[2019-02-14 09:08:52] krakjoe@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
In both cases, the name of the called class is B:
echo B::Name();
echo B::NameOfParent();
------------------------------------------------------------------------
[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