Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113473 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 85134 invoked from network); 11 Mar 2021 13:49:54 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Mar 2021 13:49:54 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D8261180508 for ; Thu, 11 Mar 2021 05:42:24 -0800 (PST) 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,HTML_MESSAGE,MISSING_HEADERS,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-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (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 ; Thu, 11 Mar 2021 05:42:24 -0800 (PST) Received: by mail-lf1-f46.google.com with SMTP id k9so39803918lfo.12 for ; Thu, 11 Mar 2021 05:42:24 -0800 (PST) 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:cc; bh=h1AfHY2GJolv7Du5I7D/W6svgs/17hfL0PAQ5d5RN8s=; b=prYGsAWyBJm6oxqF+uJzecW/V5pl3A+18GNqJF1aeruLMmm+wV21iHM3rD2UzClWXM 1NPvevlJdXkeOtvZgrWx/gDCR4dT/2j9MKU9CvbwDmJyTLmITyNfNR819rnq8jjCpE25 rc3IBQE1ZRq11WqpeAFvBEhCGXT8LcdQSOLcDy98UWyJcLrW5qA++DV5M1Q1unlKvQ55 l1M/EwBsNKf0eTRRgUCOA/tgQ07JlIMI5qABqbVUBUgoJOzqNWEkoXDC65qOAzmynoxM FREEAqRM5dROTZMivRfZ71FEEqKmdxgVLzzCT+SpFlA4UD708VBKLTNomO0DJO5DsfLa 9bUw== 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:cc; bh=h1AfHY2GJolv7Du5I7D/W6svgs/17hfL0PAQ5d5RN8s=; b=bAaAodZFi6NnaXxQ+fpO+M1Co5e6wTtlABsro4iiYlRapomDEppp/Izn3gDcT2ZxB8 iYDnb1XXIy3vFKKH+orK0n3G63Qa+5mun+ohBB5CFX3lECx0XXNkYO/cVnvXw+xdL9ZT nzoZ1z2HnkIWX5TmiEr4iVsk0i2ijsQg281rtcJlrdpH79hbBWAiaWrYg7voS30eWsdZ wBYNO3gDJrKqMjI1Nq+qBBVGtS2eKgJ+Pk/YWycBScU7HvL7LQycYBv4hsU0qoftvez6 9/C4cAb9pSBW9hl2DOZjnE8trCN5wFBLTPwMJA+GVm3aJpNkYplv+R3FhcEo5N6Ew1Xo uG2w== X-Gm-Message-State: AOAM533PdB4X1LbDPabt4n6+Rwkep/trUJOXyGGamDQ3yzziV21O4E9D ksXyLRwOpwgnu4YA5xizW0ji2ICcWP+tO6NMEwD/8CgkN14= X-Google-Smtp-Source: ABdhPJxbUI5ErdzIWbq7VO6jGnCcYmdtTmEWjU49hAFwSKvsyrGI6JKwLVofnpCcD+ANC7rHyx6UkuGq54PiU9vxPyM= X-Received: by 2002:a05:6512:3188:: with SMTP id i8mr2394203lfe.121.1615470141097; Thu, 11 Mar 2021 05:42:21 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 11 Mar 2021 14:42:10 +0100 Message-ID: Cc: PHP Internals List Content-Type: multipart/alternative; boundary="000000000000e7c99d05bd42f3a4" Subject: Re: [PHP-DEV] [RFC] [Discussion] Adding return types to internal methods From: kocsismate90@gmail.com (=?UTF-8?B?TcOhdMOpIEtvY3Npcw==?=) --000000000000e7c99d05bd42f3a4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Nicolas and Claude, First of all, thanks for your comments! Let me answer them one by one: 1.) A few other people off-list also shared their negative feelings about the E_STRICT. So I'm ok to use E_DEPRECATED instead. Now that I implemented the suppressing mechanism, I think using a separate error type is not needed anymore that much. 2.) Unifying the TentativeReturnType and SuppressReturnTypeNotice attributes is an interesting idea, and I would love to get rid of the latter one. Although, my concern is that doing so would eliminate the possibility for an overriding method to declare its own native return types (it's possible that they've already defined return types): so any child class could literally define return types at its own will, while it was not possible to do before. I'm eager to listen to any solution that would address my concerns. :) 3.) I'm not sure you noticed in the PR, but in fact, I also implemented the TentativeReturnType attribute. Currently, it can be used as below when DateTime::modify() is overridden to return the ?DateTime type= : class MyDateTime extends DateTime { #[TentativeReturnType] public function modify(string $modifier): ?DateTime { return null; } } How does this syntax look like for you? Compared to your proposal, the main difference is that the attribute doesn't itself store any type information, but it's done among the function information as normally. In my opinion, the current implementation has multiple advantages over the one you proposed: - As far as I can tell, it would be *very* cumbersome to parse and validate type information from strings, rather than reusing the capabilities we already have. But I'd be happy to be corrected if I'm wrong= . - Apart from the compiler itself, I think parsing type info is more straightforward as currently implemented for users as well as any tooling - We should also think about people who already declared return types for overriding methods. I don't see any good reason why they should repeat this information in the attribute. - I'm also not sure how the attribute could be used to retrieve the tentative type? Should it return a ReflectionType? Returning just the string representation seems like subideal for me. 4.) Claude, I think you make a good point! So non-private, untyped properties could be converted to typed properties a little bit more gradually if we made this "tentative" type mechanism available for properties as well. Coincidentally, I recently came up with the idea that I'd like to fix type issues with internal class properties (e.g. lots of them don't respect the strict_types directive), and I also thought about migrating them to typed properties for PHP 9.0. All in all, I don't want to include properties in the current proposal, but I'd probably work on it next time. Regards: M=C3=A1t=C3=A9 Claude Pache ezt =C3=ADrta (id=C5=91pont: 2021. m= =C3=A1rc. 8., H, 16:19): > > > Le 6 mars 2021 =C3=A0 23:56, M=C3=A1t=C3=A9 Kocsis a =C3=A9crit : > > > > Hi Internals, > > > > I've just finished the first iteration of the RFC ( > > https://wiki.php.net/rfc/internal_method_return_types) as well as the > > implementation based on the feedback Nikita and Nicolas provided. Thus, > I'd > > like to start the discussion phase. > > > > Regards: > > M=C3=A1t=C3=A9 > > Hi, > > Two remarks: > > (1) The RFC is about return type of non-final methods. The same issue > might arise for typed properties, whose type are supposed to be invariant > under inheritance; although it is admittedly rarely useful to redeclare > them in the subclass. Should typed properties be handled in the same way, > or should we simply recommend to not redeclare properties? > > (2) Nicolas Grekas has beaten about E_STRICT (E_DEPRECATED is fine in thi= s > case). I=E2=80=99m just adding this: By reintroducing E_STRICT you are ef= fectively > reverting the [Reclassify E_STRICT notices] RFC, whose motivation was to > =E2=80=9Csimplify our error model and resolve the currently unclear role = of strict > standards notices=E2=80=9D. Thus, you should propose a clear role of thos= e > resurrected E_STRICT notices, that justifies the complication of the erro= r > model. > > [Reclassify E_STRICT notices]: > https://wiki.php.net/rfc/reclassify_e_strict > > =E2=80=94Claude --000000000000e7c99d05bd42f3a4--