3 points par smartbosslee 2020-07-16 | 3 commentaires | Partager sur WhatsApp
<p>// Avant<br /> switch ($this-&gt;lexer-&gt;lookahead['type']) {<br /> case Lexer::T_SELECT:<br /> $statement = $this-&gt;SelectStatement();<br /> break;<br /> <br /> case Lexer::T_UPDATE:<br /> $statement = $this-&gt;UpdateStatement();<br /> break;<br /> <br /> case Lexer::T_DELETE:<br /> $statement = $this-&gt;DeleteStatement();<br /> break;<br /> <br /> default:<br /> $this-&gt;syntaxError('SELECT, UPDATE or DELETE');<br /> break;<br /> }<br /> <br /> // Après<br /> $statement = match ($this-&gt;lexer-&gt;lookahead['type']) {<br /> Lexer::T_SELECT =&gt; $this-&gt;SelectStatement(),<br /> Lexer::T_UPDATE =&gt; $this-&gt;UpdateStatement(),<br /> Lexer::T_DELETE =&gt; $this-&gt;DeleteStatement(),<br /> default =&gt; $this-&gt;syntaxError('SELECT, UPDATE or DELETE'),<br /> };</p>

3 commentaires

 
kunggom 2020-07-17
<p>En Java aussi, une instruction Switch aux fonctionnalités améliorées a été intégrée dans les versions récentes. On dirait que c’est la tendance du moment.<br /> https://fr.news.hada.io/topic?id=1130</p&gt;
 
xguru 2020-07-16
<p>Nouvelles fonctionnalités de PHP 8 https://fr.news.hada.io/topic?id=1438<br /> <br /> Il me semble que ce n’était pas encore présent au moment de la publication de cette news, mais l’article original de ce côté a lui aussi été mis à jour avec les dernières informations et `match` y a été ajouté.</p>
 
smartbosslee 2020-07-16
<p>Oui. Son ajout est confirmé, mais il paraît que `Match` lui-même peut encore évoluer.<br /> Merci pour le lien.</p>