Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117467 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 61702 invoked from network); 31 Mar 2022 14:21:47 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 31 Mar 2022 14:21:47 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C5E871804A9 for ; Thu, 31 Mar 2022 08:50:32 -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.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS29838 64.147.123.0/24 X-Spam-Virus: No X-Envelope-From: Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (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:50:32 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 41A203200D78 for ; Thu, 31 Mar 2022 11:50:31 -0400 (EDT) Received: from imap43 ([10.202.2.93]) by compute1.internal (MEProxy); Thu, 31 Mar 2022 11:50:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=tvKbxBi9+X2tgvldv IKg0CHeb4TVfsYtZtWrwpgGwNk=; b=g6SZHZXtQHRgQAKUrvm3RfSR50WiZuRZA Mm+p7fjB1+ZnIxU3mmgcR8YYHlFeR5RVQj+2Nj4Od0Otiv8CCVhQ7Py27IHWUB1j ZmHsv4tPc10ql8redJKcJhmcX/ZYow+lWuJdEb5QCQ8jlVd0J+qw6di+Fxz2fVKW TZ6w5YQ9LMecF6LJkUGDgjG1MKgcWtfINJIeFbJ1hKZIBwpjIE+LYBaCXfgnbJqg iDq62Rswyi47p1iaFKez5tzx1lzn4rvphTjV2iRCWj76fnJ6L5pMAvqHtaN/SEXn NB0DLOlRuItJ7WMC9VYGho7PVOR/XNpirMFjTCbkT7UR9qeX3Cn2Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudeigedgleefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpedvgfekgfduhffhjeeufeefgffhgfejvefgfeekkeek hfeluefgteejheekgefhveenucffohhmrghinhepghhithhhuhgsrdgtohhmpdhphhhprd hnvghtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhep lhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id B7E46AC0E99; Thu, 31 Mar 2022 11:50:30 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-382-g88b93171a9-fm-20220330.001-g88b93171 Mime-Version: 1.0 Message-ID: In-Reply-To: References: Date: Thu, 31 Mar 2022 10:50:09 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] Add leading backslash to enum and class names in var_export From: larry@garfieldtech.com ("Larry Garfield") 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=64554 > > 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. --Larry Garfield