Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120614 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 33198 invoked from network); 19 Jun 2023 02:53:16 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Jun 2023 02:53:16 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 73D1C180089 for ; Sun, 18 Jun 2023 19:53:15 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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 ; Sun, 18 Jun 2023 19:53:14 -0700 (PDT) Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-3110a5f2832so2876158f8f.1 for ; Sun, 18 Jun 2023 19:53:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datadoghq.com; s=google; t=1687143193; x=1689735193; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=W1kmuZrR79v+D26aq0hIn98C/L32ivd2SKxIKDG64Bg=; b=W7+4o0EVo1L0z3kjHAXnKTSy6LvkV5oWzhryGXFGtltoFhf5ZhTVJRdRdXDTAjYLbl TiB3tmyHC7sDgV3fq6jZFfDzR9elANp6u/sq2+NKIGVgJETX7/E1i7YmHC2ukbjCJZms GSr7hGgPoJnrGeB9WqMGWFaZhrWXJa7C/0SOQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687143193; x=1689735193; h=content-transfer-encoding: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=W1kmuZrR79v+D26aq0hIn98C/L32ivd2SKxIKDG64Bg=; b=ackK3kBsXrbpYWkiXkBG5x+ozcRvT3NBPB3dPJcU4yT5cBmiIIPLSBC00mXECD6RRN qjhJsWM2mbd2WrzvjmhN7ncp58gZt/il8txSt7PzHg0YmZiTe8fbFie6LyB0Iu9hBUbb FYWr5fWrQaXNm3Z/xG6uoe52sfpGOxKhH9AOTZ/poZ0Fuz5NXv/uhIczlIYshJkL0/G0 Gh4cyXbVBr+BQUSMgITGZUp+EzgIzOdej2P/dPa2Md5UPxZtnhwFFnQ8e85TK0W/7fWI dqcaeD+lTwidZGTAsFBffVHTWZaDNTtuN3fGw9AZwh05/jB450ozNW/cwwyIntdhbfId qXag== X-Gm-Message-State: AC+VfDxhZqPXYn0fvROWtIOwM6ARLB4rwSlbzXWQb/pmAXBijz/rS5ir cHy4XinbRqbiSt/750ET0PJwLZF/3CfRhIbs4BE9DQ== X-Google-Smtp-Source: ACHHUZ6HUw8vSFVpHUFWiSNX72EZmimgZFT0uaewoVYd4RfFW80WWA59ty77j0KACXk2hmP5Kq/cIRFGAJ0GVmdE9W4= X-Received: by 2002:a5d:6610:0:b0:30f:c1fa:7901 with SMTP id n16-20020a5d6610000000b0030fc1fa7901mr6600625wru.5.1687143193530; Sun, 18 Jun 2023 19:53:13 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Reply-To: Levi Morrison Date: Sun, 18 Jun 2023 20:53:02 -0600 Message-ID: To: David Gebler Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Interface Default Methods From: internals@lists.php.net ("Levi Morrison via internals") On Sat, Jun 17, 2023 at 4:10=E2=80=AFPM David Gebler wrote: > > On Thu, Jun 15, 2023 at 4:48=E2=80=AFAM Levi Morrison via internals wrote: >> >> >> I am moving my RFC for interface default methods to discussion: >> https://wiki.php.net/rfc/interface-default-methods. >> > > Can I ask, the RFC doesn't say - does your implementation ensure default = implementations can only call other methods which exist on the interface in= the same manner as Java? i.e. the following would give some sort of error? > > interface A { > public function foo(): void { > $this->bar(); > } > } > > class B implements A { > public function bar(): void { > ... > } > } > > But the following would be okay? > > interface A { > public function foo(): void { > $this->bar(); > } > > public function bar(): void; > } > No, there's no attempt to ensure the method body adheres to calling the public interface. Due to PHP's possible dynamic behaviors, I don't think it's reasonable to attempt to enforce it at compile-time. I'm not sure it's worth the effort trying to enforce it at runtime either, but it would be nice to see lints from static analysis tools which detect this issue.