Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110601 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 65755 invoked from network); 16 Jun 2020 17:10:31 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Jun 2020 17:10:31 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 964541805AE for ; Tue, 16 Jun 2020 08:55:58 -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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) (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 ; Tue, 16 Jun 2020 08:55:57 -0700 (PDT) Received: by mail-qt1-f175.google.com with SMTP id y1so15830598qtv.12 for ; Tue, 16 Jun 2020 08:55:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=wdNufMbz5d4nPmLTDELso/R/JNeehO3sgrIYjR2wtT0=; b=sP/cQbnyKsY/uKesQfZ2snrgOoUPp1Dd2GjZXdjgOIE+umNKDEdGEFXdMbZC20kjlB AXjRznZQNBYrIvAhL2FmWA2sm6qCRbTc9dgdut9Rx3FbVs6ANA7m/jRfYLPSdyFMwsV8 P6vb2jApeDY2ksUlu8Sm06eUpYpKunzYHtnm/0Iq3DJofYGoCI3zRm4pibBvodPpY7dx 7jjkAN0QKN3IkbgAMItrRnjnZYeCwRLg6C2k7F2xqcwhyZuA+5HMIJ7rHqeFcOyYVsYX RPD4+USwBCJT+EiyT8Ks3ikfeoX8+n8oALzH/0CqHigZ9UTuUW7HI/5Xpc25h2jvEhh8 c5mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=wdNufMbz5d4nPmLTDELso/R/JNeehO3sgrIYjR2wtT0=; b=V/imjokUOjPJc+wN1yDBuo2V9hkm/0hOlgOW4QCgfLPss9btoJCcahPK2WSMjIyzWR M+JmQCokVVFOivqrDlFUIshjTKRh1cen9A5PZw49CjJ4VtTsEcHqr/gECYNppKwkCgYT UZWCDGx95iXkN0DDBp9VMLxftz6ydocjrVs7W7koT+V/y5fyJfD8ck1ho8I6BMlAqNxd LYysNF+dDpb2VGWeHtOuo2oLRRAfc8ZzEZxYc+MKxtek9xm0bpyZwPsKh9r43z6koxy2 0Fh38xGZ7nEKxT3tK/fLpbGiBRzckla7NnnFM3QCd8KAobkI329w7lNLoDHye8jp1lB2 Nc+A== X-Gm-Message-State: AOAM533JdvlVq8LlcJIfp0IGhnOEJS/6r8vgZ4tVNOQ58TnlrUIcYjX7 l4QAkdtEguoq6rnJj9FoBCTpZQ== X-Google-Smtp-Source: ABdhPJxxPtyxMeLFSpO86oTrLlmkqSb0FcowCF8r2KhYojim8kgbr3sQfUgRNghyq4IwCMu9QGYHkA== X-Received: by 2002:ac8:6f5c:: with SMTP id n28mr22309484qtv.269.1592322955605; Tue, 16 Jun 2020 08:55:55 -0700 (PDT) Received: from ?IPv6:2601:c0:c680:5cc0:d0e5:8b54:d40:a778? ([2601:c0:c680:5cc0:d0e5:8b54:d40:a778]) by smtp.gmail.com with ESMTPSA id 5sm14890904qkr.9.2020.06.16.08.55.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jun 2020 08:55:53 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) In-Reply-To: Date: Tue, 16 Jun 2020 11:55:52 -0400 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: <6B53DD33-5638-4064-BCEB-7F0B7E2184BA@newclarity.net> References: <9D1E1E08-7DD5-4FD3-B08E-58254CC75FC5@newclarity.net> To: Nikita Popov X-Mailer: Apple Mail (2.3445.104.11) Subject: Re: [PHP-DEV] Remove LSP checks on static methods? From: mike@newclarity.net (Mike Schinkel) > On Jun 16, 2020, at 3:50 AM, Nikita Popov = wrote: >=20 > On Tue, Jun 16, 2020 at 8:59 AM Mike Schinkel = wrote: > Hi internals, >=20 > Given that there appears to be some appetite to reduce checks for = inappropriate signatures[1] I am wondering if anyone has strong opinions = =E2=80=94 pro or con =E2=80=94 on removing checks for static methods? >=20 > My primary use-case where I would like to see checked relaxed is for = static methods used as factory methods[2]. >=20 > Per [3] it seems that all but the least upvoted answer argues that LSP = applies to instances, not static methods.=20 >=20 > Per [4] it seems that all upvoted answers agree that constructors = should not be constrained by LSP, and since a factory method is a form = of a constructor it would seem that if constructors do not require LSP = then factory methods would not either. >=20 > Does anyone see any issues with relaxing these checks for static = methods that would have them downvote an RFC on the topic? >=20 > Hi Mike, >=20 > The problem here is that static methods signatures are subject to LSP = if they are used in conjunction with late static binding (LSB): >=20 > class A { > public static function test() { > static::method(); > // May call A::method(), B::method() or any child. > // Signature must match for this to be sensible! > } > } > class B extends A { > } >=20 > I do agree that the current situation is sub-optimal, because = certainly not all static methods actually are used with LSB. But we do = not presently distinguish these cases. >=20 > If that problem can be addressed in some way, then I agree that = (non-LSB) static methods should be exempt from LSP, just like = constructors are. Thank you for your response Nikita. Much appreciated. Would it be reasonable to consider moving the check for incompatible = signature to the first time a method is called using `static::` rather = than where the method is declared? That would bypass the need for a new = keyword and any confusion and BC a new keyword might create. Also, I think would assume you add need to add a flag to the child = methods when they are declared so as to know if they match their parent = or not? class A { public static function test() { static::method(); // This would work $b =3D B::create(['foo'=3D>'bar']); // This would work $c =3D C::create(123,['foo'=3D>'baz']); // This would work static::create(); // Error could = be throw here? } } class B extends A { public static function method() { } public static function create(array $args) { } } class C extends B { public static function method() { } public static function create(int$id, array $args) { } } -Mike=