Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117579 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 16968 invoked from network); 23 Apr 2022 16:39:53 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Apr 2022 16:39:53 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C05C11804A9 for ; Sat, 23 Apr 2022 11:14:25 -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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f175.google.com (mail-yb1-f175.google.com [209.85.219.175]) (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:14:25 -0700 (PDT) Received: by mail-yb1-f175.google.com with SMTP id g28so696675ybj.10 for ; Sat, 23 Apr 2022 11:14:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FaycUcFf3j1qmtW2pFBEcdiq4uNWbIDGb8GmaF+OckQ=; b=H0nIyERxUqtOBmGdVCA67T21xxfVk+v8No/bm7qepL9TTWQ0wEiJYgYNwndKCHa8w1 1nndYB8JwXnsnqpZZVayC4ix8MtiTTPplm11/wPeNW649PRWFBK9KfzKBrXXJduPI+bx uHI4ILu60x0or1qSFegfYzlLIxbfnIYYrAloi3k12TZ8NKLslLaPmB139BAKCA10Z67a QT09ekENrIATCQek4z9xwEep80iuXQuRpFima4E1FPotK97kaQCXKlDZQawSx61jueFq Ddksr0mg94jAx5PTCj+lo+B7/ESkyAi9CoU6ovmzF/Ri8JPL65km0IDuG8GKvlX7RT6y 3msw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FaycUcFf3j1qmtW2pFBEcdiq4uNWbIDGb8GmaF+OckQ=; b=jYhHHrssqcqhG+9pC+0Al5FmWmhsouLqEvo78sNzCtfOGPhjiVAlPRx9iNvBNJznQA lKd30ffTOiKRlBsH7yaOKfNkQf61u+xRBEQWGU/l5Nc2iiPUXBVwnM9Y+13/RoVW/Dho 1HJbJU8ihYuE+FbXYQpJl1tpPeuASWsdmJoIr3LmuBWt5hCwYupmckSFSoMU5NfmoEjA pgazLMzbgBUD0jZ1oqEkILB7tB9JjVQr7aI2rOMHtOr6N69wOdnerpv1oV/tJrZt/GDu Q0Hce/5V1/v3MMIHlLjXXOYbVSQkJBQksEps/OGd6ujCyMgnhRDMXv1IENLlmDh93Eeq xLlA== X-Gm-Message-State: AOAM531Qwhf9wMffZcIMDJAMElMWero5uC/yDrLU9ztuFVH9y0Ex+PL8 feLELi8OWt912ppB9O7WFpE42RmsJxUahitIGWjXdn8yGmI= X-Google-Smtp-Source: ABdhPJxSdGiuwVOWZCXFR0jjQm1tSc34yvWa1lLWkXYS9BY6N6+miy3fBdXierzBwbWcLCaodAE4eZEdxBvq4jCUnhM= X-Received: by 2002:a05:6902:1109:b0:645:58e:a373 with SMTP id o9-20020a056902110900b00645058ea373mr10216122ybu.231.1650737664529; Sat, 23 Apr 2022 11:14:24 -0700 (PDT) MIME-Version: 1.0 References: <1658b0e3-4c0c-447e-85ed-531f70e4b6f7@www.fastmail.com> In-Reply-To: <1658b0e3-4c0c-447e-85ed-531f70e4b6f7@www.fastmail.com> Date: Sat, 23 Apr 2022 19:14:13 +0100 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="0000000000001c989e05dd5650a0" Subject: Re: [PHP-DEV] Canonicalize "iterable" into "array|Traversable" and Reflection From: george.banyard@gmail.com ("G. P. B.") --0000000000001c989e05dd5650a0 Content-Type: text/plain; charset="UTF-8" On Sat, 23 Apr 2022 at 19:06, Larry Garfield wrote: > 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 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > Correct, and a better way of visualising than I did. I do think option 2 is the most reasonable. Best regards, George P. Banyard --0000000000001c989e05dd5650a0--