Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108424 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 53125 invoked from network); 7 Feb 2020 15:27:38 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Feb 2020 15:27:38 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D4746180533 for ; Fri, 7 Feb 2020 05:40:33 -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-oi1-f196.google.com (mail-oi1-f196.google.com [209.85.167.196]) (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 ; Fri, 7 Feb 2020 05:40:33 -0800 (PST) Received: by mail-oi1-f196.google.com with SMTP id q84so1996834oic.4 for ; Fri, 07 Feb 2020 05:40:33 -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=fo+S7VRHlQ3VSHBBdTwjP716XejQnC2+F8MlqMh8FDk=; b=NE+XmuD6KEejCRrLCdLBMcCUDcHpctGzpV8C3nhvVnHk/ywXVRrMX6iiNdfjIyFz2f fkD4iFxaRVazWxN4oMyJ9ZIafrbnZXJrD4CdK2FG8iMf8wttYUz6XlZhXDvhpk4LFcrt uH2lj6jkF1MjpHpCJ2pn28lu0M5c3rOu50G104rTAQhPbIgQBWMms1S8tKo/xUhLiNbK w7VPxhSwriuw38hTBNa/JXcgIEwxX8Qu5I+rjapAJj5SxT6+uwFxFOfmDqQpnwDcr2yI nT5dNUFVgzXElBezsgGxe2cfbcmSQ05Zpz3nP6fiD4Dde2PtIcwQfjg/JPO5xmnie0BG 7yAg== 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=fo+S7VRHlQ3VSHBBdTwjP716XejQnC2+F8MlqMh8FDk=; b=fjkxybU9KGGB8dUiuCAKjEjMAYfMMbd0nSz9eFIR9pJr8HA1yoasmZuIEZnwnfMtsY fDGpEiCzSFhkWCI/psYiVcxkcBS8hjUPNtjWBjCzCejcLXgfDeocnK8+IuC4xmzXTy5L Z7qZCKrzCCJNmo0EFEVkEcL6gKi0K1XafKLTHtyScmWmkB8Es5m4tOpMXCAuNvxVr5BA Ac/FcPNy3fVbYrq/NaMmQunhetYSrDpChrKhoV6r/XlhEVKTNkNyVLOuUZdZQoRdzGiI kdOL2JzdKGroyWK92d5D4HRPDo6vZpAYEzFx8/to2EkQyv3BzqT8bhMUWgmK28oSWB3i umPw== X-Gm-Message-State: APjAAAUxsnXE+MvQQDk5ZgMW7s9K2qkexy/C4plY6TrXYl4Em/DI3dif lZiyqdM3uj8pB9+xbYuT6XcX1LAoaQwz/C1kczU= X-Google-Smtp-Source: APXvYqxnoUqgwrdA/P+gkgnnzuxNKZgZVsEB7kQd5dpv3NIW5DhdWcqL9P+Yb6p6USn3MrvkzS0Trs2jU1R8iqkPURQ= X-Received: by 2002:aca:ebc2:: with SMTP id j185mr2108675oih.71.1581082832768; Fri, 07 Feb 2020 05:40:32 -0800 (PST) MIME-Version: 1.0 References: <5e3c7253.1c69fb81.c5725.860bSMTPIN_ADDED_MISSING@mx.google.com> In-Reply-To: Date: Fri, 7 Feb 2020 14:40:20 +0100 Message-ID: To: Nikita Popov Cc: Andrea Faulds , PHP internals Content-Type: multipart/alternative; boundary="0000000000009b91ac059dfc8834" Subject: Re: [PHP-DEV] Re: Changing the generated name for anon classes From: nicolas.grekas@gmail.com (Nicolas Grekas) --0000000000009b91ac059dfc8834 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Le ven. 7 f=C3=A9vr. 2020 =C3=A0 14:36, Nikita Popov = a =C3=A9crit : > 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 fo= r >> > 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@anonymou= s >> " >> > 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 on= e > or the other though. I don't know which one is more useful... Maybe Nicol= as > wants to chime in. > The proposed names are the most useful from my experience, take e.g. these lines, found in the same class: throw new class() implements ServerExceptionInterface {...}; [...] throw new class() implements ClientExceptionInterface {...}; The debugging experience is better mentioning ServerExceptionInterface or ClientExceptionInterface than the namespace of the surrounding class. The file + line info will fo straight to this surrounding class also, so the proposal maximizes the amount of useful info from my experience. Nicolas --0000000000009b91ac059dfc8834--