Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93768 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72616 invoked from network); 4 Jun 2016 14:46:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jun 2016 14:46:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=bobwei9@hotmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=bobwei9@hotmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain hotmail.com designates 65.55.111.81 as permitted sender) X-PHP-List-Original-Sender: bobwei9@hotmail.com X-Host-Fingerprint: 65.55.111.81 blu004-omc2s6.hotmail.com Received: from [65.55.111.81] ([65.55.111.81:63169] helo=BLU004-OMC2S6.hotmail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 18/B5-25194-5C9E2575 for ; Sat, 04 Jun 2016 10:46:30 -0400 Received: from BLU436-SMTP186 ([65.55.111.73]) by BLU004-OMC2S6.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Sat, 4 Jun 2016 07:46:27 -0700 X-TMN: [HQpTzSpPK9/1uqv+BefHlczf34lQKXzN] X-Originating-Email: [bobwei9@hotmail.com] Message-ID: Content-Type: multipart/alternative; boundary="Apple-Mail=_8D81813B-7BB8-4BD6-A739-1260FC9A2AE3" MIME-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) In-Reply-To: Date: Sat, 4 Jun 2016 16:45:46 +0200 CC: Larry Garfield , PHP Internals References: <0A.C5.62101.1C860575@pb1.pair.com> <68b821ac-d71f-4be5-8dca-ae94db332630@gmail.com> <20160603101659.D466A1A81FC5@dd1730.kasserver.com> <6d448fd8-8fda-d795-accb-6b96cd128ccd@gmail.com> <652fdc5a-a164-2054-ed61-305a2b72330a@gmail.com> <20160603142421.346B81A81725@dd1730.kasserver.com> <9814df22-9854-616b-bf02-d0742efefaff@gmail.com> <20160603145857.8413F1A8323C@dd1730.kasserver.com> <1fb072b3-9b9e-1dfd-6b39-7875587b6c7d@seld.be> <5751B50F.2090003@garfieldtech.com> To: Keller Niklas X-Mailer: Apple Mail (2.2070.6) X-OriginalArrivalTime: 04 Jun 2016 14:46:24.0945 (UTC) FILETIME=[DE3A1210:01D1BE6F] Subject: Re: [PHP-DEV] [RFC] [PRE-VOTE] Union types From: bobwei9@hotmail.com (Bob Weinand) --Apple-Mail=_8D81813B-7BB8-4BD6-A739-1260FC9A2AE3 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" > Am 4.6.2016 um 15:48 schrieb Niklas Keller : >=20 > Massive is a nice hyperbole here... > Sure, you can check it manually=E2=80=A6 but why not just always check = it manually then? > You then loose possibilities to reflect on it, have static analysis = rely on code only [currently you always have to check docblocks when = it's not declared; definitely not an option for e.g. Optimizer], and a = single signature is generally easier to parse for a human. >=20 > Talking about reflection, I'm not happy with the currently proposed = solution. >=20 > > ReflectionType::__toString() will now provide a full union type as = string; e.g. =E2=80=9Cint | float | NumberObject=E2=80=9D. What should it return then, if not this? ReflectionUnionType provides a = getTypes() method returning you an array of ReflectionType classes you = can access for their individual type. > That requires libraries like Auryn to manually parse that string now. = It's no longer possible to directly use __toString to get the class = name. Isn't there a better solution? You=E2=80=99ll have to change your code to respect union types and = eventually call ReflectionUnionType::getTypes() in case instanceof = returns true. There are already suggestions to give it a better structure (I can only = reference = https://www.reddit.com/r/PHP/comments/4m93s1/i_want_to_enhance_and_break_t= he_reflectiontype/ = here), but fixing this (along with proper nullable = handling etc.) is outside of the scope of this RFC. > What about ReflectionType::isBuiltin()? What will it return? Just = false? True if only built in types are used? false. The individual ReflectionTypes in the array returned by = ReflectionUnionType::getTypes() will be telling you what they are. > I think allowsNull can be handled as is. Correct. Bob= --Apple-Mail=_8D81813B-7BB8-4BD6-A739-1260FC9A2AE3--