Re: [RFC] Match expression
| From: | lists@rhsoft.net | Date: | Sun, 10 Sep 2017 19:35:21 +0000 |
| Subject: | Re: [RFC] Match expression | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-100510@lists.php.net to get a copy of this message | ||
Am 10.09.2017 um 21:25 schrieb Ryan Pallas:
On Sep 10, 2017 1:23 PM, "lists@rhsoft.net <mailto:lists@rhsoft.net>" <lists@rhsoft.net <mailto:lists@rhsoft.net>> wrote:the whole switch discussion is broken by design with "<?php declare(strict_types=1);" the intention is pretty clear raise an error if cases are mixed (case 'a' and case 1 und the same switch) and also raise an error in a case libe below when $a is anything else then int there is reall yno syntax sugar needed - the first statement of the file contains the intention of the developer and yes i migrated a 250000 LOC codebase stared in 2003 with PHP4 to PHP7 with strict types for every single file switch($a) { case 1: ..; break; case 2: ..; break; }Am 10.09.2017 um 21:16 schrieb Theodore Brown:On Sunday, September 10, 2017 12:45 PM Rowan Collins <rowan.collins@gmail.com <mailto:rowan.collins@gmail.com>> wrote:Would it be possible to add an optional$strictparameter to switch? E.g. ``` switch ($i, true) {I'd very much prefer a "strict switch ($i) { ... }" over a second parameter.What do either of you think of my "switch-use" proposal, which would spell this as "switch ($i) use (===)"?That seems more complicated and confusing than either of the other options. Normallyuse()is for inheriting variables in anonymous functions.where did you seeuse()in the proposed SYNTAX? hint: it's not thereit's just "strict switch" versus "switch"Rowan's suggestion included use