Re: [RFC] Pattern Matching

From: Date: Tue, 02 Dec 2025 11:58:19 +0000
Subject: Re: [RFC] Pattern Matching
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-129507@lists.php.net to get a copy of this message
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.

« previous php.internals (#129507) next »