Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117468 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 63330 invoked from network); 31 Mar 2022 14:27:38 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 31 Mar 2022 14:27:38 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 324F21804FF for ; Thu, 31 Mar 2022 08:56:24 -0700 (PDT) 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_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (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, 31 Mar 2022 08:56:23 -0700 (PDT) Received: by mail-ej1-f52.google.com with SMTP id bq8so207741ejb.10 for ; Thu, 31 Mar 2022 08:56:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=k/t4o8vgjKZ4Zptehl2A07q8ixv7S1fC4kGGGBCX0tc=; b=XGChVWIiWiKoHe8XzTcksQ20qvKNtNkZH6S1Gduj4xikPrnlo+cQ8hzsC+3hEkQu8P 06chEoWDCDbST/dl69EpEHJxXwRxhEglUhti9/MzgYuUovVRds0h/PAYvYT1UgWSR9RR 5bE3SYVmXGVzAbe/RTB7r/LJ7sCRFXf3hHFl9+kMmUWnCLfA0WFmYG1SFkUyMnzGxRPZ PvIc3sj21NUr3o82aq+26G4w2l1X2Zj7NWq24X04uJnhwqEvh3oOv41qGD5Xrvkr2nxo f0fj74S1vMYPRw2xV5UYOtGXChVdwrJf+NrVPybZ4zz/rueJhBdGRXA7OtMy8+ESmY/0 gWZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=k/t4o8vgjKZ4Zptehl2A07q8ixv7S1fC4kGGGBCX0tc=; b=0aV1r3G+WhBp0Uzy7zfEp6adeDGoj+Z2Rh4Imy8kZqWIlPxJ24B5L2GBV1FYJD+8y3 YmrWgsp7a3kB7NIlA8uMxwv3Ie2kWuLISIMMeVJZYqZsAmbzHLBlDNPN4GxYOP6zMebP ggSN8dk3VYVcDJgxON1FUUCKXybOr1Sct/lBJKbgRfMXZ/Ioj8AhX5n9LIFIe9Lqi5uX 2AcJq4HM6/8paozplH2uedmOo2XCGolJFh4tRabPF3qbA3KkCvrsaHSmfvqX64vxyIfN SrG4Cz/FwtYWoBdeC2FZzHvjXVPnBtGlXmz5sNNq56B3Sd5vxnVJKMCuZmjHhEtCt6rb YzWA== X-Gm-Message-State: AOAM533AnVKfakSWj4mVrzUnZSlwi2ttf5P5C9XEmdcRpepq7yy+YAgG EQHQ2EB7mzZmRH8apo44zqqLJf3bP5Rwy7MFakONPVSr X-Google-Smtp-Source: ABdhPJwftJnRkY47K5reDqAtrgFUNp2sKNS8eYhmq7kxrvSy+JA9N3FJlc/9POGJihmkPSnwdYsLPt8u3H3Oq+5o31U= X-Received: by 2002:a17:907:7e99:b0:6e0:2fed:9789 with SMTP id qb25-20020a1709077e9900b006e02fed9789mr5582689ejc.72.1648742182124; Thu, 31 Mar 2022 08:56:22 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 31 Mar 2022 17:56:08 +0200 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="0000000000001782fd05db85b4a8" Subject: Re: [PHP-DEV] Add leading backslash to enum and class names in var_export From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --0000000000001782fd05db85b4a8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Le jeu. 31 mars 2022 =C3=A0 17:50, Larry Garfield = a =C3=A9crit : > On Thu, Mar 31, 2022, at 10:45 AM, Ilija Tovilo wrote: > > Hi everyone > > > > We've had two bug reports for var_export not working for enums. The > > reason for that is that var_export does not add a leading backslash to > > names of enums. This will cause them to be resolved as > > `\CurrentNamespace\EnumNamespace\EnumName` instead of just > > `\EnumNamespace\EnumName`. > > > > enum A { > > case B; > > } > > > > echo var_export(A::B, true), "\n"; > >> A::B > > > > > > This is a problem for things like Doctrines ProxyGenerator that embeds > > the result of var_export in classes with namespaces > > (https://github.com/doctrine/common/pull/955). The Doctrine team > > resolved this by adding a `use` of the enum at the top of the file but > > that really shouldn't be necessary. > > > > The same issue already exists for classes. > > > > class C {} > > > > echo var_export(new C(), true), "\n"; > >> C::__set_state(array( > >> )) > > > > https://bugs.php.net/bug.php?id=3D64554 > > > > Marco Pivetta created a PR that adds leading backslash to all class or > > enum names of var_export. Adding a backslash will make the code work > > both inside or outside namespaces. > > https://github.com/php/php-src/pull/8233 > > > > To avoid disruption, I'm proposing to merge this into PHP 8.2 only. > > Unless anybody has any objections to this change I will merge it in a > > few weeks. > > > > Ilija > > What would be the disruption on 8.1? It wouldn't break the existing `use= ` > trick, and I doubt anyone is leveraging this deliberately. > > It could break fixtures that ppl might use to compare the two outputs of var_export(). --0000000000001782fd05db85b4a8--