Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114100 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 85440 invoked from network); 22 Apr 2021 10:34:25 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Apr 2021 10:34:25 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 925021804BD for ; Thu, 22 Apr 2021 03:37:22 -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-il1-f172.google.com (mail-il1-f172.google.com [209.85.166.172]) (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, 22 Apr 2021 03:37:21 -0700 (PDT) Received: by mail-il1-f172.google.com with SMTP id b17so37397350ilh.6 for ; Thu, 22 Apr 2021 03:37:21 -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=oiI9eNcBy3/D77p7Uzx3dz84KTO+uDEOhSUrhdlR5R8=; b=FZ2Bi+noPqNAIPgyEUY7uJTVkxUu2DtY1vSWMstAhWNubnBSH7NWSzQbekL3xkXfev eHmrRNB1YT21Qcs/40thjC6bfTZ1hbCcfqMwfqw3jO173TZM+zGweeTijx34njXfHBm+ H+Ns5KhReVks/xN5FAlhkRhp1gwPFKS36X72l6qTrW7Jz4lEFy6926pxgpmQ7+T7WB3G 7O+cTfprvgDcUonkNNGd93HvH13TbWjY/D0T7bg0RCjSBLk1GFzduDAnPv4edHp7ga58 ftyfF8x1en+6h8tGg9XFvO4PrYqIFs2hp1MO1UuakZjNj3CaWKUePXIoGHTCAXs5NiMU IW/Q== 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=oiI9eNcBy3/D77p7Uzx3dz84KTO+uDEOhSUrhdlR5R8=; b=XwYVN/wXWDmPsWlksslaXS9/OW44DuJELXp5EKjJACRJXFvDAfk0TngavDki7qTSUx QcgVKe0LAWBMT3Ekx4l88OZiK2kuniJrIWImHrXERVHL+2sxNtjPkMYP+2zSCwbAjS5u 4mq0MAv96SkDV3IUYbH2kqW5KWHkypLPvjMHCtAfYdWjOOlCobXCegSAxN3mmDdSpJE3 iYZ7xxaR9FxbgOZCJXPkBimYnMtbGEWAYfHAQ83LQAKvEl4IXcTKTgKVRsPWuFjIJUyL /48oN1PcWrSIEuVagzqrq4hMxFG1mrINPr3Gcs1VEQMCfI/jCDqlJQRm1heQmZeA8DRn Jr6A== X-Gm-Message-State: AOAM530yPRaCmOH4cBnw+I5SsNFBkU2L9UyU2vF8uICpfR4XQSDP3YfC S0MxU7JIMgoh3q0hNS8e7UQABWg7siBlJiLmoKk= X-Google-Smtp-Source: ABdhPJxcifhrxLvdz7oJGIjalzAD1PWmHUMox7EBkFF0nQiEE7LhmJ7wgBKlphrLoI6/n+AXpmPeOWKgeZE+Wb3xNfU= X-Received: by 2002:a92:cb86:: with SMTP id z6mr2137276ilo.35.1619087841292; Thu, 22 Apr 2021 03:37:21 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 22 Apr 2021 12:37:09 +0200 Message-ID: To: =?UTF-8?B?TcOhdMOpIEtvY3Npcw==?= Cc: Nikita Popov , PHP Internals List Content-Type: multipart/alternative; boundary="000000000000a3f72305c08d4304" Subject: Re: [PHP-DEV] [RFC] [Vote] Adding return types to internal methods From: ocramius@gmail.com (Marco Pivetta) --000000000000a3f72305c08d4304 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hey M=C3=A1t=C3=A9, NikiC, On Thu, Apr 22, 2021 at 12:15 PM M=C3=A1t=C3=A9 Kocsis wrote: > Overall, I see the change of reported `ReflectionMethod#getReturnType()` >> as non-problematic, and tooling around reflection would continue working= as >> expected, while adding new API requires: >> > > I do think it would be problematic, and a new API is a must (either the > one Nikita asked about or the current one). Let's consider a > reflection-based static analyser: in PHP 8.1, it would report the > incompatible > user-land return types as a very serious issue all of a sudden, while in > fact it's not the case yet. > > (now I see that Nikita answered the same) > > M=C3=A1t=C3=A9 > No, that's not serious: type-checkers operate pre-runtime, so it is good that they proactively report a variance issue when a subtype of an interface is not restrictive on a return types. Compared to the effort to be added to support the new behavior **at runtime**, this is a non-problem. Current static analyzers already report issues like these, and already rely on `ReflectionMethod#isInternal()` to determine if they should care or not about a missing type declaration (hence no need for a new API). Examples: * https://phpstan.org/r/530583f0-fab5-4f46-af6b-332e67b862cf * https://psalm.dev/r/7f987b25a3 In fact, a lot of tooling treats `Reflection*#isInternal()` as a huge red flag that means "here be dragons", which is more than sufficient to move ahead :-) Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --000000000000a3f72305c08d4304--