Se agregará la expresión Match en PHP 8
(laravel-news.com)// Antes
switch ($this->lexer->lookahead['type']) {
case Lexer::T_SELECT:
$statement = $this->SelectStatement();
break;
case Lexer::T_UPDATE:
$statement = $this->UpdateStatement();
break;
case Lexer::T_DELETE:
$statement = $this->DeleteStatement();
break;
default:
$this->syntaxError('SELECT, UPDATE o DELETE');
break;
}
// Después
$statement = match ($this->lexer->lookahead['type']) {
Lexer::T_SELECT => $this->SelectStatement(),
Lexer::T_UPDATE => $this->UpdateStatement(),
Lexer::T_DELETE => $this->DeleteStatement(),
default => $this->syntaxError('SELECT, UPDATE o DELETE'),
};
3 comentarios
En Java también incluyeron en las versiones recientes una sentencia Switch con funcionalidades mejoradas. Parece que este tipo de cosas están de moda últimamente.
https://es.news.hada.io/topic?id=1130
Nuevas funciones de PHP 8 https://es.news.hada.io/topic?id=1438
Parece que cuando se publicó esta noticia todavía no estaba, pero en el artículo original de este lado también lo actualizaron y agregaron
Match.Sí. Ya está confirmado que se agregará, pero dicen que Match en sí todavía podría tener más cambios.
Gracias por el enlace.