Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125295 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 328141A00BD for ; Mon, 26 Aug 2024 22:06:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724710127; bh=5t4qc/ri+RakwAbcy306lWDvp2U74HNG7SvF6wZBg7k=; h=Date:From:To:Subject:In-Reply-To:References:From; b=k+nq3bzaXxvSL5FQIoRMiOGoIFgFjR6pVeEzfRH5nXjjVjhiZ5UqQtHy/uVY1lchi kW4mp8ZZv4PwGy+e9ITCKGELljzA9Bd9MkNAej3dEUDo45G0JsW/6WlrQUThPlFDl7 xq7zQz/jjdv8/3BTx+ijCryR1SUuLa+Qfz/XeInEypx8ewT/RU8AlDXQihbUaa4EQh gTdkB9tzoC7Ri0aH3FmNyxWWURuUgiGQqZ58tlrDJ2OLrWBuMkAdn9NuvySBVuk9Rk 7IIv4S1Vd593S+EVkgrFyp2L8ynrRdsrtgdNjDjbPol+kZqlrDleAG6A64y8xEQmB0 dhDwns3qUYYLw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C8825180032 for ; Mon, 26 Aug 2024 22:08: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=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh7-smtp.messagingengine.com (fhigh7-smtp.messagingengine.com [103.168.172.158]) (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 ; Mon, 26 Aug 2024 22:08:46 +0000 (UTC) Received: from phl-compute-08.internal (phl-compute-08.nyi.internal [10.202.2.48]) by mailfhigh.nyi.internal (Postfix) with ESMTP id F33901151C17 for ; Mon, 26 Aug 2024 18:06:52 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-08.internal (MEProxy); Mon, 26 Aug 2024 18:06:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1724710012; x=1724796412; bh=37MyulAW/EXBjNaiuU+KHfsk44jAdPWkCfu+qkCukTY=; b= Wq0JsELoFuZDmrmuqFTILHF9xAZP6Szekr3uQuNs1W2UyCd9aoNgsbFlnRoeqhSE qARaD3zO2KF5bVQmWx6rAPJE3o5pF2ba2nqIuAKmJ7JFHc1b5S2CGEXTMVzGhDbo uIEkkyTVMR3ZrVlafBtLQnd6J9vm1twQRCIF/AL0s2rXYDiYtx5gz8TVR8S2C+h2 QXMC62KuHGT5CeAgG43etkQov9G/cPUzZP6V+eQ9dy1F8QH/qXwWpVBZ9kY5qLTc DXOAvyWhh10nSCfmvNdn/QTbk1VyvLxsxLvHPaPsb+XVrlyMe/jF2cWcxHSzV7rq OS+LLyVgAVQ3o6Xf9TGjYw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1724710012; x= 1724796412; bh=37MyulAW/EXBjNaiuU+KHfsk44jAdPWkCfu+qkCukTY=; b=V cy3qpwtln4pnJJoe6DAN21kZf+Tf1/uGoT/ct84REhNt7NNYOh/YLJI+OZmvOdE5 AJ1tZiMFZiTzF1P/ZhLoZ74bEyR8l6l6x7WfVxaTrAuY+DUBdnKjrP6F7W8LktWo nSyt8JNt7UksfYyMDNJovQMfexrUQYpry85hSz4xInpyahG+KmMJ1I4fH2fOqLqK mmYrHiOeWzA2MR0LOtNkleoxJAtxqKzJHtOHpUJVhvwF56y3y6nGEad2Dr5QA9nj S1nMIRMXrVyy1mCmtkslj5VeVGxcFat5mA1LM/6kkmhSzYrPew2chjQHkhyfTzOG C/DsiJe0+Ss/PxgDPf0NA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddvledgtdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf gfjghfkfggtgfgsehtqhhmtddtreejnecuhfhrohhmpedftfhofigrnhcuvfhomhhmihhn shculgfkoffuohfrngdfuceoihhmshhophdrphhhphesrhifvggtrdgtohdruhhkqeenuc ggtffrrghtthgvrhhnpeeffeegleehffevgeelvdethefhffekhfeihfevgfeiiedutddv leekfedutdfgleenucffohhmrghinhepvgigthgvrhhnrghlshdrihhonecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihhmshhophdrphhhphes rhifvggtrdgtohdruhhkpdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhuth dprhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Mon, 26 Aug 2024 18:06:52 -0400 (EDT) Date: Mon, 26 Aug 2024 23:06:49 +0100 To: internals@lists.php.net Subject: Re: [PHP-DEV] [RFC] Default expression User-Agent: K-9 Mail for Android In-Reply-To: References: Message-ID: Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 26 August 2024 22:27:55 BST, Matthew Weier O'Phinney wrote: >How exactly is this worrisome? Consider this: > > class A { > public function __construct(private LogInterface $logger =3D new >DefaultLogger()) { } > } > > class ProxiedLogger implements LogInterface { =2E=2E=2E } > > $a =3D new A(new ProxyLogger(default)); > >If class A is programming to the `LogInterface` contract, the fact that i= t >gets a proxied version of the default should not matter in the least=2E B= eing >able to proxy like this means that a _consumer_ of class A does not need = to >know or care what the default implementation is; they can assume it follo= ws >the same contract, and proxy to it regardless=2E The upstream developer >doesn't need to care, because they are programming to the interface, not >the implementation=2E This doesn't violate the separation of concerns >principle, nor covariance=2E On a technicality, it doesn't violate any variance rules, because PHP does= n't treat constructors as substitutable; although rules of API stability be= tween versions generally do=2E For any other method, it would violate variance principles because they gu= arantee that the method accepts *at least* LogInterface, not *exactly* LogI= nterface=2E A child class can change the parameter type to any superset - a= parent interface, a nullable type, a union, or mixed - and choose a defaul= t to match=2E As Bruce Weirdan astutely pointed out [https://externals=2Eio/message/1251= 83#125274] the caller is treating the default value as though it's an *outp= ut*, which would need to be *covariant* (allows narrowing), but it's actual= ly an *input* so is *contravariant* (allows widening)=2E If we state that default values, or their types, can reliably be inspected= and used by callers in this way, we would logically need to declare any op= tional parameter *invariant* (must match exactly in all child classes), whi= ch would be a huge loss of functionality=2E Regards, Rowan Tommins [IMSoP]