PHP 8'e Match ifadesi ekleniyor
(laravel-news.com)// Önce
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 or DELETE');
break;
}
// Sonra
$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 or DELETE'),
};
3 yorum
Java'da da işlevleri geliştirilmiş Switch ifadesi en yeni sürümlere girmişti. Görünüşe göre bu aralar trend bu.
https://tr.news.hada.io/topic?id=1130
PHP 8'in yeni özellikleri https://tr.news.hada.io/topic?id=1438
Bu haberi paylaşırken yok gibiydi ama bu taraftaki yazının orijinali de güncellenerek Match eklenmiş.
Evet. Ekleneceği kesinleşti, ancak Match’in kendisinde de hâlâ daha fazla değişiklik yapılma ihtimali varmış.
Bağlantı için teşekkürler.