Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94385 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4258 invoked from network); 5 Jul 2016 13:21:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jul 2016 13:21:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.41 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.220.41 mail-pa0-f41.google.com Received: from [209.85.220.41] ([209.85.220.41:34008] helo=mail-pa0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E8/63-14106-C54BB775 for ; Tue, 05 Jul 2016 09:21:33 -0400 Received: by mail-pa0-f41.google.com with SMTP id bz2so67480589pad.1 for ; Tue, 05 Jul 2016 06:21:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=QWlA569bPI4TsFqv6YQZFtplHC+Ucb+SUdpq41oQntY=; b=s/ZRvqW7raFJoxqiyTGxYCqOpilrmusS7CmLadqzDkMUJRakjg4pxtGUt8/2Zx1xt/ CCbRK+QgN8lPtlk+DPFzwqE7lDyuuhH1VGQhPzBW7C3DgYDv2ttUp4+NMmezM/ynOE// Iw1dwuZB1400VUC/+B6a37OxwSo+eHEBVh6E8gK8OfftRs2CkEytc1DMAVpF7V2aEcTR uzbqEh8Bq8F8L8FqHq7+xpLgSBoQGzoj/Ek8RCNPCQvzx0+dWsIKi7obH8LaG1TYxowS a9D0iaJVriusXjLvtshei35ioyAVDEXwSr1x4ZZk+oJVyWM6EsvzitVKYnXr1hCKInUg Ioqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-transfer-encoding; bh=QWlA569bPI4TsFqv6YQZFtplHC+Ucb+SUdpq41oQntY=; b=MI7StfwsMEBuipS89a8t9Sd6dVYtFxXJ+zbhlSkguq2ErPpHfK8kvtXC46XTf3OL05 RJ2h1YRDsimbnGQoN9t/DkmxW/tyo3svQCtIjb1zz+jYym1OCQu65ZqYyyAF+L8BbvH6 fneZ0Er6djG170QE0qoBDx0G3qX59/xEPA1XZCG4aAcZDZsKFlxlzCIEbrTrl2W+rKyz zV3H+aIEuqLj9mMLjy+SU9ukuk6VNWHJ6cvjV25TM/r6axoLi7piFFZR0KETU3mCxxIQ gRpgprGhO/al8J8u4ygvLdfHDIHhpymReAASjsrWvXL/y8b0S8smvEnc4jpqHEm//121 VYfw== X-Gm-Message-State: ALyK8tK8GGrmbtBUWGEB+B64OE1ELZYy1EIS6b6DlZzhkTmwDFRdUSt5lw25DDk7NNFxGeQDkYYTN+OaBOzm/Q== X-Received: by 10.66.148.162 with SMTP id tt2mr2897344pab.53.1467724889310; Tue, 05 Jul 2016 06:21:29 -0700 (PDT) MIME-Version: 1.0 Sender: morrison.levi@gmail.com Received: by 10.66.23.72 with HTTP; Tue, 5 Jul 2016 06:21:28 -0700 (PDT) In-Reply-To: <1f39f97a-6aaf-8550-9f82-a7e80465f903@telia.com> References: <1f39f97a-6aaf-8550-9f82-a7e80465f903@telia.com> Date: Tue, 5 Jul 2016 07:21:28 -0600 X-Google-Sender-Auth: RNdR-FtbG538vAYO9N1L6fW-YFc Message-ID: To: =?UTF-8?Q?Bj=C3=B6rn_Larsson?= Cc: Nikita Popov , PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC][Vote] ReflectionType Improvements From: levim@php.net (Levi Morrison) On Mon, Jul 4, 2016 at 10:51 AM, Bj=C3=B6rn Larsson wrote: > Den 2016-06-30 kl. 23:57, skrev Nikita Popov: >> >> On Thu, Jun 30, 2016 at 6:06 PM, Levi Morrison wrote: >> >>> The RFC for improving ReflectionType[1] is now in voting phase. The >>> voting >>> window is June 30th through July 8th. I have not finished the patch but >>> I'll have it done before the end of voting. >>> >>> [1]: https://wiki.php.net/rfc/ReflectionTypeImprovements >> >> >> Replying on-list as multiple people asked: >> >> I'm voting against this RFC, because it introduced not only the >> ReflectionNamedType class (which is reasonable), but also the >> ReflectionClassType class (which is not). >> >> My main objection to ReflectionClassType is that it is autoloading >> dependent (*). Something like getReturnType() on a class type hint will >> either return a ReflectionClassType if the class can be loaded, or a >> ReflectionNamedType if it can't. I think this is confusing and I'm sure >> that this will lead to broken code: For example, people will try to use >> "$type instanceof ReflectionClassType" to check whether something is a >> class type hint, while the currently correct way, which works >> independently >> of class loading, is to check isBuiltin() instead. >> >> I don't think that most consumers of ReflectionType are interested in >> obtaining a ReflectionClass for the type hint anyway (which is the only >> functionality that ReflectionClassType provides), and if necessary this >> can >> be easily done in userland. There is no need to over-complicate the >> ReflectionType functionality in this manner, especially with the propose= d >> semantics. >> >> Nikita >> > Maybe one should split the vote into separate for each function. > I mean pity if vote fails because one function is not attractive while > the other one is... > > What do you think? > > Regards //Bj=C3=B6rn Larsson I think that it's disappointing that I received no feedback on this RFC at all and yet have this ratio of votes in the negative. I'll take this opportunity to share a portion of a conversation I had with Nikita that demonstrates why ReflectionClassType is actually useful: > Nikita: But does it really help them? I don't see a lot of differences be= tween these two: if ($type instanceof ReflectionClassType) { $r =3D $type->getClass(); } // and if (class_exists($type->getName())) { $r =3D new ReflectionClass($type->getName()); } > Levi: ...[I]t will fail for interfaces.] ReflectionClass can be built for= those but class_exists() will be false. > Nikita: True :) The (currently) correct code would be: if (class_exists($type->getName()) || interface_exists($type->getName()= )) { $r =3D new ReflectionClass($type->getName()); } But if we add some other type such as enums we may have to add more conditions. As long as ReflectionClass can be made from the type then doing it in the engine is fully forward compatible. I hope people who voted no will share why they have done so, but I also hope they'll switch to yes if they voted no because they don't see it as being useful.