From db7019e556f4d48d9d656d2f45358cd290cd9a9c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 4 May 2026 04:21:31 +0000 Subject: [PATCH 1/4] Initial plan From f9104f097a632052d20c293f9a69f0a9bbfd29d8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 4 May 2026 04:22:51 +0000 Subject: [PATCH 2/4] Drop PHP < 7.4 support and upgrade PHPStan to 2.x Agent-Logs-Url: https://github.com/donatj/SimpleCalendar/sessions/e23d84f4-11bb-4c84-b324-4434d1ef1a4d Co-authored-by: donatj <133747+donatj@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- composer.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2963840..5e42f62 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: operating-system: [ubuntu-latest] - php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] + php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] runs-on: ${{ matrix.operating-system }} diff --git a/composer.json b/composer.json index 0066b21..e0832fc 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "homepage" : "https://donatstudios.com/SimpleCalendar", "license" : "MIT", "require" : { - "php": ">=7.2", + "php": ">=7.4", "ext-calendar": "*" }, "require-dev": { @@ -14,7 +14,7 @@ "corpus/coding-standard": "^0.6.0", "donatj/drop": "^1.1", "friendsofphp/php-cs-fixer": "^3.3", - "phpstan/phpstan": "^1.10", + "phpstan/phpstan": "^2.0", "phpunit/phpunit": "*", "squizlabs/php_codesniffer": "^3.7" }, From 309d487ca28c2243f64741806d2673f3f6918cf4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 4 May 2026 04:30:06 +0000 Subject: [PATCH 3/4] Fix PHPStan 2.x errors: remove redundant assert, template-type rotate(), drop assertTrue(true) Agent-Logs-Url: https://github.com/donatj/SimpleCalendar/sessions/f748e819-6c6d-447d-ad48-c2d2fe8ade30 Co-authored-by: donatj <133747+donatj@users.noreply.github.com> --- src/SimpleCalendar.php | 8 +++----- test/SimpleCalendarTest.php | 2 -- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/SimpleCalendar.php b/src/SimpleCalendar.php index 4a15f2d..73f484b 100644 --- a/src/SimpleCalendar.php +++ b/src/SimpleCalendar.php @@ -203,10 +203,7 @@ public function setStartOfWeek( $offset ) : void { throw new \InvalidArgumentException('invalid offset'); } - $date = date('N', $weekTime); - assert($date !== false); - - $this->offset = intval($date) % 7; + $this->offset = intval(date('N', $weekTime)) % 7; } } @@ -315,7 +312,8 @@ public function render() : string { } /** - * @param array $data + * @template T + * @param array $data */ private function rotate( array &$data, int $steps ) : void { $count = count($data); diff --git a/test/SimpleCalendarTest.php b/test/SimpleCalendarTest.php index c87cd08..12a9329 100644 --- a/test/SimpleCalendarTest.php +++ b/test/SimpleCalendarTest.php @@ -16,8 +16,6 @@ public function testBadDailyHtmlDates() : void { $cal = new SimpleCalendar('June 2010', 'June 5 2010'); $cal->addDailyHtml('foo', 'tomorrow', 'yesterday'); } catch( InvalidArgumentException $ex ) { - $this->assertTrue(true); - return; } From 0a944f84acec076f10f060acd3170325dc0aad6c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 4 May 2026 04:36:18 +0000 Subject: [PATCH 4/4] Fix PHPStan and PHPCS: rewrite rotate() with array_slice+array_merge, add param-out, fix risky test Agent-Logs-Url: https://github.com/donatj/SimpleCalendar/sessions/dbb21c82-dab4-4f9f-bd11-a6421b09055b Co-authored-by: donatj <133747+donatj@users.noreply.github.com> --- src/SimpleCalendar.php | 11 +++++++++-- test/SimpleCalendarTest.php | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/SimpleCalendar.php b/src/SimpleCalendar.php index 73f484b..30e5402 100644 --- a/src/SimpleCalendar.php +++ b/src/SimpleCalendar.php @@ -314,17 +314,24 @@ public function render() : string { /** * @template T * @param array $data + * @param-out array $data */ private function rotate( array &$data, int $steps ) : void { $count = count($data); + if( $count === 0 ) { + return; + } + if( $steps < 0 ) { $steps = $count + $steps; } $steps %= $count; - for( $i = 0; $i < $steps; $i++ ) { - $data[] = array_shift($data); + if( $steps === 0 ) { + return; } + + $data = array_merge(array_slice($data, $steps), array_slice($data, 0, $steps)); } /** diff --git a/test/SimpleCalendarTest.php b/test/SimpleCalendarTest.php index 12a9329..a2563e7 100644 --- a/test/SimpleCalendarTest.php +++ b/test/SimpleCalendarTest.php @@ -16,6 +16,8 @@ public function testBadDailyHtmlDates() : void { $cal = new SimpleCalendar('June 2010', 'June 5 2010'); $cal->addDailyHtml('foo', 'tomorrow', 'yesterday'); } catch( InvalidArgumentException $ex ) { + $this->addToAssertionCount(1); + return; }