Skip to content

Commit

Permalink
Merge pull request #27 from GeoSot/feat/add-ci-actions
Browse files Browse the repository at this point in the history
feat: add ci actions
  • Loading branch information
benhall14 authored Oct 25, 2024
2 parents 6660d7e + cdc9ea8 commit 1c354ba
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 5 deletions.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: weekly
day: tuesday
time: "12:00"
20 changes: 20 additions & 0 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Check & fix styling

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
php-cs-fixer:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run PHP CS Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=ruleset-php_cs.php --allow-risky=yes --show-progress=dots --diff --dry-run
26 changes: 26 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: PHPStan

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
phpstan:
name: phpstan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
coverage: none

- name: Install composer dependencies
uses: ramsey/composer-install@v3

- name: Run PHPStan
run: ./vendor/bin/phpstan --error-format=github analyse -c ruleset-phpstan.neon -vvv
37 changes: 37 additions & 0 deletions .github/workflows/rector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Rector

on:
push:
branches: [main]
pull_request:
branches: [main]


jobs:
rector:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Rector Cache
uses: actions/cache@v3
with:
path: /tmp/rector
key: ${{ runner.os }}-rector-${{ github.run_id }}
restore-keys: ${{ runner.os }}-rector-

- run: mkdir -p /tmp/rector

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
coverage: none

- name: Install composer dependencies
uses: ramsey/composer-install@v3

- name: Rector Dry Run
run: php vendor/bin/rector process --dry-run --config=rector.php


1 change: 1 addition & 0 deletions ruleset-php_cs.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'php_unit_method_casing' => ['case' => 'snake_case'],
'elseif' => true,
'phpdoc_align' => ['align' => 'left'],
'global_namespace_import' => true,
];

$dirsToCheck = [
Expand Down
4 changes: 2 additions & 2 deletions src/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
namespace benhall14\phpCalendar;

use BadMethodCallException;
use DateTimeInterface;
use benhall14\phpCalendar\Views\Month;
use benhall14\phpCalendar\Views\Week;
use Carbon\Carbon;
use DateTimeInterface;

/**
* Simple PHP Calendar Class.
Expand Down Expand Up @@ -146,7 +146,7 @@ public function addEvent(
* (optional) 'mask' => a masking class name.
* (optional) 'classes' => custom classes to include.
*
* @param iterable<int, array{start: (string| DateTimeInterface), end: (string|DateTimeInterface), summary?: string, classes?: (string|list<string>), mask?: bool, event_box_classes?: (string|list<string>)}> $events the events array
* @param iterable<int, array{start: (string|DateTimeInterface), end: (string|DateTimeInterface), summary?: string, classes?: (string|list<string>), mask?: bool, event_box_classes?: (string|list<string>)}> $events the events array
*/
public function addEvents(iterable $events): static
{
Expand Down
3 changes: 3 additions & 0 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class Config
*/
public array $hiddenDays = [];

/**
* @return list<string>
*/
public function getHiddenDays(): array
{
return array_intersect($this->hiddenDays, Carbon::getDays());
Expand Down
3 changes: 2 additions & 1 deletion src/Views/Month.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use benhall14\phpCalendar\Event;
use Carbon\Carbon;
use Carbon\CarbonInterface;
use DateTimeInterface;

class Month extends View
{
Expand All @@ -22,7 +23,7 @@ protected function findEvents(CarbonInterface $start, CarbonInterface $end): arr
/**
* Returns the calendar as a month view.
*/
public function render(\DateTimeInterface|string|null $startDate = null, string $color = ''): string
public function render(DateTimeInterface|string|null $startDate = null, string $color = ''): string
{
$calendar = $this->makeHiddenStyles();

Expand Down
2 changes: 1 addition & 1 deletion src/Views/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace benhall14\phpCalendar\Views;

use DateTimeInterface;
use benhall14\phpCalendar\Calendar;
use benhall14\phpCalendar\Config;
use benhall14\phpCalendar\Event;
use Carbon\CarbonInterface;
use DateTimeInterface;

abstract class View
{
Expand Down
3 changes: 2 additions & 1 deletion src/Views/Week.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace benhall14\phpCalendar\Views;

use DateTimeInterface;
use benhall14\phpCalendar\Event;
use Carbon\Carbon;
use Carbon\CarbonInterface;
use Carbon\CarbonInterval;
use Carbon\CarbonPeriod;
use DateTimeInterface;

class Week extends View
{
Expand Down Expand Up @@ -98,6 +98,7 @@ protected function makeHeader(CarbonPeriod $carbonPeriod): string
if ($this->config->dayShouldBeHidden($carbon)) {
continue;
}

$headerString .= '<th class="cal-th cal-th-'.strtolower($carbon->englishDayOfWeek).'">';
$headerString .= '<div class="cal-weekview-dow">'.ucfirst($carbon->localeDayOfWeek).'</div>';
$headerString .= '<div class="cal-weekview-day">'.$carbon->day.'</div>';
Expand Down

0 comments on commit 1c354ba

Please sign in to comment.