Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126883 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id D8DBD1A00BC for ; Fri, 21 Mar 2025 09:50:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1742550481; bh=BJIn0CTwCMY7QVrDz6Qf01zBEbfgxMgWY7slDt8IIBQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=mNr6cnNp6pqPgS6VfzR5agkx7+SXb0c2vHCwXG8aA+wRUT0ZfkTtjpzDox2NmKQEl FZFAU9q7qxeD4eTt2+XCcB1ndJVOt3muIeM3pY1BEHE0ObyZym54yWwXy8S24VkdLm w9lQfNqs8owzHMgDHuUxrdd1sFV+QyTRnFGREjsmEywopTeeMGNkqJmfgI6+007kuQ wfS+8qAk87SiVUI2JUqlC+as/sfNqvv/c1uuh2VzjOSfeyLjCpnJ9SGt7DGeWhzBHl y56RsmL0jfbM6wxpkfxyvEDl3zWeUIoL4zPdl/KxvTVPBAwmYCsNgXip/7VxgwqC4y JethY6BWO2q5w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 38F7C18005B for ; Fri, 21 Mar 2025 09:48:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-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,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 21 Mar 2025 09:47:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1742550628; bh=N6bwyRjm21On7lUXTgyP89DyrdZa3xZRCnUbuTcq0Fg=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=DetmxgcXYhSpSU32zxC3JmePOQbegTZiCoGJZU+639SsHIUECbbFYg4udVKMR/s/i HVLCADqwFNNUfFdStn75ac0o7ich0P6bU/2f4RBMLfQINOo6QKnctWolyWXOeDFw+N tDBvbqRnLhNRI/BpMuuqAmatY2fTy6OmCPSH8TRd8ZDflkbCmpTs7bl1kezgaCPvuA 4GHKvYEF7JDgYkekbSnp+5pXDb7jdrGV8NARDnnlEFpHd+09dxUl1sQQbRZMbOmMqd v4KEBu+FiCjmfonOGfveAN1KQ5Unpc1CJ9La7nZ/wJRD3Izk7xrhwCfmzCzaRFWL+O 9zphkCkZ/EZfA== Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Fri, 21 Mar 2025 10:50:28 +0100 To: "Gina P. Banyard" Cc: Juris Evertovskis , 'php internals' Subject: Re: [PHP-DEV] [VOTE] Optional Interfaces In-Reply-To: References: <084101db94b8$73da47e0$5b8ed7a0$@glaive.pro> Message-ID: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi Am 2025-03-20 17:09, schrieb Gina P. Banyard: > And another user [2] was basically suggesting my previous solution of > adding support for type classes/runtime implementation of interfaces. > […] > [2] https://www.reddit.com/r/PHP/comments/1jbcbtx/comment/mhvxo5j/ I don't see how this could (usefully) work in PHP, which doesn't scope the methods on a “per interface” basis / which makes methods just some syntactic sugar for a function that takes the object as a parameter. Once you have more than a handful of interfaces on a single object you are bound to have naming / signature conflicts, unless the interfaces use some oddly-specific name for their methods. Two different serialization libraries might want to use `serialize()` for their methods, but using incompatible signatures (e.g. to pass additional options). It works well for Rust, since each trait will need to be imported explicitly for the associated methods to be available. And then you can also call the method as a free-standing function, just passing the appropriate struct as a parameter to disambiguate them. Best regards Tim Düsterhus