Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108533 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 4336 invoked from network); 13 Feb 2020 12:28:30 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Feb 2020 12:28:30 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 15200180531 for ; Thu, 13 Feb 2020 02:42:52 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 13 Feb 2020 02:42:51 -0800 (PST) Received: by mail-lf1-f67.google.com with SMTP id 203so3888060lfa.12 for ; Thu, 13 Feb 2020 02:42:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=T3pI3FGL/fRfNyGyr+nPMci+DKN7k6cEVlr0WEjHA1U=; b=PgW5YlFOzBfTrynAmCkRtnBYJ1Y9svi7yBaw0t246eTg+0oPkrmOp2CqkNqt6kgPnY 3nagm+vrkhCjkmvG4d6TLoR98obn/kSNru4JXEdrEhT+Le5i357vd9W7eT8zPcOJqaq9 H9CTzyc+IORya8XfXlleeP2MKg1hBjkdb86fNyp/yIhpmK4n+4Col+OPmLkJCgmH+y+D Zj9PWv95fWBndnZYZrEEtP09LBhbV+Ng1FY9O8OSABMvNGgCoPOily0CKl74AEJ2X8a8 lnIYotyjJGZQvk0mK91016KE27hK12jEe770QgozZbxljhDNY3apaXSjNrBRwowkxMDK cvcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=T3pI3FGL/fRfNyGyr+nPMci+DKN7k6cEVlr0WEjHA1U=; b=Ab1rsG3h1X+tPQzRdR1+hAx351SMm+STKe1ttB1dkm6vdtwY5j1Wb78kDf111KAm06 THnjZn+Vshv314k3ui/j70dzTYpj1PHxWzutQm4QTpvtLrV4dqjx3x//xWcnwDuSfdi6 ZPmWq21PyAxGoUf6yS4KqT+rhF8krp2la7DorO6vpRymnRduIH9JSLf2w8fwgD29RTC5 2epxgiuHCeE3hhsSJFcFYMCvdm1jO3j844GKVahPVYQqnQlj0KSAPuBFEMC637PUU01o +t6FB9NnTty9JIz405qLVw29j42RCeU+T4aC2dAkVa/SIfjx7SCzk6H1PiWLIASFzENJ F00w== X-Gm-Message-State: APjAAAWBAgreY4UgIa/7mdVESF9fPGKod4iAbGA/vqNf80rxW0wyc+Wo OZ8/1QVXgXLQBj383td9Yp9Vm0EEBJiGFC2CcVI= X-Google-Smtp-Source: APXvYqwarw88W27wiac+aKqE/8dFq1/52tPH4nzFV0Lg2RBGc36mBw5BAn2trg2StucH1Lq3xS3WoDwm1MjsB12x6vA= X-Received: by 2002:a19:2351:: with SMTP id j78mr9062416lfj.173.1581590566184; Thu, 13 Feb 2020 02:42:46 -0800 (PST) MIME-Version: 1.0 References: <5e3c7253.1c69fb81.c5725.860bSMTPIN_ADDED_MISSING@mx.google.com> In-Reply-To: Date: Thu, 13 Feb 2020 11:42:30 +0100 Message-ID: To: Andrea Faulds Cc: PHP internals , Nicolas Grekas Content-Type: multipart/alternative; boundary="000000000000e0abc1059e72bfe6" Subject: Re: [PHP-DEV] Re: Changing the generated name for anon classes From: nikita.ppv@gmail.com (Nikita Popov) --000000000000e0abc1059e72bfe6 Content-Type: text/plain; charset="UTF-8" On Fri, Feb 7, 2020 at 2:35 PM Nikita Popov wrote: > On Thu, Feb 6, 2020 at 9:08 PM Andrea Faulds wrote: > >> Hi, >> >> Nikita Popov wrote: >> > Hi internals, >> > >> > Based on a suggestion by Nicolas Grekas, >> > https://github.com/php/php-src/pull/5153 changes the generated name for >> > anonymous classes to include the name of the parent class or first >> > interface. So instead of just class@anonymous, you'll see something >> like >> > EventHandler@anonymous in error messages, for example. >> > >> > There's a minor BC break here, for code checking for a "class@anonymous >> " >> > prefix, which should be easy to rectify by checking for "@anonymous" >> > instead. >> > >> > What do people think about doing this change? >> > >> > Regards, >> > Nikita >> > >> >> Perhaps it would make sense to include the namespace used by the code >> which defines/instantiates the class? That might make it easier, when >> looking at a mysterious anonymous class using var_dump() deep in a big >> project perhaps, to find out where it came from. >> > > That would be a possible alternative. This is similar to what we do for > closures. > > As we need the generated name to be reasonably concise, we can only do one > or the other though. I don't know which one is more useful... Maybe Nicolas > wants to chime in. > I've scrolled through anon class uses in popular composer packages, and that convinced me that parent/interface is probably the most useful information here. Adding the namespace prefix leaves you with something like "Amp\class@anonymous", which doesn't really tell you anything at all, while adding the interface gives you "Amp\CancellationToken@anonymous", which is fairly meaningful. Many more examples like this. Nikita --000000000000e0abc1059e72bfe6--