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.

Reply via email to