Skip to content
Open
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
35 changes: 20 additions & 15 deletions language/enumerations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ enum Suit implements Colorful
// Fulfills the interface contract.
public function color(): string
{
return match($this) {
return match ($this) {
Suit::Hearts, Suit::Diamonds => 'Red',
Suit::Clubs, Suit::Spades => 'Black',
};
Expand Down Expand Up @@ -363,7 +363,7 @@ enum Suit: string implements Colorful
// Fulfills the interface contract.
public function color(): string
{
return match($this) {
return match ($this) {
Suit::Hearts, Suit::Diamonds => 'Red',
Suit::Clubs, Suit::Spades => 'Black',
};
Expand Down Expand Up @@ -414,7 +414,7 @@ final class Suit implements UnitEnum, Colorful

public function color(): string
{
return match($this) {
return match ($this) {
Suit::Hearts, Suit::Diamonds => 'Red',
Suit::Clubs, Suit::Spades => 'Black',
};
Expand Down Expand Up @@ -462,7 +462,7 @@ enum Size

public static function fromLength(int $cm): self
{
return match(true) {
return match (true) {
$cm < 50 => self::Small,
$cm < 100 => self::Medium,
default => self::Large,
Expand Down Expand Up @@ -527,7 +527,8 @@ interface Colorful

trait Rectangle
{
public function shape(): string {
public function shape(): string
{
return "Rectangle";
}
}
Expand All @@ -543,7 +544,7 @@ enum Suit implements Colorful

public function color(): string
{
return match($this) {
return match ($this) {
Suit::Hearts, Suit::Diamonds => 'Red',
Suit::Clubs, Suit::Spades => 'Black',
};
Expand Down Expand Up @@ -748,11 +749,13 @@ print serialize(Suit::Hearts);
<![CDATA[
<?php

enum Foo {
enum Foo
{
case Bar;
}

enum Baz: int {
enum Baz: int
{
case Beep = 5;
}

Expand Down Expand Up @@ -791,7 +794,8 @@ class B extends A {}

function foo(A $a) {}

function bar(B $b) {
function bar(B $b)
{
foo($b);
}
?>
Expand All @@ -812,7 +816,8 @@ function bar(B $b) {
<![CDATA[
<?php

enum ErrorCode {
enum ErrorCode
{
case SOMETHING_BROKE;
}

Expand All @@ -823,7 +828,6 @@ function quux(ErrorCode $errorCode)
ErrorCode::SOMETHING_BROKE => true,
};
}

?>
]]>
</programlisting>
Expand All @@ -844,16 +848,17 @@ function quux(ErrorCode $errorCode)

// Thought experiment code where enums are not final.
// Note, this won't actually work in PHP.
enum MoreErrorCode extends ErrorCode {
enum MoreErrorCode extends ErrorCode
{
case PEBKAC;
}

function fot(MoreErrorCode $errorCode) {
function fot(MoreErrorCode $errorCode)
{
quux($errorCode);
}

fot(MoreErrorCode::PEBKAC);

?>
]]>
</programlisting>
Expand Down Expand Up @@ -923,7 +928,7 @@ enum UserStatus: string

public function label(): string
{
return match($this) {
return match ($this) {
self::Pending => 'Pending',
self::Active => 'Active',
self::Suspended => 'Suspended',
Expand Down