Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"homepage" : "https://donatstudios.com/SimpleCalendar",
"license" : "MIT",
"require" : {
"php": ">=7.2",
"php": ">=7.4",
"ext-calendar": "*"
},
"require-dev": {
"ext-dom": "*",
"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"
},
Expand Down
19 changes: 12 additions & 7 deletions src/SimpleCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -315,18 +312,26 @@ public function render() : string {
}

/**
* @param array<int, mixed> $data
* @template T
* @param array<int, T> $data
* @param-out array<int, T> $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));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/SimpleCalendarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function testBadDailyHtmlDates() : void {
$cal = new SimpleCalendar('June 2010', 'June 5 2010');
$cal->addDailyHtml('foo', 'tomorrow', 'yesterday');
} catch( InvalidArgumentException $ex ) {
$this->assertTrue(true);
$this->addToAssertionCount(1);

return;
}
Expand Down