Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86394 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29714 invoked from network); 26 May 2015 17:51:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 May 2015 17:51:49 -0000 Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.175 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.213.175 mail-ig0-f175.google.com Received: from [209.85.213.175] ([209.85.213.175:32843] helo=mail-ig0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3F/E2-05273-4B2B4655 for ; Tue, 26 May 2015 13:51:48 -0400 Received: by igbpi8 with SMTP id pi8so66118823igb.0 for ; Tue, 26 May 2015 10:51:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=Wy7yXpXU5KDxM+QTsRG+f77xbvnAyqvulhqMkb2Csqc=; b=sb1muLndB3OSjaJeHe3XfMlpBeIoJVo/Gl7iKOXnmuSNbzRNXUoJMNkqjpt83+7l4T YukZamzFBytEU3LUfbPe10xP/LG73UR1LFgEXFbSlqrhP3GJsuj/0nJekY1+FBXqYWfF 4cmqvBSjHJ4o5msukKwtdtwWh7ixx/sx5ArMZI203oW5RvJjxEp7D3L9tEnwemliz6IF 75+sIbIP6gRT9LN3VK7uJVgGf5msjLRIQeFUtg30WkqfHESB7Eyt44Xh/QD3ABsrnoyj YVG4hDT4s0fHPmkAXNl+0tpm3q8zVDRr1ZlNwyfgxI0W5UcXpH1IY5EoxA52ahYChReL Y6PA== MIME-Version: 1.0 X-Received: by 10.107.7.195 with SMTP id g64mr6350675ioi.81.1432662704920; Tue, 26 May 2015 10:51:44 -0700 (PDT) Sender: morrison.levi@gmail.com Received: by 10.79.98.67 with HTTP; Tue, 26 May 2015 10:51:44 -0700 (PDT) In-Reply-To: <556496B3.1030905@ralphschindler.com> References: <55636034.6010003@mabe.berlin> <556496B3.1030905@ralphschindler.com> Date: Tue, 26 May 2015 11:51:44 -0600 X-Google-Sender-Auth: hTG16BVrShoF-yUxlds85oCeMy4 Message-ID: To: Ralph Schindler Cc: internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] ::class wrong case From: levim@php.net (Levi Morrison) On Tue, May 26, 2015 at 9:52 AM, Ralph Schindler wrote: > > >> > >> namespace foo; >> >> function bar(){} >> >> var_dump(bar::class); // string(7) "foo\bar" >> >> ?> >> >> This was not explained in the RFC at all, and had I known this I would >> have voted against it personally. > > > How would you suggest it be different, if not a "compile-time name expansion > for classes"? Emit an opcode for it. This would also allow for dynamic lookups ($foo::class), trigger autoloading, and restrict it to classes and interfaces (and traits?). All of these things are beneficial in my opinion, at least. > On a personal note, I've gotten plenty of benefit from the feature which > (again, for me) totally eclipses the only very small regret that ::class > looks like a class constant lookup. That syntactical point could have gone > either way, but I feel like the accepted syntax is still a good choice. I have found this feature to be useful as well. The essence of this feature is good, but I feel like the implementation is unfortunate. > Your example above might attempt to cause some mis-direction to the reader > of the code a bit because you have clearly defined a symbol (function) > called "bar", yet you're still name-expanding a class called "bar", which > technically could be living in the same namespace in a different file > covered by an autoloader. bar::class still does actually mean foo\bar the > class, not the function. > > namespace foo; > function bar() {} > class bar {} > var_dump(bar::class); // string(7) "foo\bar" > $b = new bar; > var_dump(get_class($b)); bar::class does not necessarily mean `foo\bar` the class; it just does a string expansion. In my opinion it should have been restricted to only classes and interfaces (or other things like them) since that's what the RFC and syntax intends, but not what it actually does.