Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113540 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 52350 invoked from network); 15 Mar 2021 15:05:10 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Mar 2021 15:05:10 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8612E180087 for ; Mon, 15 Mar 2021 07:58:41 -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_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (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 ; Mon, 15 Mar 2021 07:58:41 -0700 (PDT) Received: by mail-lj1-f170.google.com with SMTP id u20so16596384lja.13 for ; Mon, 15 Mar 2021 07:58:40 -0700 (PDT) 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=Fzslsa13GOPyHeBY5mI6xujUErBcMOhyWf/ArdTZx+o=; b=DT7F7mywv1EKukrKphddeXHv/MTE2ZRO2k0ssLOtp7zGbNwSjnP/Jl24HXrTZynsK6 F/h47/R6AWGAI2sS1CeC3+trngPVvrFE9T53FAzDCvkPCof4CI+6D/JBKSPKBHG1dm4q 9p5quFmqFGdwg3iWvTy4R55VOkQadrqlh/dXwdh8m5HqUA3eTyVx1rSTZY8YGF/Ej7AD h9R3uFNIfAZo7FiyUhQTZ0rwkwJbqtMT7Vo6+3OchNzEyuKGw+sgaCVGCjB5IvxACooT g9PVgawPoFQL5Q+2GqcdxJdv3QxO7++QebFtByDXeYu5tusB2bmmLGpedVPRgzCYM+Q0 7QZA== 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=Fzslsa13GOPyHeBY5mI6xujUErBcMOhyWf/ArdTZx+o=; b=lOryTKMEnHk/SDF2Wt1/IA4bc1Gd/ioBz28CFbEWob3AydcezJ9rHW5p138H4gJl9A CgfwSbCki9p+GP7sPlWuspO6pO0jspE5VUWXzy9KDHE6iHViomMvYXS3CVDRQCnjWIcT fsA16IskrQshUibdJjglE9p86qEO2FkzIBFSS9ecYHb5tX8S3m8dzuHbwAC7IgjV+fk2 nbK2uUontwLzal/IbNBnEMChWLcyhQ4zpNdefgbXsQk6VqnO54BLMDlTwugTW3lNnYV+ Dz2+EyfmDUGD27ep+r7V01LUtpAP2NrjLCHoZXofL4RObBKeUPnyOP2wY8iCEGJcD6+q gAZA== X-Gm-Message-State: AOAM5332CDsPcW3QAvmBZKA9p+K6XiSbZ3fs5vfTIAB1EHZlAKGk62JS HwYBQ5AzawSQQ8ARLuvNo2bxRjbY4JR5kQjRpRA= X-Google-Smtp-Source: ABdhPJz3Imopy/6T4Uxocr80RrCbjcFUd1MAVMy1XlE3zg3g6r+yefxSMQXkpfut7i8AC9UfUD4KZ+Ps0fJM3y6VxVc= X-Received: by 2002:a2e:95d2:: with SMTP id y18mr11521561ljh.353.1615820319381; Mon, 15 Mar 2021 07:58:39 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 15 Mar 2021 15:58:23 +0100 Message-ID: To: =?UTF-8?Q?K=C3=A9vin_Dunglas?= Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000285e0905bd947c58" Subject: Re: [PHP-DEV] Add support for ::class to constant() From: nikita.ppv@gmail.com (Nikita Popov) --000000000000285e0905bd947c58 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Mar 9, 2021 at 11:16 PM K=C3=A9vin Dunglas wrote= : > Hi folks, > > Currently, it's not possible to use the ::class special constant with the > constant() function. This doesn't work: > > var_dump( > constant('\DateTime::class') > ); > > For instance, Twig's constant() helper internally uses this PHP function, > consequently the following Twig template doesn't work: > > `myObject` contains a random object, retrieve its class: > {{ constant('class', myObject) }} > > I wrote a patch adding support for ::class: > https://github.com/php/php-src/pull/6763 > As this probably qualifies as a new feature, should I write an RFC too? > I'm not a fan of this change. X::class is not a constant, it just happens to share the same syntax. I think that https://github.com/php/php-src/pull/6763#issuecomment-795046502 makes the key point that if this is treated as a proper class constant in constant(), then it should also be treated as such everywhere else, including reflection. And I really don't think we want to do that. Regards, Nikita --000000000000285e0905bd947c58--