php-src
php-src copied to clipboard
Match allow Lambda Functions
Description
Currently match() not allow use lambda functions.
If you try
$test = 'test';
$a = match($test) {
'test' => function($test) {
print_r($test);
}
};
- Return -- Today: Nothing is returned. -- New implementation: "test"
Match arms allow arbitrary expressions, including closures. But you need to call them yourself.
https://3v4l.org/OEnWa
Not calling the function is also already valid and returns the closure itself. Changing the meaning of that code would be a BC break (and pretty confusing).
https://3v4l.org/vACd5