3 puntos por smartbosslee 2020-07-16 | 3 comentarios | Compartir por WhatsApp

// 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

 
kunggom 2020-07-17

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

 
xguru 2020-07-16

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.

 
smartbosslee 2020-07-16

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.