From: spamfreedave-zend at yahoo dot com Operating system: Mac OSX PHP version: 5.4.9 Package: *General Issues Bug Type: Feature/Change Request Bug description:New constant __ALIAS__ for trait functions to know how they were called
Description: ------------ I would like my trait functions to know what alias (if any) was used to call them. The idea came from discovering that you can give a trait function multiple aliases (see Test Script). It occurs to me that you could have some interesting dynamic behavior if the trait function was able to determine what name (alias) was used to call it. If possible, a new constant __ALIAS__ could be created to store this value. Thank you for your consideration. Test script: --------------- <?php trait TestTrait { public function test() { print __FUNCTION__ . ', ' . __ALIAS__ . "\n"; } } class TestClass { use TestTrait { test as test2; test as test1; } } $c = new TestClass(); $c->test1(); $c->test2(); Expected result: ---------------- test, test1 test, test2 Actual result: -------------- test, __ALIAS__ test, __ALIAS__ -- Edit bug report at https://bugs.php.net/bug.php?id=63629&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63629&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63629&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63629&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=63629&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=63629&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=63629&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=63629&r=needscript Try newer version: https://bugs.php.net/fix.php?id=63629&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=63629&r=support Expected behavior: https://bugs.php.net/fix.php?id=63629&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=63629&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=63629&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=63629&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63629&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=63629&r=dst IIS Stability: https://bugs.php.net/fix.php?id=63629&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=63629&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=63629&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=63629&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=63629&r=mysqlcfg