Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57806 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73443 invoked from network); 9 Feb 2012 21:36:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Feb 2012 21:36:28 -0000 Authentication-Results: pb1.pair.com header.from=marc@easen.co.uk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=marc@easen.co.uk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain easen.co.uk from 74.125.82.170 cause and error) X-PHP-List-Original-Sender: marc@easen.co.uk X-Host-Fingerprint: 74.125.82.170 mail-we0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:60983] helo=mail-we0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C8/11-00170-A5C343F4 for ; Thu, 09 Feb 2012 16:36:27 -0500 Received: by werm1 with SMTP id m1so1772080wer.29 for ; Thu, 09 Feb 2012 13:36:24 -0800 (PST) Received: by 10.216.136.200 with SMTP id w50mr1384615wei.2.1328823384429; Thu, 09 Feb 2012 13:36:24 -0800 (PST) Received: from [192.168.1.45] (5e0f2b4d.bb.sky.com. [94.15.43.77]) by mx.google.com with ESMTPS id dw7sm9367452wib.4.2012.02.09.13.36.22 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 09 Feb 2012 13:36:23 -0800 (PST) Message-ID: <4F343C47.1020304@easen.co.uk> Date: Thu, 09 Feb 2012 21:36:07 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20120129 Thunderbird/10.0 MIME-Version: 1.0 To: internals PHP Content-Type: multipart/alternative; boundary="------------070504050908060706030700" X-Gm-Message-State: ALoCoQkOKeajh4WPiYj3pvykDL6JW+dQiLEydS5GHo3uq3kC516+469pEG3sHnzxpEYTK6fsz5C5 Subject: Bug #61033 __FUNCTION__ doesn't report correctly in alias trait methods From: marc@easen.co.uk (Marc Easen) --------------070504050908060706030700 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hello everyone, I've recently came across an odd situation where __FUNCTION__ can produce a misleading results when using traits with aliased methods, see https://bugs.php.net/bug.php?id=61033. This has been closed and I've been asked start a discussion on here if I disagree with the ruling. The reason why I feel this should be changes to reflect the actual called function name is that one of main uses of the __FUNCTION__ constant it to refer back to the function that is currently running, for the use recursive functions: trait FooTrait { public function foo($n) { if ($n == 0) return; echo $n . PHP_EOL; $function = __FUNCTION__; $this->$function(--$n); } } class MyClass { use FooTrait { foo as public countdown; } public function foo() { echo 'MyClass::foo()'; } } $instance = new MyClass(); $instance->countdown(3); This example will produce running (PHP 5.4 RC7): 10 MyClass::foo() Which as you can see is not the desired effect. I send this email in the hope this can get the discussion under way regarding the magic constant __FUNCTION__. Thanks, Marc Easen --------------070504050908060706030700--