Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115747 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 22288 invoked from network); 16 Aug 2021 01:58:03 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Aug 2021 01:58:03 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6CE191804B4 for ; Sun, 15 Aug 2021 19:29:52 -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,HTML_MESSAGE,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-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (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 ; Sun, 15 Aug 2021 19:29:52 -0700 (PDT) Received: by mail-qk1-f173.google.com with SMTP id p22so16435568qki.10 for ; Sun, 15 Aug 2021 19:29:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=I47PLJpNQD1MBB4o6yl7C2nWFuQQmRnmi/x/JPEbH+U=; b=vHfstrqSbLa8hIzPicnz9pOCVVCr3TXuog2sZaXJWxVFt2OoRHYwjFfl+KgWdWFzcP GBwppXmGhKXc+5ZEamA1nzBIudAgJvZbJObCe8bLoPdTv2jGnpZXy7jjcU5IcYgvEKiv he3MvbG4X1nB6hI6C4xEEntJxnaFalq2kv9DO+5WYIhEOWPDWR68K4diRO95TXXZpRp4 j8ugWWfOVgUIWK0OVp4gExYr0XSiYroUNKkACvYbJ/U3L1zFx+bD3bFLB1PXVURyo0R7 65xYr+f/h6lp8Q8EFThIFeMIKQXOEmyF2WjMF34fWa2peFPpHyqqg6PbI+ohmJ4Q7LxK MQug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=I47PLJpNQD1MBB4o6yl7C2nWFuQQmRnmi/x/JPEbH+U=; b=Vq5f8CxomYPyKe0LaUINVH7Uo66cPj4h0LVrxr1d1If7EewXsm9DZWpd73xV6hZ7hW DwaSHwyQsmD6h9MOEF+9T+8UAAYktyKQO5AMC0EhjWD9ztsjxeh8lx3HAT4hosEFjbVL L66OvXJdtIT+p9Xjdqhm8bxjTXLRh20JVxciKoQoFZExgWvdePIaihrjSg184GuNxAYG 7injkOdRlyz+S821y/o7tMaTHjPq+IhBwFi9/9Tp09SJFJQ1WnIc7OpNior32BhWY+tW 1VWsKy0S728pERi3U6o3gPFHtogWHXsshBs1ffLdQby7isu26rO+dJZVrHN8LzjvxN8b mqXA== X-Gm-Message-State: AOAM531CRDAPHOOb99EmslHvCZOfSdPW1vI/eXn5YWggrBMj4YYwf+fx Lt34dNdDE7+PQapgj3GhNDhh+w== X-Google-Smtp-Source: ABdhPJy+SfFDMWFdFWVfvMZxeli3Wr+o3XPpVRWS7tw4bZAXjZE0HE5KrUdCeZ0ZTk/jCWa4pLgoAg== X-Received: by 2002:ae9:dc83:: with SMTP id q125mr14009436qkf.284.1629080990510; Sun, 15 Aug 2021 19:29:50 -0700 (PDT) Received: from [192.168.1.10] (c-24-98-254-8.hsd1.ga.comcast.net. [24.98.254.8]) by smtp.gmail.com with ESMTPSA id i10sm5421672qkl.51.2021.08.15.19.29.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Aug 2021 19:29:49 -0700 (PDT) Message-ID: <556F04FF-B1FE-4BBE-877E-7C52D5EB6A35@newclarity.net> Content-Type: multipart/alternative; boundary="Apple-Mail=_CE3B5758-CB90-4775-817B-3E7DD518529E" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Date: Sun, 15 Aug 2021 22:29:47 -0400 In-Reply-To: Cc: PHP internals To: =?utf-8?Q?Alexandru_P=C4=83tr=C4=83nescu?= , Jordan LeDoux References: X-Mailer: Apple Mail (2.3608.120.23.2.7) Subject: Re: [PHP-DEV] [RFC] Never For Argument Types From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_CE3B5758-CB90-4775-817B-3E7DD518529E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Aug 15, 2021, at 7:06 PM, Alexandru P=C4=83tr=C4=83nescu = wrote: >=20 > If I see an interface that was created just so it can be implemented = by > multiple classes but the caller doesn't use the interface but it uses = the > actual classes, I call it out as that is the wrong abstraction and the > interface should just be removed. >=20 > Your example with ArrayAccess is similar with this; when using it, you = know > exactly what implementation you have. The interface is not helping = here > related to polymorphism but it is actually required to allow a = language > construct related to the engine itself, to translate accessing an = object > with the same syntax as for an array. >=20 > If the 4 functions would have been magic methods, without an = interface, you > would not have this problem. That is very insightful.=20 It seems that back when PHP only had a hammer, PHP used a hammer. But = now that PHP has a better tool for the job maybe PHP should change = course? More specifically, since ArrayAccess is primarily being used as a class = annotation and not to enable polymorphism maybe the best course of = action would be to deprecate having `ArrayAccess` the interface being an = annotation and to instead having `#[ArrayAccess]` the attribute tell PHP = to allow indexing instances of the class like an array? > On Aug 15, 2021, at 6:22 AM, Jordan LeDoux = wrote: >=20 > 2. Interfaces have more purposes than just standing in for classes in = a > type hint. Interfaces also guarantee an implementation. Correct. Which is why interfaces that allow for non-specific types =E2=80= =94 e.g. `mixed` or `never` =E2=80=94 weaken that guarantee[1]. If `never`-parameter interfaces were to exist then code that passes a = parameter to a `never`-parameter method would first have to check via = reflection if the type if wants to pass will be accepted. That nullifies = the guarantees of an interface. I think the reason for envisioning `never` as an option to address the = concerns it attempts to address is the unfortunately ramification of, as = Alex identified, the choice to use an interface as a signal to provide = language specific behavior to a class rather than to enforce polymorphic = behavior.=20 So rather than double down on features based on leaky abstractions = better to backtrack and correct the original sin IMO. -Mike --Apple-Mail=_CE3B5758-CB90-4775-817B-3E7DD518529E--