Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89166 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16339 invoked from network); 11 Nov 2015 02:13:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Nov 2015 02:13:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=steven.hilder@sevenpercent.solutions; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=steven.hilder@sevenpercent.solutions; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sevenpercent.solutions designates 46.101.25.58 as permitted sender) X-PHP-List-Original-Sender: steven.hilder@sevenpercent.solutions X-Host-Fingerprint: 46.101.25.58 mail.sevenpercent.solutions Received: from [46.101.25.58] ([46.101.25.58:56268] helo=mail.sevenpercent.solutions) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 72/AC-21426-D44A2465 for ; Tue, 10 Nov 2015 21:13:34 -0500 Received: from charlie (bzq-79-177-4-95.red.bezeqint.net [79.177.4.95]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: steven.hilder) by mail.sevenpercent.solutions (Postfix) with ESMTPSA id C57B53FC6D; Wed, 11 Nov 2015 02:13:29 +0000 (UTC) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: "PHP Internals" References: <72.8B.21426.C9492465@pb1.pair.com> Date: Wed, 11 Nov 2015 04:13:28 +0200 Cc: "Andrea Faulds" MIME-Version: 1.0 Content-Transfer-Encoding: Quoted-Printable Organization: SevenPercent Solutions Ltd. Message-ID: In-Reply-To: <72.8B.21426.C9492465@pb1.pair.com> User-Agent: Opera Mail/1.0 (MacIntel) Subject: Re: [PHP-DEV] Null bytes in anonymous class names From: steven.hilder@sevenpercent.solutions ("Steven Hilder") On Wed, 11 Nov 2015 01:06:32, Andrea Faulds wrote: > This is mostly tangential, but I note that we use "{closure}" as the n= ame > of anonymous functions. So, maybe it should be "{class}@..." for = > anonymous > classes? It's at least semi-consistent... Hi Andrea, Only slightly tangential - I'm interested in your input on this issue, a= nd I'm keen to get this sorted out before 7.0 launches, so that we don't ge= t stuck with something suboptimal until 8.0 because of BC concerns. To be honest, the original meaning of the class names has been lost sinc= e Phil and Joe's RFC[1]. It had originally been `class@0x[addr]`, which ha= d a reasonable semantic interpretation of "the (otherwise anonymous) class = which can be found at the address [addr]". Dmitry added[2] the null byte and t= he filename, but he did so between the '@' and the '0x[addr]', with = 'anonymous' added (just for good measure?). At this point, the purpose of the = '@'-symbol was gone, in my opinion. Furthermore, the RFC allowed for the portion of the name before the '@' = to identify the parent class: class mine {} new class extends mine {}; This class name will be =E2=80=9Cmine@0x7fc4be471000=E2=80=9D. This behaviour was present in Joe's original implementation, but later removed[3] by Nikita. His commit message says that this was "dead code",= = but I don't see what was wrong with it. The result of all of this is that we have a naming convention for anonym= ous classes that is not only inconsistent with an existing feature of the language, but has little in the way of reasoning behind its current form= at. My patch[4] aims to save userland from this mess by hiding the entire = suffix wherever anonymous classes' names are to be displayed. This means that a= ll anonymous classes will show as "class@anonymous" (which I'd happily chan= ge to "{class}" in keeping with "{closure}") in userland, with no way of retrieving the internal name; not even using `ReflectionClass`. My = reasoning is that users should never need to know the underlying names; if a class= = has a distinct name, then it's not really *anonymous*, is it? Kind regards, Steve [1] https://wiki.php.net/rfc/anonymous_classes#internal_class_naming [2] http://git.php.net/?p=3Dphp-src.git;a=3Dcommitdiff;h=3D2a1b0b1#patch= 1 [3] http://git.php.net/?p=3Dphp-src.git;a=3Dcommitdiff;h=3D4a7061b#patch= 1 [4] = https://github.com/php/php-src/compare/master...stevenhilder:hide-anon-c= lass-suffix