Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Replace if/else with return match #38622

Merged
merged 1 commit into from Nov 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 8 additions & 15 deletions lib/private/Files/FileInfo.php
Expand Up @@ -121,21 +121,14 @@ public function offsetUnset($offset): void {
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset) {
if ($offset === 'type') {
return $this->getType();
} elseif ($offset === 'etag') {
return $this->getEtag();
} elseif ($offset === 'size') {
return $this->getSize();
} elseif ($offset === 'mtime') {
return $this->getMTime();
} elseif ($offset === 'permissions') {
return $this->getPermissions();
} elseif (isset($this->data[$offset])) {
return $this->data[$offset];
} else {
return null;
}
return match ($offset) {
'type' => $this->getType(),
'etag' => $this->getEtag(),
'size' => $this->getSize(),
'mtime' => $this->getMTime(),
'permissions' => $this->getPermissions(),
default => $this->data[$offset] ?? null,
};
}

/**
Expand Down