Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116836 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 96362 invoked from network); 6 Jan 2022 16:55:29 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Jan 2022 16:55:29 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3D7BA18053A for ; Thu, 6 Jan 2022 10:03:14 -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-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-vk1-f180.google.com (mail-vk1-f180.google.com [209.85.221.180]) (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, 6 Jan 2022 10:03:14 -0800 (PST) Received: by mail-vk1-f180.google.com with SMTP id h67so2205525vkh.1 for ; Thu, 06 Jan 2022 10:03:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=c7a2hYUQL1VmaDujt+jg+L/H8qPU/8WN65K8H+PqCnA=; b=dF8J8hD+dw6tOys8nXyVq3iWYa3DPY85NzePOUJppalJtcCU5EXa7KNuC+TlQLpNbh nT3MO44aCJzyN0+Eo92tgW5BfI5tz0afhIp2cWHm4cA3/eGVtqppvBkHvfDtyV9wJyBS x+vZgWg/83LEehyXja3Usz75pdeHZIX9+BPlqXXL+thggdGV0yTSTbDoX7ary8ZtqYwY 2F6FbChbGYs2aR1rkZxcJU9TzYxBwwaol0GWOY37Wx0JLWFa+QTHAjUJc58qmITgY8Vv +TUyUNuLlJCHxXwoisqC9WJ64dTfgBMtdjJc0C2nDXG2/rE80M/PH0nDhce4J73nJPA5 bLqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=c7a2hYUQL1VmaDujt+jg+L/H8qPU/8WN65K8H+PqCnA=; b=1pkmgYudt5SaZlRo1FeT66R+1TNJJFQYSciSjGP3jFjrONA6dJFpMwaZOCxBhsNw/m SHh/N+yIzoFcvXOpcj+vR6Pg4Sob7Zze+UqOYvLPMb7eb9VHgyGlHlIo4x1VN3kuHBaJ Zih50pbd/cmhqAaEE3ny0zeQFJdP22kK0g1DT3JsiLRYHvUS2ijfAhsa2k3P59NNCt8s w2qQInbXYVFE0MGVCeGLkuzw0IqjuuX+NnPB3Clas+BZSSxptVlJjoJm3gADs9umbCbt O8IwioDUsLmKGrpeiLB3xsl2fDBAFmvyayFsyF8SVFopZAYIu+++gekx2E9jzTvswHpq pv/g== X-Gm-Message-State: AOAM5333F1rbe6hshNJihn5Nj6NJG3CGsOxg01a52LNG22Y23GW8gUK1 Yrste6zAHUy7+c1bsWxLKQDvTIY9dKbXf4qy4BM= X-Google-Smtp-Source: ABdhPJxFozG2ff+EwR12DC/9xOI3dbFHTUZraKKyGeukhETusspPQvaVFgH1O1XEP9Q+g0y7qOmdhG37Sdi/+kSaofg= X-Received: by 2002:ac5:cfc4:: with SMTP id m4mr20629770vkf.30.1641492193367; Thu, 06 Jan 2022 10:03:13 -0800 (PST) MIME-Version: 1.0 References: <1641335738.195767637@f174.i.mail.ru> <5a4aebf8-e592-4517-8930-d18b112ef1fd@www.fastmail.com> <5a99809d-afda-546c-5a11-a4f0f821aa37@korulczyk.pl> In-Reply-To: Date: Thu, 6 Jan 2022 13:03:04 -0500 Message-ID: To: =?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?= Cc: Rowan Tommins , PHP internals Content-Type: multipart/alternative; boundary="000000000000165c7405d4edaf17" Subject: Re: [PHP-DEV] RFC: Trait expects interface From: chasepeeler@gmail.com (Chase Peeler) --000000000000165c7405d4edaf17 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jan 6, 2022 at 12:37 PM Alexandru P=C4=83tr=C4=83nescu wrote: > On Thu, Jan 6, 2022 at 7:12 PM Rowan Tommins > wrote: > > > > > But some comments seem to be hinting at some *separate* advantage, to d= o > > with "correct usage" of the trait, which I haven't grasped. It's possib= le > > that the mention of static analysis relates to that in some way, and I'= m > > just completely missing the point. > > > > Yes, traits are a language construct that has in general more negative > implications than positive so it's good to keep an eye on their usage. > One of the okish usages is to define some implementation for an interface > that classes can use. > Limiting that trait to be used only by classes implementing the interface > is seen as a restriction placed on the trait that would not allow it to b= e > used in other places when it might have a negative impact. > > And that's what I don't like about this. I'm totally OK with allowing developers to do things the "wrong" way. It might end up that it's the "right" way for their use-case. > Just as a note, on the composition vs inheritance line, I see traits > somewhere in the middle. > I'll always prefer to go for full composition, even if that means a bit > more boilerplate. The implementation can very well sit in a class and hav= e > it as a dependency of the class that needs it. > > Alex > > but that wouldn't be any *easier* for the tool, and in fact would be extra logic for them to implement, so it seems an odd thing to bring up. I think most people see the tools as black boxes to make THEIR lives easier. They aren't concerned about whether it's added complexity to the tool itself. If PhpStorm allows me to reference $this->someMethodFromAnInterface() without defining someMethodFromAnInterface() as an abstract method in the trait because I include "expects ", then that means things are "simpler" for me as a developer. I don't really think this makes things that much simpler though. --=20 Chase Peeler chasepeeler@gmail.com --000000000000165c7405d4edaf17--