|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-02-09 20:43 UTC] gron@php.net
[2012-02-09 20:44 UTC] gron@php.net
-Status: Open
+Status: Not a bug
[2012-02-09 20:44 UTC] gron@php.net
[2013-02-14 09:59 UTC] kusmierz at o2 dot pl
[2013-02-18 17:26 UTC] kusmierz at o2 dot pl
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 05:00:01 2025 UTC |
Description: ------------ The __FUNCTION__ magic constant does not report correctly in aliased methods within traits. When a trait function is called by it's initial name __FUNCTION__ is correct. When it is called by it aliased name __FUNCTION__ still reports as the initial name, but debug_backtrace() reports the aliased method name. Test script: --------------- <?php trait MyTrait { public function foo() { $backtrace = debug_backtrace(); echo '__FUNCTION__ = ' . __FUNCTION__ . PHP_EOL; echo '$backtrace[0][\'function\']) = ' . $backtrace[0]['function'] . PHP_EOL; } } class MyClass { use MyTrait { foo as public bar; } } $instance = new MyClass(); echo 'foo()' . PHP_EOL; $instance->foo(); echo PHP_EOL; echo 'bar()' . PHP_EOL; $instance->bar(); Expected result: ---------------- foo() __FUNCTION__ = foo $backtrace[0]['function']) = foo bar() __FUNCTION__ = bar $backtrace[0]['function']) = bar Actual result: -------------- foo() __FUNCTION__ = foo $backtrace[0]['function']) = foo bar() __FUNCTION__ = foo $backtrace[0]['function']) = bar