Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113416 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 75394 invoked from network); 8 Mar 2021 15:06:33 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Mar 2021 15:06:33 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 279E51804B8 for ; Mon, 8 Mar 2021 06:58:20 -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=-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-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (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, 8 Mar 2021 06:58:16 -0800 (PST) Received: by mail-ej1-f43.google.com with SMTP id jt13so21023999ejb.0 for ; Mon, 08 Mar 2021 06:58:16 -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:to :cc; bh=fQY1Vku4+gJhGN6WMrt8h60MzdHuRlgsoIHiJgA5Lvs=; b=m73PHILNyimyevs1kev/ctVFoWjJSr1qOxEj0UXAB/vTyUyGioVZF3TPNKwSjQaj/x g7uO5koOWPm5u2hSwA7ktDcbACdbnaGJZ8bYsyJ/aFSyyy70X72QCdTOCrvwDN2gQFuf f09hfSTOIE9Up/UUUhy+dp0TSQ06znxRHr7nNyrEA4t6K9yU7NuYeIagKzgy2nXE5tL5 c9nDvtJNyRCKLIuM1MpEDHIAQR/HwkH+j9R8V+0UWYHLTwH0fmy0O6XMpqrfK228KNV3 oq28gLUMjmHpI/3yyewKlpkPl2fLZgoI2OOhutJHANwKhnn4sZ0+GCYi9X8FBOyV7jbM MVAw== 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=fQY1Vku4+gJhGN6WMrt8h60MzdHuRlgsoIHiJgA5Lvs=; b=m2p9KfE/zsxb7+88f2Rf3zT0TAczmJAJKtdiSkf5yeFMUMjMcpVX5SiUbdk4WWU9CS zNXHVs5QtoXjUSHRYNYy7J+V1pV3wS773we418k5xtpfpvs/J6AMooNBs5Xg0KDNgJte M/JRhP/wm6UK9MZ7tgWhp0j9hAe0Cdei0FKa1OlBX8yekZvyi4NbpbqvZwJrBDu/j+zr cj3k0Zou23s7iQyssq7j+WlkdrqMIKV3aVP14qZYwIR8664hT75Kff7PjKx1LJImB6K2 EAHeVqXJab1zlgT/Za+pntCNoKM4x6GkGLyxY8u+PDLYl5f7gwxaUjArJZRuLxfhNB2E R70A== X-Gm-Message-State: AOAM5329W37+rnniyvC0qINyCawTwCOaJGHsko9qBVQ0uyx90zfrU6Or yQinGB+CX15/z2Ccq3B+86ocg2KC/lzjyP1D24s= X-Google-Smtp-Source: ABdhPJwPJWSEBddPs6VXK77uWcBS+Ng2BLoEhbf1fNZ+qQ1flmwRfVNYHFFyACn1/By+Y4/mj3BukoFOwIbJpBKvpbU= X-Received: by 2002:a17:907:d8a:: with SMTP id go10mr15535891ejc.46.1615215494989; Mon, 08 Mar 2021 06:58:14 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 8 Mar 2021 15:58:03 +0100 Message-ID: To: =?UTF-8?B?TcOhdMOpIEtvY3Npcw==?= Cc: PHP Internals List Content-Type: multipart/alternative; boundary="000000000000d08d6e05bd07a9bd" Subject: Re: [PHP-DEV] [RFC] [Discussion] Adding return types to internal methods From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --000000000000d08d6e05bd07a9bd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello Mat=C3=A9, https://wiki.php.net/rfc/internal_method_return_types) as well as the > implementation based on the feedback Nikita and Nicolas provided. Thanks for moving this topic forward, it's very much needed. I like the word "tentative" you're using to describe the missing return types. I would be good with the RFC but I want to give a few different ideas to challenge it a bit. Here they are: - About using "E_STRICT", I'm not really sold. I think these notices should follow the same path as deprecations as far as reporting is concerned. By using E_STRICT, many error handlers will throw exceptions, while the code is fine really. Deprecations don't lead to exceptions usually (at least they never do in any Symfony stack). Semantically, a deprecation fits well to me also. - Suppressing the notice is very much needed, but I think we can merge the corresponding attribute with the TentativeReturnType that you mentio= n in "future scope". - As a corollary, we might not need the new methods on ReflectionMethod: instead, we might make getAttributes() return a TentativeReturnType attribute for internal methods too. To summarize my proposal, I think we need only one TentativeReturnType attribute, that we would put on internal methods, and that would also be allowed on userland methods. ReflectionMethod::gettAttributes() would report these attributes for both internal and userland methods. The attribute would need to convey the allowed types. This could be done with a list of strings. Taking your example from the RFC, this would look like this: class MyDateTime extends DateTime{ /** * @return DateTime|false */ #[TentativeReturnType(DateTime::class, 'false')] public function modify(string $modifier) { return false; }} In this example, this would duplicate the docblock, but many docblocks contain extended return-type info that the engine doesn't understand anyway (list of types, etc.) When engine sees these attributes, it would behave as you describe in the RFC, with one possible extension: it could also validate the supplied list of types and check LSP on it (when there is a parent type). Does this make sense to you? Nicolas --000000000000d08d6e05bd07a9bd--