// bool vs int
false =~= '' // true
false =~= '0' // false
false =~= 'false' // false
true =~= '1' // true
true =~= 'true' // false
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| > 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| enum Option { | |
| case None; | |
| case Some(mixed $value) { | |
| public function availableForSome() { | |
| var_dump($this->value); | |
| } | |
| }; | |
This file has been truncated, but you can view the full file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $_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) |
http://blog.codefx.org/java/switch-expressions/
result = switch (foo) {
case bar -> baz;
case bar2 -> baz2;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function sum(int $a, int $b, &$c) { | |
| $c = $a + $b; | |
| return $c; | |
| } | |
| function reflection_param_to_string(\ReflectionParameter $reflectionParam, bool $useList = false) { | |
| $string = ''; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| enum Boundaries | |
| { | |
| case includeNone; | |
| case includeStart; | |
| case includeEnd; | |
| case includeAll; | |
| public function startIncluded(): bool |
This file has been truncated, but you can view the full file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
NewerOlder