Run Rector on your code to see what it can do for you:
<?php final class Workload {
// ... private function &getRef(int $index): int { - switch ($index) { - case 0: - return $this->monday; - case 1: - return $this->tuesday; - // ... - default: - throw new LogicException(); - } + return match ($index) { + 0 => $this->monday, + 1 => $this->tuesday, + default => throw new LogicException(), + }; } public function setAtIndex(int $index, int $value) {
Applied Rules:
Not a change you expect?
rector.php