Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114071 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 54331 invoked from network); 19 Apr 2021 14:41:31 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Apr 2021 14:41:31 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 01228180531 for ; Mon, 19 Apr 2021 07:43:49 -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 autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (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 ; Mon, 19 Apr 2021 07:43:48 -0700 (PDT) Received: by mail-ed1-f50.google.com with SMTP id bx20so39894280edb.12 for ; Mon, 19 Apr 2021 07:43:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lLZTHWLF76RKz9h4+HKEPNGI3gsvQXbz77+w/37XRZk=; b=dolImD8gaw7gUU0wq9coqxDE5CViykseba/GB5uABnMGffeZb8Kd0QHcfMn0ArQRxX zluwlIexZsF2az9/Iy9USApOI/I1gxnW/QleKc01lRxLrT9nqAPJIKgOdf/N50WFm9J3 +ebr2GWHhLn8XOyEsxMxQSVRPfBn2eRJMcYF+NXy/ysd/WSMGwKrcM8d7/k339ZZNtNh R851s2ybL0yeWLEkDRJDQCYiGC3aulpSwg9sCEvXhgD3VQQXDDY8UgleC63EifIV2RP/ PgndjYxwLYuF7ODwD1lHSVyGIwZjXH6naFoNxyiIhdtJiCJZAynbEVAlv/Y9GEBCQIXm cbWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lLZTHWLF76RKz9h4+HKEPNGI3gsvQXbz77+w/37XRZk=; b=T8u3aHalkyq//mDJ5jQyxWkhO0PHqgI2x+tnTMlZXpMQdBFjgaj8m7ex8EIqFQtWcF J68F+EKvy6Xi7HbweC+Y2uv9NEOjcl2TLAMlbIgwqEHIvkS/Nlj4aYQ1l4/9OyJXFqnR /bJuc/2AIAuDx4VOk2XWXGg31oBasSVPOqZqMEks2+idbvAG6rinYsouWCOdlz6KFSj1 gb8HKrECcKDCczsk/wdFd4i9x8QGk51L+8h7Ozu047ZTSOlBIgq8p9LcE54lZgNMhU/A VQXtq//DLN2X9RpZ6iq+W1gKQeGZobkb+x4WNblc0/Gh4PazPv2r7ZxqW/0YZYgLWTQJ u/lQ== X-Gm-Message-State: AOAM532sQxUV9/E1PiyOl3AEPIL6QQDD9whc5Iytt2FkUMtnl+e6Gj6e a+mXXbDX+s4UHsQdZJ6hioLRpZyAAdfSpx5hbhg= X-Google-Smtp-Source: ABdhPJwp2F9VMvSbogqVBSCGK9N2/FnQ2Eh1Sw2ARd9X0KiHRNsr0CpSOXQIz5CYfqMiJpnmZV/1r5PFsBn5TRa7k1c= X-Received: by 2002:aa7:df8f:: with SMTP id b15mr14584018edy.68.1618843427102; Mon, 19 Apr 2021 07:43:47 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 19 Apr 2021 16:43:35 +0200 Message-ID: To: =?UTF-8?B?TcOhdMOpIEtvY3Npcw==?= Cc: Nikita Popov , PHP Internals List Content-Type: multipart/alternative; boundary="0000000000006b648a05c0545b84" Subject: Re: [PHP-DEV] [RFC] [Discussion] Adding return types to internal methods From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --0000000000006b648a05c0545b84 Content-Type: text/plain; charset="UTF-8" > Thank you, Nikita, for the wise wrap-up about the general problem and the > possible solutions! > > I think as far as the original motivation is concerned (adding return types > > to internal methods), the RFC as proposed does well. The only thing I > would > > change is to add the ReflectionMethod::getTentativeReturnType() part > > independently of the userland aspect. I believe it's important that this > is > > exposed in reflection, even if the more general userland functionality is > > not provided. For example, if you have a mock generator, you'll probably > > want to either add the tentative return type as a real return type to > > mocks, or at least automatically add the #[SuppressReturnTypeNotice] > > attribute. > > > > Initially, the reflection-related changes were a core part of the RFC, but > since I didn't find a really good use-case > for ReflectionMethod::getTentativeReturnType(), I moved it to the secondary > part. I think your example highlights really well that it's needed indeed, > I've just put it back to the core proposal. > > > > I'm more ambivalent about the userland side of this proposal. As Nicolas > > has already pointed out, the RFC as proposed requires the library to > have a > > PHP 8.1 minimum version requirement to make use of this functionality. > And > > libraries requiring PHP 8.1 are likely not the target audience for this > > feature -- at least not when it comes to adding return types at all, > there > > might still be a use when it comes to changing them in the future, as > > typesystem capabilities are expanded. > > > > I agree here as well, as neither I am a fan of the current implementation. > Especially after you made me realize that it doesn't even solve the general > problem completely... That being said, I've just got rid of the > userland-related part of the RFC, since this is something somebody can > implement later after giving some more thought for the feature. > > Now that the controversial part has been removed from the RFC, I'd like to > start the vote shortly (late next week), in case there is not any more > feedback. Finally, I didn't rename the SuppressReturnTypeNotice attribute, > but I'm open to do so if you strongly prefer TentativeReturnType of > ReturnTypeWillChange (although I like the latter one more). > I strongly prefer either TentativeReturnType or ReturnTypeWillChange yes (ReturnTypeWillChange would work for me.) They're more declarative and can be re-used by userland without a need for any RFC from internals. Actually, I plan to use them in Symfony to help us add return types asap. Once this is changed in the RFC, I'll be +1 on it. Thanks for doing the hard work, Nicolas --0000000000006b648a05c0545b84--