Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129526 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 lists.php.net (Postfix) with ESMTPS id 838E71A00BC for ; Wed, 3 Dec 2025 15:57:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1764777438; bh=i6CizyQ4ZLvvbJibEBslcldvXY+p+A0TjTbVK2LhwUk=; h=Date:From:To:In-Reply-To:References:Subject:From; b=RyJuD0fSpd9Ldcckya5FS1u1BKhKV0uCdv5iEFnn3CjB4UgOBTOS5c0mkoWO8td9Y hoq7IkD44MinKvqNWGnVUfNdG9Mftr91MniW97+KD+HExY+udGDGl6IJ3sdp5DUHBG PvKZCCHk48LqGO7YnJiRSch62cB+6n1CBbn92ynB2CiMPSARp1juYXrenwIV3hKYGP GOhg5WbIjHLVvD+/2+o10gPnYcIo2TOMaubnk0VOCkvPCm3l71UDtpgy9FTKENf4vU 1muRD1gawilJaOWdp3cQCbmGMsYN6RiuPwsWTAKezppavpw4J03F1ml8VbvKg98YNd Io/HjMLs4TE3A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 41159180389 for ; Wed, 3 Dec 2025 15:57:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) 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_NONE autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from fout-b8-smtp.messagingengine.com (fout-b8-smtp.messagingengine.com [202.12.124.151]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 3 Dec 2025 15:57:14 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id 4BB7D1D000F8 for ; Wed, 3 Dec 2025 10:57:09 -0500 (EST) Received: from phl-imap-01 ([10.202.2.91]) by phl-compute-04.internal (MEProxy); Wed, 03 Dec 2025 10:57:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; 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=1764777429; x=1764863829; bh=R8Q31gY/0S0a55KnoR/U2 SUkxyrsNmEQmBAtxtqF+AY=; b=NFFDrVqE29tMOeKf8wW7OkS219ziYFzPyLJaY xr1M5ndlGg56FzatdsykLLDGBpcU0BMNzjOSe94XQjTBpYgB7aVPZIWAOfwH/47y +5ddf8TynX/45fc4zZ2J6yFzEfpXt1eSsyFnUfK6d8rGQbnHoMr5BhPvs/5C0G/A MscZg3jGIFG9FNI4VmqWwflynr6k0IH0Dj2ZmmHF4MnoyTirxg9lvH+780CK8869 QSDA0p+HcAEHoP0RijbMuIun9shkC80SRZeN2RM6PHzDgPLXTSRUr468AxFU2y0V 7RZrp9D0DKOxioUhnlx7KrDe1Snj9Q6ib6YJdJsRxcYKc8nkA== 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-sender :x-me-sender:x-sasl-enc; s=fm1; t=1764777429; x=1764863829; bh=R 8Q31gY/0S0a55KnoR/U2SUkxyrsNmEQmBAtxtqF+AY=; b=k3Preqq065yH4W7jz rJU59nfJQw6vm42f47ZyOUVJVoxWPwJhkaMqC5eQRnLrhmCScyNhtS1/aDMqU9ut +GU6QxAYtMpEQpV/05gaSKvbXbpZJB0qlbQsyyzoPgZHvYyv7ixaNIGpC+yV1G/R 0X1S65zHPRnsD0Nemsm9bI22uXQHbFarT4kajqlL/n+PID39fKl03w4Dqq1J4tHg JIG1QllyHPtzymqDGbPB0mDPocnWw7TvmTcG9F+8oHJiDggqRzM5qlFT6IHIB0Oc xwXsof8Dk3cjUIahwWhOPAlAb7KEPKy4o2KpkdRFzC/3eznxhKcJew9jace69fe+ Nmofw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdefvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceurghi lhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurh epofggfffhvffkjghfufgtgfesthhqredtredtjeenucfhrhhomhepfdfnrghrrhihucfi rghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmqeenuc ggtffrrghtthgvrhhnpeffieeivdfhvdeguddttdegteeiueegvefhteehfeeffeetudei tdehtdegjeeuieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomhdpnhgspghrtghpthht ohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsheslh hishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 0ABDE18C004E; Wed, 3 Dec 2025 10:57:09 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: A0wUJIXp2QXJ Date: Wed, 03 Dec 2025 09:56:15 -0600 To: "php internals" Message-ID: <9530d617-6951-4225-be8a-56e7b4ba594a@app.fastmail.com> In-Reply-To: References: Subject: Re: [PHP-DEV] [RFC] Pattern Matching Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Wed, Dec 3, 2025, at 2:21 AM, Alexandru P=C4=83tr=C4=83nescu wrote: > On Tue, Dec 2, 2025 at 10:09=E2=80=AFPM Larry Garfield wrote: >>=20 >>=20 >> > 1. There are mentions that any type present in a function parameter=20 >> > signature and return value is a valid pattern matching. >> > But are there any plans to extend the pattern-matching-syntax to=20 >> > parameter types and return values? >> > >> > Of course, with some restrictions: without variable pinning.And wit= hout=20 >> > variable binding on return type, but that could work on parameter t= ypes. >> > If that's possible or already planned, I think it's worth mentionin= g it=20 >> > in the future scope section. >>=20 >> See the linked "speculative extensions" document. It's mentioned the= re, but it hasn't gone beyond "Larry thinks it would be kinda cool to wr= ite `public int $x is >0`. That's definitely out of scope for now, but = I'm very open to discussing it in the future. >> =20 > > That is not exactly what I meant. > Since all types are valid patterns, can't we enlarge the type set to=20 > include more things from the pattern set? in future RFCs. > Something like this: `function process(Point(x: 3|4, y: $y) $p): ['a'=20 > =3D> int, 'b' =3D> float & >0]`. > > --=20 > Alex Yes, that's also in speculative extensions, under the "Parameter or retu= rn guards" section. :-) I think it would be cool (especially if combined with Rob's type aliases= ), but that's out of scope for now. --Larry Garfield