Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:65928 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13532 invoked from network); 19 Feb 2013 09:37:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Feb 2013 09:37:14 -0000 X-Host-Fingerprint: 178.73.10.238 unknown Received: from [178.73.10.238] ([178.73.10.238:14889] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B8/51-04083-7C743215 for ; Tue, 19 Feb 2013 04:37:13 -0500 Message-ID: To: internals@lists.php.net Date: Tue, 19 Feb 2013 10:37:18 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 178.73.10.238 Subject: Trait vs magic constants (bug #61033) From: m.kurzyna@crystalpoint.pl (Marcin Kurzyna) Hi Internals after quite a long time, There is an issue in the tracker (#61033 and somewhat related #64239) about magic constants behaviour in aliased trait methods. Stefan classified #61033 as a "feature not a bug" however he suggested to start a discussion about it. So here's the case: how to get current running method name when in an aliased trait method: trait T { public function method() { // __FUNCTION__ is "method" } } class C { use T { method as m; } public function method() {} } This is all nice and dandy but imagine (among other things) that you want to return a callback to itself from such a method. How would you go about it? Returning [$this, __FUNCTION__] would be most obvious but it's obviously not what we want. Apart from using debug_backtrace (which has it's own issues; #64239 being one) I don't see any way of doing it. So: is this a feature or a bug? And if it really is a feature then either we need another magic const (like suggested in #64239) or (preferably IMO) a method to resolve method name at runtime (a counterpart to get_called_class() - say get_called_method()). Cheers Marcin