Bug #61033 [NEW]: __FUNCTION__ doesn't report correctly in alias trait methods
| From: | marc at easen dot co dot uk | Date: | Thu, 09 Feb 2012 20:23:48 +0000 |
| Subject: | Bug #61033 [NEW]: __FUNCTION__ doesn't report correctly in alias trait methods | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-167362@lists.php.net to get a copy of this message | ||
From:
Operating system: Gentoo
PHP version: 5.4.0RC7
Package: Reflection related
Bug Type: Bug
Bug description:__FUNCTION__ doesn't report correctly in alias trait methods
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
--
Edit bug report at https://bugs.php.net/bug.php?id=61033&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=61033&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=61033&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=61033&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=61033&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=61033&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=61033&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=61033&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=61033&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=61033&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=61033&r=support
Expected behavior: https://bugs.php.net/fix.php?id=61033&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=61033&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=61033&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=61033&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=61033&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=61033&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=61033&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=61033&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=61033&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=61033&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=61033&r=mysqlcfg