Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116651 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 51500 invoked from network); 15 Dec 2021 20:16:40 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Dec 2021 20:16:40 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4ECDA1804F8 for ; Wed, 15 Dec 2021 13:18:57 -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.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS19151 66.111.4.0/24 X-Spam-Virus: No X-Envelope-From: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 15 Dec 2021 13:18:56 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 4B5995C026D for ; Wed, 15 Dec 2021 16:18:56 -0500 (EST) Received: from imap43 ([10.202.2.93]) by compute6.internal (MEProxy); Wed, 15 Dec 2021 16:18:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=M/PJp7 eXKy2ABxp6fsQhB3J70rBeXyfZ4L4G3icergE=; b=DiJmPzZlxBBQ0uTpHS9uM3 0AdkXRysqs2MAS2HTV4cl2zdkzX+kgToAHVRgBeuduLUWBEbUPOTXsHYMC1D2QJz W0yLKVvRkOZmXJqPG7Jad1dq3vItOTbBCaw/atjqQzEtwL7Z2L70tfmSpwEZt4Qr 9FkX0/jrmPrl73TyRg4z9yocRg1YtP2JN+GULPoAHzz5osJnH+bGImDAmTlzaAyf CvKUkDCL7NacwzpDlCOrt+WAIfDFUs2Ca5Q1gzUv14SaXLmQ0anvh/cCXPoB4aZo AwgzuSSqLiSByKMO1cPl6Bn/id7XKQ46zI6vNkOWhcMpNi63yjsrmsfSKqxLpL/w == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrledvgddugeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeeglefgkeduiedvvdetffeujefftdfhjeeiveehgfff keduveektddvledvvdfffeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id B238FAC03DB; Wed, 15 Dec 2021 16:18:55 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-4524-g5e5d2efdba-fm-20211214.001-g5e5d2efd Mime-Version: 1.0 Message-ID: In-Reply-To: <5187537c-2edf-f57d-6030-f969df3b28b5@gmail.com> References: <44b3fb4b-4693-1639-c8c0-5e17296c196e@gmail.com> <5187537c-2edf-f57d-6030-f969df3b28b5@gmail.com> Date: Wed, 15 Dec 2021 15:18:14 -0600 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] User Defined Operator Overloads (v0.6) From: larry@garfieldtech.com ("Larry Garfield") On Wed, Dec 15, 2021, at 10:10 AM, Rowan Tommins wrote: > On 15/12/2021 15:03, Dik Takken wrote: >> $query->where(Price < 100); >> >> Here Price is a class that represents a database column which has a >> (static) overload of the '<' operator. The operator overload yields an >> object representing a database expression, which gets passed to the >> where() method. > > > The biggest problem with this particular example is not the operator > overloading, but the bare word "Price", which is currently a constant > lookup, not a class reference, as in: > > const Price = 50; > var_dump(Price < 100); > > > However, with any version of operator overloading that didn't limit the > return values of the overloaded operator, you could do something like: > > $query->where(Product::$price < 100) > > Where the static property Product::$price is an object which overloads > the "<" operator to return some kind of Condition object which can be > used by the query builder. Cool as that would be, it poses a problem as it would mean the Price object could either be directly compariable, or query-builder-comparable, but not both. There's no way to have multiple <=> overrides in different contexts. Also, for <=> in particular, that one is restricted to only return -1 | 0 | 1 anyway, so it wouldn't be able to return a query builder object. --Larry Garfield