Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117578 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 15472 invoked from network); 23 Apr 2022 16:32:11 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Apr 2022 16:32:11 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 029F91804C6 for ; Sat, 23 Apr 2022 11:06:44 -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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS29838 64.147.123.0/24 X-Spam-Virus: No X-Envelope-From: Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) (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 ; Sat, 23 Apr 2022 11:06:43 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 407B53200D18 for ; Sat, 23 Apr 2022 14:06:41 -0400 (EDT) Received: from imap43 ([10.202.2.93]) by compute1.internal (MEProxy); Sat, 23 Apr 2022 14:06:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1650737200; x= 1650823600; bh=/fZoNw+9Of+DKxRfCyP9KtRT79jo0yr9eV8MOps08+c=; b=A ORsUl3koeUy3b0GSCj9oZISkuccUEWn4cPdOYC0gW3O4ofnaelqXUZXIdNtQhpkx STvtrXGXHJGzPD2h3pmVYkFa+wrXvGwtixMfcqP9gqtBUJqtB7BL+22K3lw8QcCS 2DGx6lXKnmCjiIshWfDzEW2ylVVFQ3wgnsN+3a16AAkqGXogjymmdWKYDxM3xm9n //ADFZRQrX2gdWGPdayMQ/v8QJOYRmIwHJVpccBNIrtu7Nve8zniu/I/JHu7Y4g6 lOEz2yUeV4C0h7Z5AtfiF77mIZ7PGW0EvzCDxaRZx7pVkgY/kxpkzvrBjLifWxC9 LP1lHw4fAuFkfkrEUz7Tg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1650737200; x= 1650823600; bh=/fZoNw+9Of+DKxRfCyP9KtRT79jo0yr9eV8MOps08+c=; b=l vhTivnN5JCsM3txtnGlta1coxieFGd/kSUTAj9By6sen7V31IMc+XgnugHu48beD +eeIp1PfZpxxTYPlJfbRyPTY6HeQeecsHN+OrMz0HeIxd0YqzRWZJeiaUvX/G1Ag nXDeCCjG3Zh6yAokVVoT6gnPKnoCTD/w4a5HEx2csNPDSM0HvcPM4H3WAXTcxBk/ JZPA+AHtrwqzjwUZC3csLMVlF8T+yf/a/DnVlqg8vtIpAlDFFkbJA8LXvFebjBIF XKBuESJJ24tdcZIvNmUhI6IY/ATHhuf5sdCFZirgMeVC6F+nEHPfCBTltDT1yhzH WVI30YOEcZ/fYEoL19UGw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrtdeigdduvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeekteelheffgeefvddufeeujeekhfdvtdeuuedvveet ieevheeludegjeduhffhteenucffohhmrghinhepghhithhhuhgsrdgtohhmnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgr rhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 45DC2AC0E98; Sat, 23 Apr 2022 14:06:40 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-569-g7622ad95cc-fm-20220421.002-g7622ad95 Mime-Version: 1.0 Message-ID: <1658b0e3-4c0c-447e-85ed-531f70e4b6f7@www.fastmail.com> In-Reply-To: References: Date: Sat, 23 Apr 2022 13:06:14 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] Canonicalize "iterable" into "array|Traversable" and Reflection From: larry@garfieldtech.com ("Larry Garfield") On Sat, Apr 23, 2022, at 7:27 AM, G. P. B. wrote: > Hello internals, > > One area the engine currently needs to take special care is dealing with > the typing relation between iterable, Traversable, and array. > The change is to canonicalize "iterable" into "array|Traversable" as this > then removes this special case. > > However, doing so breaks Reflection for iterable types and will now return > a ReflectionUnionType instead of a ReflectionNamed type. > There are a couple of options to proceed: > - Accept the BC break, and expect end users to already be handling union > types for code running on 8.2 (least complexity) > - Only provide a BC layer for (?)iterable to return a ReflectionNamedType > and have usages of iterable in a union type be exposed as Traversable|array > (OK complexity) > - Full BC such that even in union types where iterabl was used > Traversable|array gets converted back to iterable (high complexity) > > The PR for this change is https://github.com/php/php-src/pull/7309 > > This PR is also blocking the implementation for DNF types, as it vastly > simplifies the implementation of it. > > Best regards, > > George P. Banyard To make sure I understand, Option 1: * function foo(iterable $i) // $i is ReflectionUnionType of array,traversable * function foo(iterable|Beep $i) // $i is ReflectionUnionType of array,Traversable,Beep Option 2: * function foo(iterable $i) // $i is ReflectionNamedType of iterable * function foo(iterable|Beep $i) // $i is ReflectionUnionType of array,Traversable,Beep Option 3: * function foo(iterable $i) // $i is ReflectionNamedType of iterable * function foo(iterable|Beep $i) // $i is ReflectionUnionType of iterable,Beep Am I following correctly? If so, I'm fine with 1 or 2. I... cannot imagine a situation where someone is doing iterable|Beep to begin with, so I don't really care if that is a slight break. Though... I do have some code that might get cranky with Option 1, as it doesn't deal with union types at all (for various reasons). I don't think it currently deals with iterables either, which is possibly an oversight... So, I think my preference would be 2, 1, no 3. --Larry Garfield