Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113990 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 17760 invoked from network); 7 Apr 2021 17:02:04 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Apr 2021 17:02:04 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 332A71804B3 for ; Wed, 7 Apr 2021 10:01:23 -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=-0.7 required=5.0 tests=BAYES_05,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-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (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 ; Wed, 7 Apr 2021 10:01:22 -0700 (PDT) Received: by mail-ed1-f47.google.com with SMTP id f8so17722908edd.11 for ; Wed, 07 Apr 2021 10:01:22 -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=62OasfOgkiSU4YocAENbYba62zqWPiQL8kbC9XWDVes=; b=b1jRuZE4o9VhEd9tGqn04bkvcc+sroxpCX9COPAtGM66pfupjQb1zlVx6LnbEia8lw ideFl4Bl5rZJTqLuL8Ue3mg7xXwURXWmtSqSfxJ42/VCuxB3NKYUGoIsqSKyH+8XBSh0 RgHeeXs+2iFtWzYHEn0bFpwSQ/ZLkMBtsUNB2/pgzCsril/x7TUZ3j7RhntPO1sZG/8J hZAoHXxvZBVm+a3vp0ehYAoYVBpQdTzJcyemU7KDTwUzlndjPDdOdPSmjwsxoM2SZ7KA ArLoI6MxEzuX+TSfEkivwUd5DISDgOAOZNlKnrUxRNWZv+g41USgrOUG7gyKIvipQU24 2/9w== 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=62OasfOgkiSU4YocAENbYba62zqWPiQL8kbC9XWDVes=; b=f0cxtWRAI6gse0p4RPrcKAaTIcXvNNZX41w+yqmEFaPEfpVtdhn8zoBmSAAbCtSQWB Fvr24Co3ode7g2lbiKnUiocgBhShXJsVw0hEP5/olRvplYmRKh3kOcRhneWU89kzAHRF odNUNH6BaEaXEKRn6MlCoH1259ojC8sHrFvmaCgflLCx65GREG7gY1YKKNc8RDiBY+jj FuUWytpHL0/CnRJxCELe+LJC/7Sj+nVmbR3GK7m+cCa3bVHgJcP1P8SzlsLX68zrZ0sx 73cGINb9JPVEVxVSLAh/Y6Bbgsl4rjHmxGd/4SWf0rebnEJYXPCnT1aOloDfYGDf9/Oh IIiQ== X-Gm-Message-State: AOAM532I+rY9TnJUu7HTsGiVR3mrcgWDcl1ZPv5vWv0B3L/anyg4DTOh Jw+4+l7Nm8D+PACiAM8hIrivES7LJNW9hbfsMhA= X-Google-Smtp-Source: ABdhPJzEJZZErHoag6WT4o9v3tf64QmAB9d/7KMBh7Tk1KiYBKIhXQddCAptLTuBccqhL6vFFuJ/j5NHhQcal58cf+8= X-Received: by 2002:a50:ed17:: with SMTP id j23mr4957093eds.260.1617814881753; Wed, 07 Apr 2021 10:01:21 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 7 Apr 2021 19:01:08 +0200 Message-ID: To: =?UTF-8?B?TcOhdMOpIEtvY3Npcw==?= Cc: PHP Internals List Content-Type: multipart/alternative; boundary="00000000000056dd5a05bf64e197" Subject: Re: [PHP-DEV] [RFC] [Discussion] Adding return types to internal methods From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --00000000000056dd5a05bf64e197 Content-Type: text/plain; charset="UTF-8" > For userland, there are already ways to declare the planned return type >> (aka @return in phpdoc), so we might not need any new way to declare this >> from the engine pov. >> > > Yes, I think I agree, but I'd be curious about Nikita's opinion as well, > since he brought up this problem first. > > >> We should replace the SuppressReturnTypeNotice by the TentativeReturnType >> one right away. > > The TentativeReturnType would mean: "I'm going to add a return type to >> this method in its next major". >> As a consequence, for child classes of internal methods, this would >> suppress the notice. >> > > If we get rid of the userland part of my proposal, then I think we can > really rename SuppressReturnTypeNotice > to TentativeReturnType. > This would mean that the RFC could describe how userland (code analyzers) should understand the TentativeReturnType when encountering one, without asking anything from the engine when base userland classes are extended. For internal classes, the attribute would just mean what you wrote already. That'd be fine to me. > As a corollary, adding this attribute should conflict with having a real >> return type. > > > This is the only questionable part for me, because then this RFC would > cause more trouble for overriding methods > which already define a wrong return type: a deprecation notice would > always be triggered for them on PHP 8.1+ > until return types are fixed or removed. And as we discussed it > previously, fixing them is not always possible. > Or is there any specific reason I'm not aware of why you favor this > behavior? > To me, overriding methods that define a wrong return type should remove their return type as a fix, and replace it with the attribute. Removing a return type is allowed by LSP, so this should be just fine. Nicolas --00000000000056dd5a05bf64e197--