Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42766 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87801 invoked from network); 22 Jan 2009 07:24:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Jan 2009 07:24:59 -0000 Authentication-Results: pb1.pair.com header.from=sv_forums@fmethod.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=sv_forums@fmethod.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fmethod.com from 69.16.228.148 cause and error) X-PHP-List-Original-Sender: sv_forums@fmethod.com X-Host-Fingerprint: 69.16.228.148 unknown Linux 2.4/2.6 Received: from [69.16.228.148] ([69.16.228.148:52093] helo=host.fmethod.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 13/08-19181-A4F18794 for ; Thu, 22 Jan 2009 02:24:59 -0500 Received: from [83.228.56.37] (port=3624 helo=pc) by host.fmethod.com with esmtpa (Exim 4.69) (envelope-from ) id 1LPtvr-0002Bf-Jj for internals@lists.php.net; Thu, 22 Jan 2009 01:24:56 -0600 Message-ID: <6E01DF250C3B49319EE799C717FAC6C1@pc> To: "PHP internals" References: <49778E0A.5010806@grudl.com> Date: Thu, 22 Jan 2009 09:24:49 +0200 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="ISO-8859-2"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host.fmethod.com X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - fmethod.com Subject: Re: [PHP-DEV] Enhanced __CLASS__ constant From: sv_forums@fmethod.com ("Stan Vassilev | FM") > Especially in namespaced code it should be very useful to have > "something" returning fully qualified name as string. It can be operator, > but I think introducing new keyword is bad way, or it can be realized > using well known magic constant in new context: > > Example: > > function factory($class) > { > return new $class; > } > > $obj = factory('MyClass'); // returns object MyClass > $obj = factory(MyClass::__CLASS__); // returns again object MyClass, code > is little bit more selfexplaining Hi, I've discovered this omission earlier and I have proposed two solutions: 1) $x = nameof Foo; -or- 2) $x = Foo::__NAME__; // very similar to yours, Foo::__CLASS__ may even be better Since passing identifier references as strings is relatively pervasive in a lot of the PHP code out there, I hope this is resolved for 5.3, before we figure out we need it the hard way after we've littered our code with tons of manually written out explicit references. One problem with your proposal / my second proposal is, it works for classes, but doesn't address namespaced 1) functions 2) constants. A new keyword would address this, but then, who wants a new keyword, right... Regards, Stan Vassilev