Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116429 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 50490 invoked from network); 16 Nov 2021 21:51:55 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Nov 2021 21:51:55 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 88D0E1804BD for ; Tue, 16 Nov 2021 14:46:58 -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.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8412 83.65.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from mail04.x-net.at (mail04.x-net.at [83.65.7.57]) (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 ; Tue, 16 Nov 2021 14:46:57 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail04.x-net.at (Postfix) with ESMTP id 6A07060098; Tue, 16 Nov 2021 23:46:55 +0100 (CET) Received: from mail04.x-net.at ([127.0.0.1]) by localhost (x-zimbra04.x [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id rkWPyomtYp9l; Tue, 16 Nov 2021 23:46:54 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail04.x-net.at (Postfix) with ESMTP id 385806011B; Tue, 16 Nov 2021 23:46:54 +0100 (CET) X-Virus-Scanned: amavisd-new at x-zimbra04.x Received: from mail04.x-net.at ([127.0.0.1]) by localhost (x-zimbra04.x [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id kC03hQ2sbfSf; Tue, 16 Nov 2021 23:46:54 +0100 (CET) Received: from mail02.x-net.at (unknown [172.24.210.35]) by mail04.x-net.at (Postfix) with ESMTPS id 0EF1B60098; Tue, 16 Nov 2021 23:46:54 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail02.x-net.at (Postfix) with ESMTP id 06F613800BC; Tue, 16 Nov 2021 23:46:54 +0100 (CET) Received: from mail02.x-net.at ([127.0.0.1]) by localhost (mail02.x-net.at [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id bT0fJI2KURtK; Tue, 16 Nov 2021 23:46:51 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail02.x-net.at (Postfix) with ESMTP id 28FEE3803F9; Tue, 16 Nov 2021 23:46:51 +0100 (CET) X-Virus-Scanned: amavisd-new at x-t.at Received: from mail02.x-net.at ([127.0.0.1]) by localhost (mail02.x-net.at [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id FNN2wS4559S7; Tue, 16 Nov 2021 23:46:51 +0100 (CET) Received: from [127.0.0.1] (178.165.162.196.wireless.dyn.drei.com [178.165.162.196]) by mail02.x-net.at (Postfix) with ESMTPSA id D97E83800BC; Tue, 16 Nov 2021 23:46:50 +0100 (CET) Date: Tue, 16 Nov 2021 23:46:52 +0100 To: internals@lists.php.net, Kamil Tekiela , Dusk CC: PHP internals User-Agent: K-9 Mail for Android In-Reply-To: References: <05aa01d7db0e$783fa120$68bee360$@webkr.de> <05b601d7db18$18d59eb0$4a80dc10$@webkr.de> <968C461B-8CFE-44B3-BED1-5508B1D68B3B@woofle.net> Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: =?US-ASCII?Q?Re=3A_=5BPHP-DEV=5D_Is_there_an_RFC/discuss?= =?US-ASCII?Q?ion_for_=3A=3Aclass_being_a_specific_type=3F?= From: mel@dafert.at (Mel Dafert) On 16 November 2021 23:02:59 CET, Kamil Tekiela wr= ote: >Hi Dusk, > >Perhaps, you misunderstood me=2E Take a look at the documentation >https://www=2Ephp=2Enet/manual/en/language=2Eoop5=2Ebasic=2Ephp#language= =2Eoop5=2Ebasic=2Eclass=2Eclass >::class is just a compile time transformation=2E It will give you the ful= ly >qualified name of *something* as a string literal=2E The only exception t= o >this is when using ::class on objects, as this is a runtime transformatio= n, >and when using with keyword static=2E > >When ::class is used with a class name, it will give you the name of that >class as a string=2E When used with a name of a function, it will give yo= u >the name of that function as a string=2E When used with a string, it will >give you that string as a string=2E >See this example https://3v4l=2Eorg/EKnEd > >The fact that this gives you a callable is just coincidental with all >strings being callable in PHP=2E The reason why it works right now is >because a string can represent a name of a class, interface, trait or >function=2E >If we were to replace the transformation with something else, like it is >proposed here, we would have to ensure that it is as versatile as a plain >string=2E Otherwise we would be losing functionality=2E In my opinion, this is extremely unintuitive and surprising=2E I would not have expected this to work, and would consider this more of an unintended side effect rather than an actual feature of ::class=2E In my opinion, this is an argument for ::class producing a ClassName type,= =20 and for migrating such code that misuses it for functions to the first-cla= ss callable syntax (ie=2E strlen(=2E=2E=2E))=2E It might be even possible to issue a deprecation warning whenever a ClassName is coerced to a callable - I am not sure how feasible it would b= e to implement this, however=2E