Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:126756
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 3D9041A00BC
	for <internals@lists.php.net>; Fri, 14 Mar 2025 16:57:21 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail;
	t=1741971288; bh=ccrnqS/TVw0qchCt8SCrEgYhaiwOe1Bzfokop31MLKo=;
	h=Date:From:To:Cc:Subject:In-Reply-To:References:From;
	b=YIwb08Y/c51XgTD3HCgya2BfVKgRikW7X80PFlDZ+PQiMMSQiyVOPev+aIC5NdbKS
	 UMQb8bV+h7pAkOjNDmBi5yVOH8n28CwjzC67XIkGPnzCC5aRHvfY196J2PP9/Be+D7
	 KGp7Nl2xJaRmtsQ1FNBr2unQZLzF0dcmkM7dnGRNTOBWca/n2xpKcGw4oWBr1fNsyx
	 MnKcVqYdrIEUqQnV9Yk4GEvapSOxxf3cvvEyhH3gv0cIPEUSOw3fcCRnTX68OPe15F
	 dAidmQz36BqsLA0wo02cdtSDKCGEJX+7ztte4Lbm3kx/PyolDzwz71e3eHKW0471r4
	 eewLX8nRB4feA==
Received: from php-smtp4.php.net (localhost [127.0.0.1])
	by php-smtp4.php.net (Postfix) with ESMTP id CDAB9180066
	for <internals@lists.php.net>; Fri, 14 Mar 2025 16:54:46 +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=ARC_SIGNED,ARC_VALID,BAYES_00,
	DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,
	HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,
	SPF_HELO_NONE,SPF_PASS,T_PDS_PRO_TLD autolearn=no autolearn_force=no
	version=4.0.0
X-Spam-Virus: No
X-Envelope-From: <juris@glaive.pro>
Received: from cyan.elm.relay.mailchannels.net (cyan.elm.relay.mailchannels.net [23.83.212.47])
	(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 <internals@lists.php.net>; Fri, 14 Mar 2025 16:54:46 +0000 (UTC)
X-Sender-Id: yszpovajlk|x-authuser|juris@glaive.pro
Received: from relay.mailchannels.net (localhost [127.0.0.1])
	by relay.mailchannels.net (Postfix) with ESMTP id 5BD7B83950;
	Fri, 14 Mar 2025 16:57:18 +0000 (UTC)
Received: from server42.areait.lv (100-108-253-94.trex-nlb.outbound.svc.cluster.local [100.108.253.94])
	(Authenticated sender: yszpovajlk)
	by relay.mailchannels.net (Postfix) with ESMTPA id 7EC0C82895;
	Fri, 14 Mar 2025 16:57:17 +0000 (UTC)
ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1741971438; a=rsa-sha256;
	cv=none;
	b=+Sz6kVGGDfGthE3TzbgFIAQakla5IyBLQ9YtpE7IzWF4jzNCK2BKw1yJ6uAxZHXepF97nY
	RafUYEFitZGKHfngK6Ir7DI8vw+VbVQcoMdQQoc1ZYUgLfcR9QaRsxQyKIll0Zuh8OuxBp
	Ku6LpF9/pJWX6JyreZQ9WH/mC3eBpUbjRGtz+zUwyrqyKGrcnLTJB0X9ACyNzAX6J+cx3c
	niX4LwAz9EriwaVWCN9hnWmlwuYI07+pmSJ+9uAHKxE961tj57vuBTKCyjj+3CkFI2iy3r
	unO+kfkg8b4Ef8y8qMZ7etLL6AeDln18iRNwnAcewTNnJ/oXOMwLwqqOX+4Mrg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
 d=mailchannels.net;
	s=arc-2022; t=1741971438;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references:dkim-signature;
	bh=UwsrjV9f2u//aeRTKcOMUHT2LLTfeRpoELAtbH8y3QI=;
	b=iKf8N9xkZH51yHrlRCDK3qkY9mX9rWXQqhSpc5Kx7seEWC7PAWSqmSij/Ra2NYal0w65tx
	9p7bPPKo64vHUGrPxJkbIyNl+aeIUcIeI79qydSEGYUtuFUEHCQjTP4FhH0ppBIK10icnW
	x4mzwOR7Z1JCS47sHwFGxKwSbaMkcriopEA1oaLv12clowjO6W7J/RWXR58G3dz/uaby3d
	R6GXiGN2bV36r1P7jZs04rZZRmvG3L8loHfp6mdlpw4Nnk/+zf+3V6zPpH4pZMUuJbwdtY
	HT7IFhwWMwNLPctuVwB1ie2/iG+QC68/zZ7OJ6jhzaIl/99KUmA2bnQfprHc/Q==
ARC-Authentication-Results: i=1;
	rspamd-5f7c79bbc7-tpbbn;
	auth=pass smtp.auth=yszpovajlk smtp.mailfrom=juris@glaive.pro
X-Sender-Id: yszpovajlk|x-authuser|juris@glaive.pro
X-MC-Relay: Neutral
X-MailChannels-SenderId: yszpovajlk|x-authuser|juris@glaive.pro
X-MailChannels-Auth-Id: yszpovajlk
X-Irritate-Whimsical: 1ac776a2367622d4_1741971438222_2981267444
X-MC-Loop-Signature: 1741971438222:1716302867
X-MC-Ingress-Time: 1741971438222
Received: from server42.areait.lv (server42.areait.lv [212.7.207.88])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384)
	by 100.108.253.94 (trex/7.0.2);
	Fri, 14 Mar 2025 16:57:18 +0000
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=glaive.pro;
	s=default; h=Content-Type:Message-ID:References:In-Reply-To:Subject:Cc:To:
	From:Date:MIME-Version:Sender:Reply-To:Content-Transfer-Encoding:Content-ID:
	Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
	:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
	List-Post:List-Owner:List-Archive;
	bh=UwsrjV9f2u//aeRTKcOMUHT2LLTfeRpoELAtbH8y3QI=; b=ajgjg1wwh1M1n6tGM5N0Pp/Ose
	0Vprvl9EwzFSs+0o8VsWA2SGkCD04fPVDA/7CeI4Rfq98yjWbFGqiLl0R5NtMqnTZCcDflPjw49uH
	nIp3raUTon54FVfKS5c9DE9JN+HV+QD06he98nrVuN7U1Ax+wLkbjSwA8KlGLMfAAPrpwDtBa4YFQ
	+g5wLjpBW9+ss0doSLqn2m4RvAax1aoNhnOpixupbPs4pabOcgyhWbyi0uYfN3PiPCD/9llP6Twi0
	0XzkMbbvLxmbQ7HkhPzqr6HqkSegxXOneZbsJyeTbZen7ixvAkT/ulhzGSBoXianV93rWUqFeUcfv
	AgWfPZ2g==;
