Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129507 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 983791A00BC for ; Tue, 2 Dec 2025 11:58:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1764676724; bh=9ajAf37oKUsq7ELYMl9OmNPwEbul1pHUdJDVDt3drIE=; h=Date:Subject:To:References:From:In-Reply-To:From; b=CKHacACLiB421GaKRY0mKCYK/bDfY1tu2+MkO1Ks/6dq5eSGiQhtZFaA5pRL/yf4X f680qwqoeqlC3so4RZBHfUhE1hu6+6YCgyBSI3I4tp0+cwyn4Liku9sOsr6saM/S5Q LfCqU2Yt1TJ0+j23M555P0UAzTy8vLsaJGRpbeQC62HGOztf0XBzUkJUpiUmEFP1c8 snkrUscFKkJ0tbtH1Ed4VbgeVkAUuCl7WlwVEo656EVldEy7SdwQKCKYzdt5q4bwgH h956yhpZAPf1zYKtNNxu6sYP243fEgUjuthSnZLcUJFcSj69rmASbuyW5ID4JAAmg/ RC6WUtmOWYROg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EF922180080 for ; Tue, 2 Dec 2025 11:58:41 +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.8 required=5.0 tests=BAYES_50,DMARC_MISSING, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from gavin.smtp.mailx.hosts.net.nz (gavin.smtp.mailx.hosts.net.nz [43.245.52.167]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 2 Dec 2025 11:58:36 +0000 (UTC) Received: from 122-57-27-239-adsl.sparkbb.co.nz ([122.57.27.239] helo=[192.168.1.67]) by gavin.smtp.mailx.hosts.net.nz with esmtpsa authed as varteg.nz (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim 4.96) (envelope-from ) id 1vQP1X-00CEn3-2P for internals@lists.php.net; Wed, 03 Dec 2025 00:58:27 +1300 Message-ID: <9e295e28-5977-41fb-9cbc-f16cab366f98@varteg.nz> Date: Wed, 3 Dec 2025 00:58:19 +1300 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC] Pattern Matching To: internals@lists.php.net References: Content-Language: en-GB In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Hosts-DKIM-Check: none From: weedpacket@varteg.nz (Morgan) On 2025-12-02 19:26, Dmitry Derepko wrote: > > > Regarding the patterns, is there a way to declare and reuse the patterns? Assign it to a variable and use it as “is $pattern” or something like that. Maybe as a separate class “$pattern->match($var)”. > > There is an annex document on more speculative extensions linked in the RFC that mentions this: https://github.com/Crell/php-rfcs/blob/master/pattern-matching/future.md I was going to raise the thought of using these patterns to constrain function parameters (despite the heavy overlap of "$var is type" and "type $var"), but found that already included in the annex as well.