http://blog.codefx.org/java/switch-expressions/
result = switch (foo) {
case bar -> baz;
case bar2 -> baz2;| Terminals unused in grammar | |
| "comment (T_COMMENT)" | |
| "doc comment (T_DOC_COMMENT)" | |
| "open tag (T_OPEN_TAG)" | |
| "open tag with echo (T_OPEN_TAG_WITH_ECHO)" | |
| "close tag (T_CLOSE_TAG)" | |
| "whitespace (T_WHITESPACE)" | |
| "invalid character (T_BAD_CHARACTER)" | |
| T_ERROR |
| <?php | |
| enum Boundaries | |
| { | |
| case includeNone; | |
| case includeStart; | |
| case includeEnd; | |
| case includeAll; | |
| public function startIncluded(): bool |
| <?php | |
| function sum(int $a, int $b, &$c) { | |
| $c = $a + $b; | |
| return $c; | |
| } | |
| function reflection_param_to_string(\ReflectionParameter $reflectionParam, bool $useList = false) { | |
| $string = ''; |
http://blog.codefx.org/java/switch-expressions/
result = switch (foo) {
case bar -> baz;
case bar2 -> baz2;| $_main: | |
| ; (lines=72, args=0, vars=1, tmps=19) | |
| ; (before optimizer) | |
| ; /tmp/php-src/Zend/tests/match/039.phpt:1-62 | |
| ; return [] RANGE[0..0] | |
| 0000 ECHO string("--TEST-- | |
| Test match with duplicate conditions | |
| --FILE-- | |
| ") | |
| 0001 ASSIGN CV0($value) int(1) |
| <?php | |
| function takes_ref(&$ref) {} | |
| $foo = null; | |
| takes_ref($foo?->bar); | |
| // Can either: | |
| // 1. Throw no error, pass null | |
| // 2. Throw a "Cannot parameter 1 by reference" error |
| Terminals unused in grammar | |
| "comment (T_COMMENT)" | |
| "doc comment (T_DOC_COMMENT)" | |
| "open tag (T_OPEN_TAG)" | |
| "open tag with echo (T_OPEN_TAG_WITH_ECHO)" | |
| "close tag (T_CLOSE_TAG)" | |
| "whitespace (T_WHITESPACE)" | |
| "invalid character (T_BAD_CHARACTER)" | |
| T_ERROR |
| <?php | |
| enum Option { | |
| case None; | |
| case Some(mixed $value) { | |
| public function availableForSome() { | |
| var_dump($this->value); | |
| } | |
| }; | |
| > An Enumeration may have one or more case definitions, with no maximum, although at least one is required. | |
| Could an enum with no values potentially be useful? If not, should we still allow it for consistencies sake? | |
| > __toString, Do we want this part or not? I only thought of it while writing this. I don't know if it's good or bad. | |
| Could be useful. Why not. | |
| > The Enum Type may also implement an interface, which all Cases must then fulfill, directly or indirectly. |