Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add match section #21

Merged
merged 1 commit into from
Aug 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ if (
}
```

### 5.2 `switch`, `case`
### 5.2 `switch`, `case`, `match`

A `switch` structure looks like the following. Note the placement of
parentheses, spaces, and braces. The `case` statement MUST be indented once
Expand Down Expand Up @@ -757,6 +757,19 @@ switch (
}
```

Similarly, a `match` expression looks like the following. Note the placement
of parentheses, spaces, and braces.

```php
<?php

$returnValue = match ($expr) {
0 => 'First case',
1, 2, 3 => multipleCases(),
default => 'Default case',
};
```

### 5.3 `while`, `do while`

A `while` statement looks like the following. Note the placement of
Expand Down