Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126374 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 8A4741A00BC for ; Tue, 11 Feb 2025 16:33:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1739291416; bh=97SZYh5OAB2wdY9Y8ow5kxFr7Fc5voGdphL6yUQKUCQ=; h=References:In-Reply-To:From:Date:Subject:To:From; b=NWnMtnXpf0ljGXxL/+/X88X2HrXvjrnJQ0GkA0Y18I0Nh7QrBtTyG2Z0d8pnAbvnd ArHK+t9E/PZ2V89/0s9W70Mb1BMaqkfLAp2lCHctg77EeFYZINYRJo5sOSd8YcYwT+ Q+Iukkb9fv/ViicPxF8pWxzD2lcu9r+1HdgrnsrnuRpf0kfvTrdt0952yJ/Nek29Bb bOUFp5o49Lq9ujSh6jeBmkHsaCQjaxR01MhvfVoLwbLDUxWQiZuIliT/q/kf00SMEp XVOrRLOHPHYaRFe6Zh3BnNf5sJV4JVlfLw7Cs8srBy+KREl26ESrZ/R1UBu3jlUb0/ oVDANb0UAL5lA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8BDA7180080 for ; Tue, 11 Feb 2025 16:30:15 +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.0 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) (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 ; Tue, 11 Feb 2025 16:30:15 +0000 (UTC) Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-6e45dbf15c7so16702786d6.2 for ; Tue, 11 Feb 2025 08:32:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739291578; x=1739896378; darn=lists.php.net; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=YNysh0uascoJ6D+6ORS8MweqeN1NpY6G2/r/6C1icG0=; b=CvEefGltuxMwSRuB9zX4rbk/89SVqFE4xha+BUkDQ0MrgJOIV8T2xLUWr2jDP+apFi 63rLLvjasckeEuE7JLZtD3WK5rZpusQ8v05FsuISV0kscMsoJaEqWbd0TR+4TyQhOvID tmsrsdYzpi9IICkXFvllVdVr7tJFRqWN0rNh3F76uBhfvb+XKtrZGOMC08mIw3H0j87t SPZ7Rd+/eY0vP/Io2RXuI1UQ72mu+AoIVGWPZJOSPI0/BliLAvQzgsc2Md2Xwyk+QstF sOg62d5NPGckAm0OJ5Whhr+H7dK+mkPDDkByw89jLeugBEikYiy5i2WpXhtFACp2rHOy WG8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739291578; x=1739896378; h=content-transfer-encoding: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=YNysh0uascoJ6D+6ORS8MweqeN1NpY6G2/r/6C1icG0=; b=wB45rtDHHBNaz6aoQ24m/hbi05Yq0sUvf0iWvs6vhmofyXsDk/4at+JWbqDHHq39kZ KbqmvFg04n4W3bwU0tbExz1jaBR2xMt1CN1bdhulZbe9M7tLLARD5zbn+ac/DiiEZioK GlyirjsFZYarqVzjuoT6NlCtMoLBdhXk97dM0bVwHe2DHDejSvH/yilj8fNXJEUz/PkF nlfTEBIzxOR0PGgq63OOcFaT+whWe9Fuul3VV1oTOVt88d4PYcxaqvo5afgvqr3TQC0q QU+qUmHQtS1TadblEQM2VICb5gUwSyuzjdqMtNMdY87PH1L2jiExhMl714xqPIALc6P4 fKww== X-Gm-Message-State: AOJu0Yw/PMOJ2+9m0YmzgC+uT8RawOgCL7R3fsQqstgGtRwwUZXNsZfF tYjY+x2c2YWBM0StV2Tq4ue1/GJwE+DTQ+TH9bjfY/XTZCE2X1KI9uGfz9wSad9CX6U1FYoAOdr Tm/3sYbbj0YqyPOSe113g6N/+dAbutUDicN/mag== X-Gm-Gg: ASbGncv5fZPmn5eOg3CZZYzpMMNm5iU8DzkjCpWTDOToeMTcTJmWQuahd8fSybQtnFy cSI23UDjuGtvEns6f/ii1OdUHO/w9/Yb5s4KGXvQuakPItZtWohKMyC7YscVdg7SD3tMxjwO8aL rehuf3mE64QxMY2EA3ODTl46pW+GHbXg== X-Google-Smtp-Source: AGHT+IH+mAALDbc00k9lbb9gDyHdliIJGamtWBv6UwamMERtFMIaORwciDgx59JSLAkJ0BZ/G9ypqFtsNKKWKB5Hj2A= X-Received: by 2002:a05:6214:5008:b0:6e4:2f63:ba54 with SMTP id 6a1803df08f44-6e445660a1dmr292412296d6.20.1739291578055; Tue, 11 Feb 2025 08:32:58 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <087a01db596a$e7525660$b5f70320$@glaive.pro> <045501db7b37$e1f15970$a5d40c50$@glaive.pro> In-Reply-To: <045501db7b37$e1f15970$a5d40c50$@glaive.pro> Date: Tue, 11 Feb 2025 17:32:46 +0100 X-Gm-Features: AWEUYZlXce-OhDvxWf4OzTMhTme8eRD7cXX8CTiCzeM1C1qXKHkfirXbPFUwB8c Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] Optional interfaces To: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: tovilo.ilija@gmail.com (Ilija Tovilo) Hi Juris On Sun, Feb 9, 2025 at 10:16=E2=80=AFPM Juris Evertovskis wrote: > > https://wiki.php.net/rfc/optional-interfaces Thanks for your efforts. I've reviewed the patch, it seems there are still a few issues and it would be great if we could solve them before this goes into voting. A few thoughts on the RFC itself: You mention `#[Override]` in the RFC and how it will work on optional interfaces that are available at runtime (the `TestClass::method()` example). Given the interface is implemented as optional, it is to be expected that the interface will go away under certain configurations. This will break, because the method is no longer overridden. Hence, it might be best to also disallow `#[Override]` on optional interface methods, to signal the breaking for the missing interface scenario. > A class only conforms to types that are actually implemented. Just as a note, this also has some semantic implications. Notably `$object instanceof OptionalInterface` will evaluate to `false` without errors when the interface goes missing. To catch this issue with static analysis, the project will need to be analysed without the interface being available, or they will need to gain new rules that catch such expressions that can lead to inconsistent results. Also, when I read the subject "optional interfaces", what came to mind was "an interface that may or may not be implemented", i.e. similar to Objective-C's optional protocol methods [1]. I'm not sure if the naming can be improved. Overall, I'm not particularly convinced this is a big problem that needs solving, but I'll leave that up to framework designers to decide. Ilija [1] https://developer.apple.com/library/archive/documentation/Cocoa/Concept= ual/ProgrammingWithObjectiveC/WorkingwithProtocols/WorkingwithProtocols.htm= l#//apple_ref/doc/uid/TP40011210-CH11-SW6