Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116464 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 99066 invoked from network); 19 Nov 2021 13:27:11 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Nov 2021 13:27:11 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C29531804C4 for ; Fri, 19 Nov 2021 06:22:51 -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=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS36024 206.123.114.0/23 X-Spam-Virus: No X-Envelope-From: Received: from mail1.25mail.st (mail1.25mail.st [206.123.115.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 19 Nov 2021 06:22:51 -0800 (PST) Received: from smtpclient.apple (unknown [49.48.217.115]) by mail1.25mail.st (Postfix) with ESMTPSA id 3C352607ED; Fri, 19 Nov 2021 14:22:44 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) In-Reply-To: <05aa01d7db0e$783fa120$68bee360$@webkr.de> Date: Fri, 19 Nov 2021 21:22:40 +0700 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: References: <05aa01d7db0e$783fa120$68bee360$@webkr.de> To: =?utf-8?B?QW5kcsOpIEjDpG5zZWw=?= X-Mailer: Apple Mail (2.3654.120.0.1.13) Subject: Re: [PHP-DEV] Is there an RFC/discussion for ::class being a specific type? From: php-lists@koalephant.com (Stephen Reay) > On 17 Nov 2021, at 00:22, Andr=C3=A9 H=C3=A4nsel = wrote: >=20 > It is common (with DI systems for example) and to my knowledge not > particularly discouraged to have function parameters that are supposed = to > accept something like Foo::class, which currently is a string. >=20 > It seems logical to ask for a special type that can hold class names, = so > that parameters that can accept a class name can be type hinted more > specifically than just (any) "string". >=20 > Regardless of whether or not such a proposal would be accepted or = declined > (for complexity reasons maybe) I couldn't even find any such proposal. = Has > this really never been asked? >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php >=20 Hi Andr=C3=A9, I=E2=80=99ve wondered about this kind of functionality myself, but IMO = to be particularly useful it=E2=80=99d need to support the ability to = accept a classname that is a subtype of a parent class or interface. I = can=E2=80=99t think of too many places where I=E2=80=99d want to know = something is a classname reference, and not also want to know that it's = a subclass or implementation of something specific. This typeof functionality could support some very expressive solutions, = when combined with union types, and anonymous classes.=20 Cheers Stephen=20=