Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130007 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 42F101A00BC for ; Wed, 4 Feb 2026 14:35:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1770215748; bh=aHYDxy1n+X91nR/VFomKGh3Jrv1nQmRSSe7lJcvBtA0=; h=Date:From:To:In-Reply-To:References:Subject:From; b=OmvB0Nl+kSFI2sybqMoyvzvEHkvSWSSeKVadLwPGgnjMI6Z8e4AR3Ow6DgN0gM8Ss e+kXtjL2/rKl2UltemFp73N6q4UKEtS7QFY/SmId5E5NifAVGsi00RVMUaEGTrZdck WPiIvOi6cotfI707JN+/s5CyhRmyGO0P63lg/75hxThMh7uV74XaOkveA430r+sFfS QedD3v3Q36Z4fZoGcPaQ29MXY0vi+EpUy2Knf06B7QVmvJsI+lNQ7KYiTBLs6vKali 1QA6DUGfN9X7h7qfESehZU341burwOOwGM7Bf7gfCI+Rkx6XPbGCo4xW4X8pOBPHlA nZ5If7Xq3xKmg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B9050180048 for ; Wed, 4 Feb 2026 14:35:47 +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 fhigh-a1-smtp.messagingengine.com (fhigh-a1-smtp.messagingengine.com [103.168.172.152]) (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 ; Wed, 4 Feb 2026 14:35:47 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id 0A3CE1400177 for ; Wed, 4 Feb 2026 09:35:42 -0500 (EST) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-04.internal (MEProxy); Wed, 04 Feb 2026 09:35:42 -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=fm3; t=1770215742; x=1770302142; bh=wqjTY/Zik2qf0eICLsnip QywoaIEJFn5TAhM5L9EiTc=; b=mLtoPx8GOAKpfD+7gvmhWagYyhxTzyiYLBJ8M ktqSrfVPUMS1s0MEQYis3+zfzlVTSpnMkFbPSxToeQ65ndLe1heN2jRdrtFdRQ/y LVGK7cEMDMQpe6JyknyYuhlkmVpvv5xi347ngus+SJnfmQ3vDm84Lal4j3aUqWZa G4h76pvjM4zTtpZMDo3XvhagDQwlvOzI2+Inx0YjuK0loido/mObiBzbTf/xhG0T qKLEporpumx6BZFZkJDAiexnO7O4XRmtDJwxB9WSsfFiJqVGzwOYr9gX6PIiXiHG iNTf1/A6SrzrE5kDX6/AW3R8N5tWZx1DUrGloV9PvlnTU3/Cg== 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=fm3; t=1770215742; x=1770302142; bh=w qjTY/Zik2qf0eICLsnipQywoaIEJFn5TAhM5L9EiTc=; b=Yyj82eoPPogtBEQsI mrGFw2zMY/Vc+uI000nFOcqsm0KydIAvUft3xgLbXeL0mdWlDfAtJWpsffM2SYeD tQmBWvut5bXhqlytRmTkaX2tNylkfKCt3K82Tik7+tDGmyR8avV/v6zBaoMhjX1T eJEfhuU7InlvC7lrdLevJ7VEiUYPsuJVR8ab/W/0mSosCmsusj94LfaHVVLJgGSZ kcBYwg75D8Hl+b5UPQDLgKy2G4a+Z5nTax3EeRZEnJfpfe01t8QNb6pHPLJBFsWq i/GMOxwhxjq00A1ghq1ebvbbLqwss1V09FIX/24ZR+PPrG4OjMkKD/4sienPq8JJ 3JVwA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddukedvieelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvffkjghfufgtgfesthejredtredttdenucfhrhhomhepfdfnrghrrhih ucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmqe enucggtffrrghtthgvrhhnpeeuvedvudfhffffhfelueehvdejvefgleegteegffetudef leehgeefvdehgeelteenucffohhmrghinhepphhhphdrnhgvthenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghl ughtvggthhdrtghomhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpd hrtghpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 90519700065; Wed, 4 Feb 2026 09:35:41 -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: AFxu8ZxMwycc Date: Wed, 04 Feb 2026 08:35:18 -0600 To: "php internals" Message-ID: <5260e078-6ad0-4684-96eb-1ee015d9c6d4@app.fastmail.com> In-Reply-To: References: <3b37ad58-2152-4e66-ae3d-2e197d791dc6@Spark> Subject: Re: [PHP-DEV] RFC Karma request: Enums with Associated Values for cases Content-Type: text/plain Content-Transfer-Encoding: 7bit From: larry@garfieldtech.com ("Larry Garfield") On Wed, Feb 4, 2026, at 6:16 AM, Jordi Kroon wrote: > Hello, > > I would like to get RFC Karma for my wiki account. My username is: > jkroon. > The proposed RFC will introduce Enums with Associated Values for cases > and is inspired by Rust and Swift. > > For example it would allow for the following: > > ``` > > enum ApiResult { > case Success(string $data, int $statusCode); > case Failure(Throwable $error, ?int $statusCode); > } > > function handle(ApiResult $r): string { > return match ($r) { > ApiResult::Success => 'OK ' . $r->statusCode . PHP_EOL, > ApiResult::Failure => 'NO ' . ($r->statusCode ?? 'unknown') . PHP_EOL, > }; > } > > echo handle(ApiResult::Success('All good', 200)); > echo handle(ApiResult::Failure(new Exception('Bad request'), 400)); > echo handle(ApiResult::Failure(new Exception('Server error'), null)); > ``` > > Regards, > Jordi Please be aware that there are already plans for this feature (RFC is a bit dated for now so don't take literally): https://wiki.php.net/rfc/tagged_unions Which is currently blocked pending pattern matching, currently in discussion: https://wiki.php.net/rfc/pattern-matching I'm regularly around the phpc.chat Discord if you want to talk about it more directly. Right now the main blocker is time availability, and getting pattern matching done. (See it's thread for the currently open questions.) --Larry Garfield