Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116819 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 79170 invoked from network); 5 Jan 2022 18:09:41 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Jan 2022 18:09:41 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D4C271804F8 for ; Wed, 5 Jan 2022 11:17:12 -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=-0.2 required=5.0 tests=BAYES_40,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-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (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 ; Wed, 5 Jan 2022 11:17:12 -0800 (PST) Received: by mail-ed1-f41.google.com with SMTP id w16so352909edc.11 for ; Wed, 05 Jan 2022 11:17:12 -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=6Fh9NWhfmRZDh7olLoQ0Vyj2WqcvrBO0Pr5DiQoF5As=; b=ia2XxeocAadSs+f3Hzsd4krpJjoKUPhTUnrz5tYA7OyvuzS8zlsEQ1KFBdaLyHtO/q QZU1bvs1DkL1hlJN7yrRS2wGAwbYRSHattAzeh6H9xziNlISGMiiSeElQuw5RkrOuRQQ docB9aJVQAMEoZtPtPF6IfUHPQzjnEu9vA1pFGsfXvyuOotIA2sqPI/KcvdQ7sduw8eZ JQ6CWz49ipeIrHRqCvK4u2pBNRnD8BEX3M5d1JfdW2cMTP5FFsz+SfAbKxyl0AOuq9gZ eLcQbrn5YoZwGDKzHQeGbpNkJHgung8zGeXmVILJPNWZrTRl5CHxpR5/Y8L9Y2udycnv cV6w== 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=6Fh9NWhfmRZDh7olLoQ0Vyj2WqcvrBO0Pr5DiQoF5As=; b=oMo+zLoTjJxFoLmGiwDkVoWCj7w1LGx0UwTYGj+IHU+d8grUed3YW7yDT7wLaVNQVV 5J+8wJHiS2Gy/GHiCYG0jDuBX0Bfnvx7OYv3vuxG4Wt1NKa8thQdwLxkYYwSdDsHUuzm jDQ4qP52MobZvRIXvHmWm96dUs9YEA0yuYG7HUjB7gKSFgO7HuZEuFdi8LKcS8uYhj5P z2stlQ0dLAdBeemHydQAz5XNZaLkk+mrIfeCT0zE1LeVCplZJjKsVxWnkNiCmcQfv03J gjVl64pQr9rT9kdPCq91HV39jMAMYGM1EoECVvLllhwpL03mY2tiCDY77DVc4dOAVwIs ClCg== X-Gm-Message-State: AOAM532veMgn4su7MYGIbgMzCEyyQZy8E2Im69ebqTQUaPQIgMkZRCGT Lm2qJb4QJfATTpgJeZITWi3KuM5SbYIVLc1z4OM= X-Google-Smtp-Source: ABdhPJwwanLMbm/6j0ZTe2nRepP2lzuptWX+KsEEKLZ1o4pnGzCTtxCDQX8bvmEqH+7nds6zUoE8fOAxiuBPYV3F0Go= X-Received: by 2002:a05:6402:2882:: with SMTP id eg2mr54917952edb.406.1641410231073; Wed, 05 Jan 2022 11:17:11 -0800 (PST) MIME-Version: 1.0 References: <1641335738.195767637@f174.i.mail.ru> In-Reply-To: <1641335738.195767637@f174.i.mail.ru> Date: Wed, 5 Jan 2022 19:16:58 +0000 Message-ID: To: Kirill Nesmeyanov Cc: internals Content-Type: multipart/alternative; boundary="000000000000c0fc8b05d4da9907" Subject: Re: [PHP-DEV] RFC: Trait expects interface From: davidgebler@gmail.com (David Gebler) --000000000000c0fc8b05d4da9907 Content-Type: text/plain; charset="UTF-8" On Tue, Jan 4, 2022 at 10:35 PM Kirill Nesmeyanov wrote: > How relevant do you think this idea/proposal is? And what possible > problems or solutions will this entail in the future? > I'm not convinced there's a reasonable need for it. The very nature of finding yourself in a situation where you want any class using a trait to also require other things outside the trait kind of suggests you really want to be using interfaces or abstract classes anyway. There is a similar concept for what I think you're trying to achieve in Java, though, which could also be useful in PHP if it was feasible within the engine - the ability to provide a default method implementation on interfaces themselves. Short of that, we can already effectively get there with the tools we have; an abstract class can use a trait and define abstract or concrete methods, and in doing so can implement one or more interfaces. Obviously traits can also declare abstract methods but I assume it's the identity/type aspect of an interface you want here which isn't satisfied by that approach. Also worth noting, although I can't say I'm familiar with the mechanics of traits in PHP's implementation, my understanding has always been that they're effectively compiler-level copy and paste in to a class so I'm not sure what interfaces are implemented by the class (or conversely allowing a trait to implement an interface) would be readily achievable. That's my two cents, good luck with whatever you're trying to do anyway. - David > -- > Kirill Nesmeyanov --000000000000c0fc8b05d4da9907--