Run Rector on your code to see what it can do for you:
<?php final class DemoFile
{ protected function _getGroupByDateFormat($type) { - switch ($type) { - case 'day': - $format = '%Y-%m-%d'; - break; - default: - case 'hour': - $format = '%Y-%m-%d %H'; - break; - } - return $format; + return match ($type) { + 'day' => '%Y-%m-%d', + 'hour' => '%Y-%m-%d %H', + default => $format, + }; } }
Applied Rules:
Is the result wrong?
rector.php