Received: from [::1] (port=46860 helo=glaive.pro)
	by server42.areait.lv with esmtpa (Exim 4.96.2)
	(envelope-from <juris@glaive.pro>)
	id 1tt8LS-007N14-2L;
	Fri, 14 Mar 2025 18:57:15 +0200
Precedence: bulk
list-help: <mailto:internals+help@lists.php.net
list-unsubscribe: <mailto:internals+unsubscribe@lists.php.net>
list-post: <mailto:internals@lists.php.net>
List-Id: internals.lists.php.net
x-ms-reactions: disallow
MIME-Version: 1.0
Date: Fri, 14 Mar 2025 18:57:14 +0200
To: Jorg Sowa <jorg.sowa@gmail.com>
Cc: php internals <internals@lists.php.net>
Subject: Re: [PHP-DEV] [RFC] [Discussion] Optional interfaces
In-Reply-To: <CAPTD5yE0aDgLuoB6fCQawrz9syWfGqFfq6_8taPCEUB5252oeQ@mail.gmail.com>
References: <087a01db596a$e7525660$b5f70320$@glaive.pro>
 <CAPTD5yE0aDgLuoB6fCQawrz9syWfGqFfq6_8taPCEUB5252oeQ@mail.gmail.com>
User-Agent: Roundcube Webmail/1.4.8
Message-ID: <2f1223116bd43e9fa985aac94971cbc7@glaive.pro>
X-Sender: juris@glaive.pro
Organization: SIA "Glaive.pro"
Content-Type: multipart/alternative;
 boundary="=_89e341220e217d95d331ad667a499093"
X-AuthUser: juris@glaive.pro
From: juris@glaive.pro (Juris Evertovskis)

--=_89e341220e217d95d331ad667a499093
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII;
 format=flowed

On 2025-03-14 16:04, Jorg Sowa wrote:

> Hello Juris, There is some uncertainty for me on how this approach 
> would work with namespaces.
> 
> Let's get this example:
> https://3v4l.org/bI1Rj
> 
> I would expect to get the error message that I forgot to insert `use 
> Stringable;`.
> But with your idea everything is fine. I don't like such ambiguity and 
> I worry it may bring some confusion to developers.
> 
> Kind regards, Jorg

Hi Jorg,

You are correct. We can't really distinguish whether an interface is 
absent because the dependency is absent or because the name was 
mistyped.

In practice I would not expect this to be a big issue. Adding a 
?OptionalInterface would be a deliberate action when your objects needs 
to pass a specific type check. In case of a typo the type check will 
fail and the object will be rejected by the consumer.

I admit that it's not as nice as a compile-time error, but my point is 
that the typo would still be easy to notice as it would break the whole 
purpose of that interface implementation.

BR,
Juris
--=_89e341220e217d95d331ad667a499093
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; charset=
=3DUTF-8" /></head><body style=3D'font-size: 10pt; font-family: Verdana,Gen=
eva,sans-serif'>
<p id=3D"reply-intro">On 2025-03-14 16:04, Jorg Sowa wrote:</p>
<blockquote type=3D"cite" style=3D"padding: 0 0.4em; border-left: #1010ff 2=
px solid; margin: 0">
<div id=3D"replybody1">
<div dir=3D"ltr">
<div>
<div>
<div>
<div>
<div>Hello Juris,</div>
There is some uncertainty for me on how this approach would work with names=
paces.<br /><br /></div>
Let's get this example:<br /><a href=3D"https://3v4l.org/bI1Rj" target=3D"_=
blank" rel=3D"noopener noreferrer">https://3v4l.org/bI1Rj</a><br /><br /></=
div>
I would expect to get the error message that I forgot to insert `use String=
able;`. <br />But with your idea everything is fine. I don't like such ambi=
guity and I worry it may bring some confusion to developers.<br /><br /></d=
iv>
Kind regards,</div>
Jorg</div>
</div>
</blockquote>
<p>Hi Jorg,</p>
<p>You are correct. We can't really distinguish whether an interface is abs=
ent because the dependency is absent or because the name was mistyped.</p>
<p>In practice I would not expect this to be a big issue. Adding a ?Optiona=
lInterface would be a deliberate action when your objects needs to pass a s=
pecific type check. In case of a typo the type check will fail and the obje=
ct will be rejected by the consumer.</p>
<p>I admit that it's not as nice as a compile-time error, but my point is t=
hat the typo would still be easy to notice as it would break the whole purp=
ose of that interface implementation.</p>
<p>BR,<br />Juris</p>

</body></html>

--=_89e341220e217d95d331ad667a499093--