Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113547 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 72635 invoked from network); 15 Mar 2021 18:19:02 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Mar 2021 18:19:02 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5E2D3180087 for ; Mon, 15 Mar 2021 11:12:33 -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-vs1-f52.google.com (mail-vs1-f52.google.com [209.85.217.52]) (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, 15 Mar 2021 11:12:32 -0700 (PDT) Received: by mail-vs1-f52.google.com with SMTP id z65so16798497vsz.12 for ; Mon, 15 Mar 2021 11:12:32 -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=TdBKz1W6ofdgJE4rRPlkGJyZZ7D+pGR7wYqX8mwicyo=; b=JKYXmw+KCESWmj7kbFbKj0g70r/kvZcsosOQBXgOTAakvXN0/KqOG4fHnHjak4rdm9 HvO93wdgDPKfW2dtVlkQMxyocdVJMjv8sVzqa7mxoz/bVXH17AmSBYvY/HNHB0ZwguzN jpW3C1YeGQ3rb6wAJUqh6aPDc/xl/Uh4lNSv3wMoX3b656jasxiscmsqs0siASPrjhT0 tx0rxmG9P4ntrNZLho5yzfzFJVf3nLcNaFzgBQ17amzeTeUqSmEFBFN2vf7ifBKKIaMW 2yz9wQynZOhxPnOhwO2ZP+B75NQg9U7TPhvvpe/xsB7hya95JzmAdvEnf5/unYWq6JHT j2eQ== 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=TdBKz1W6ofdgJE4rRPlkGJyZZ7D+pGR7wYqX8mwicyo=; b=a0xaEw4lfH2uhLEJNdcYg2OxP261fDAPG8OxBLXJnCGZfIBinXJo6OQgd4oQu0/UFT /PL3DmWLZ6f+q/R/yXckROsSAs3n/xCMOxSgHT1lNer+w1g5MTlX+3gRGyIKKd0WLu55 rxK2odhds1N+sMtaGnGSEIAGqnf14EoF2Q1Mfrw9j4s3lXpQoytd7+u+LOHnxLe008Bg oxm+SHzOFfmk8WT7mSJNJ126xmy/EM8PbABTZbaN24TfNYA2+Uh4VlFQslsQ1ekfDbaP L839Rwe61y+payzMd1bmzCv+/9ryhWZNyMN0ovjEIV0ExjzweqfzGu+FUQEbvjA4t4AN elpw== X-Gm-Message-State: AOAM533Hg6h8kZMHVa3I/Al0GtFARRqDuXpR9fgKcElGu1tFJHVlBFyZ NqwHZG+hoTBovKvfkQdG1opKj94rgaoUyWdpAomXaUlkcueBgA== X-Google-Smtp-Source: ABdhPJysGSysBYQSqr3pqT0XhBcwOOwbUWJmGO9wTbnfiFp8xNj8lXaib2fb5aEVGGZ1/tlUs12LTMIWB9TkeQu2QNA= X-Received: by 2002:a67:de87:: with SMTP id r7mr6095962vsk.48.1615831951965; Mon, 15 Mar 2021 11:12:31 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 15 Mar 2021 14:12:20 -0400 Message-ID: To: Nikita Popov Cc: Rowan Tommins , Internals Content-Type: multipart/alternative; boundary="00000000000083800d05bd9731fc" Subject: Re: [PHP-DEV] [RFC Proposal] Allow methods to 'become' static From: matthewmatthew@gmail.com (Matthew Brown) --00000000000083800d05bd9731fc Content-Type: text/plain; charset="UTF-8" On Mon, 15 Mar 2021 at 09:36, Nikita Popov wrote: > I'm not sure I follow your point. The fact that something is compatible, > does not mean that you can just blindly perform a forwarding call. For > example, consider this: > > class A { > public function method(string $x) {} > } > > class B extends A { > public function method(string|int $x) { > parent::method($x); > } > } > > B::method() is compatible with A::method() from a typesystem perspective. > But that doesn't mean that a parent::method() call will work. The above > code is simply an implementation bug in B::method(), but doesn't say > anything fundamental about the compatibility of the signatures. I would > argue that the same holds in your example. > > Disclaimer: I have some serious doubts that allowing non-static->static > changes is worthwhile, I just don't see why it would be outright unsound. > > Regards, > Nikita > Ah OK! When I say "unsound" I mean "the type system implied by PHP's behaviour allows code that a static analysis tool cannot catch". It's trivial for a static analysis tool to find a bug in your example: https://psalm.dev/r/3cd498b539 If PHP changed to allow child methods of instance methods to become static, static analysis tools could follow suit, but that would invite undetectable unsound behaviour. The most well-known example of PHP's existing unsoundness is its treatment of array keys, something that static analysis tools cannot detect: https://psalm.dev/r/4640ef8f22 vs https://3v4l.org/XQTWc --00000000000083800d05bd9731fc--