spatie / period

Complex period comparisons
https://spatie.be/open-source
MIT License
1.65k stars 73 forks source link

Visualizer cause error when it have one period #130

Closed dihalt closed 10 months ago

dihalt commented 1 year ago

PHP 8.1 When $periods contains one period

        $visualizer = new Visualizer(["width" => 120]);
        $visualizer->visualize($periods);

This cause error in the selected line, because max function argument is integer. In this line not need spread operator ..., because that function can works with arrays.


class Visualizer {
     ...
    public function visualize(array $blocks): string
    {
        $matrix = $this->matrix($blocks);

>>>>>>> $nameLength = max(...array_map('strlen', array_keys($matrix)));

        $lines = [];

        foreach ($matrix as $name => $row) {
            $lines[] = vsprintf('%s    %s', [
                str_pad($name, $nameLength, ' '),
                $this->toBars($row),
            ]);
        }

        return implode("\n", $lines);
    }
    ...
}
spatie-bot commented 10 months ago

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.