Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119592 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 68793 invoked from network); 21 Feb 2023 19:04:16 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 21 Feb 2023 19:04:16 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8DF0B18005D for ; Tue, 21 Feb 2023 11:04:15 -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, T_SCC_BODY_TEXT_LINE 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-vs1-f49.google.com (mail-vs1-f49.google.com [209.85.217.49]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 21 Feb 2023 11:04:15 -0800 (PST) Received: by mail-vs1-f49.google.com with SMTP id x14so5706622vso.9 for ; Tue, 21 Feb 2023 11:04:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=2t8B+DM+pHSrlyfe5SZy093esQgCBeOjV1thQbGUHpI=; b=KLHSQUK/AoWJvVciQ63Wphil1XaMFb+fe/7slB38juDOxvaFNuMLjOwIHQRqEmU0dt TOXw55A5S3gwxteeiyxP2TtT8Nkv1tvUNmpGkDp9aH+bdint/rpS4cnBiF9gzsrMB4hY qb5t/IOLyEqjs/DASKDqIUCVdE+5e0nRamIZv60jaEOwWD2iLdY0Tl6O14YufAr1otnQ 3p/ApPKd17ja/9rgoSX+gcXkKFI4lzIux48jN8c9O4UPdmaqRBxSBh2BKLtSMc01xdh0 pVzTfCLvHTXrygiwIWa5sn1UVoVT9xVh+lIKzA+UvozBptgHMaF2jKGW8qSH8iw5jNfq 9pCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2t8B+DM+pHSrlyfe5SZy093esQgCBeOjV1thQbGUHpI=; b=3yTczIWeWJ54hE2KGoygDlDKVUJfvh3Wxao0va9hGWuj8Q8awtejdDMPge4wbXtA8D remCcLoJooBqi6HSXakIT55iHGN5pbGWP75BrsvkugZLIaIXE1aaoxjnjc076fXKudwL o0+99/C8tqAdY94zM6MADkcnh9llitK4/unQGEH+06sS4eGCDyqIMrFfE60tv29t8gJd NpWHu4PUqrRR6p2jlWLsWHbg3DYY6UGwHvDbY/GJ5o3ASNt1BvRJrZVtfgX6MZJYxwkz 4vgjeNspy96F+8MgsQOrOp5XeesdUqGCTl+tzdASiK8bdscb1Jy0mmFO5OlKXjYT7chZ Aejg== X-Gm-Message-State: AO0yUKUTlRrzU03FoESC2FiF3ua6xIU5FNdQUr5cq0Tbxu5vATjxYCmj lYyTxCbaZf3dzTMy7aavHIq/sjX5+GxKy/r7pHY= X-Google-Smtp-Source: AK7set8N32SyBlq88f6aMm3oaGXdI/TFGXQzhNBdb5/c9hfAK3A1q9CKH7UFIIvhFAXcnNWmfBq0P9myScfUgkl+uS8= X-Received: by 2002:a05:6102:c87:b0:415:1ced:3c10 with SMTP id f7-20020a0561020c8700b004151ced3c10mr1242113vst.73.1677006254322; Tue, 21 Feb 2023 11:04:14 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 21 Feb 2023 21:04:03 +0200 Message-ID: To: =?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?= Cc: php internals Content-Type: multipart/alternative; boundary="00000000000013385005f53a722e" Subject: Re: [PHP-DEV] Class Re-implementation Mechanism From: someniatko@gmail.com (someniatko) --00000000000013385005f53a722e Content-Type: text/plain; charset="UTF-8" > > >> So it's mostly a syntactic sugar that allows defining an interface for > the current class that is already implemented by the current class. > Yeah, while answering to you, I've actually came to the same conclusion. > > The interface name is the same as the class name and based on the context, > you either use one or the other. > I think we should distinguish this thing from an interface though. There are some places where this could get in conflict like (new > ReflectionClass(A::class))->isInterface(). But also internally things might > be difficult to sort out to know what to use one or the other. > Yeah, I also thought about reflection, exactly about this method. I believe it's better not to lie, and make isInterface() return false. However, another method should be added, e.g. isClassInterface() - which will return true only in case of `class interface`, or, maybe a more general one like isImplementable(), which will also return true for interfaces. > To have a perfect syntax-sugar, why not also allow the interface name to > be specified? > Something like: > final class interface(ServiceInterface) Service { > public function method1() {} > protected function method2() {} > } > > that would generate: > interface ServiceInterface { > public function method1(); > } > final class Service implements ServiceInterface { > public function method1() {} > protected function method2() {} > } > Well that goes against my initial concern of not introducing additional entities to the system. However it indeed reduces the amount of code to write and is more "transparent" type of syntaxic sugar, like the promoted properties in constructors - this feature also translates to PHP code. If my suggestion ever becomes an RFC, this way of implementing it may become a separate vote I suppose. Regards, Illia / someniatko --00000000000013385005f53a722e--