Skip to content

Commit

Permalink
Use GitHub Actions for PHPUnit, Rector, ECS and PHPStan
Browse files Browse the repository at this point in the history
  • Loading branch information
u01jmg3 committed Oct 17, 2022
1 parent f830416 commit 304ed15
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 43 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ updates:
open-pull-requests-limit: 10
reviewers:
- u01jmg3
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: weekly
41 changes: 41 additions & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Coding Standards

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
Scan:
runs-on: ubuntu-latest

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
tools: composer:2.2

- name: Install dependencies
run: |
composer install --quiet
composer require rector/rector symplify/easy-coding-standard --quiet
- name: Execute tests
run: vendor/bin/phpunit --verbose

- name: Execute Rector
run: vendor/bin/rector process src --dry-run

- name: Execute ECS
run: vendor/bin/ecs check

- name: Execute PHPStan
run: vendor/bin/phpstan analyse src
7 changes: 7 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
paths:
- src

level: 6

checkMissingIterableValueType: false
34 changes: 17 additions & 17 deletions src/ICal/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,119 +11,119 @@ class Event
/**
* https://www.kanzaki.com/docs/ical/summary.html
*
* @var $summary
* @var string
*/
public $summary;

/**
* https://www.kanzaki.com/docs/ical/dtstart.html
*
* @var $dtstart
* @var string
*/
public $dtstart;

/**
* https://www.kanzaki.com/docs/ical/dtend.html
*
* @var $dtend
* @var string
*/
public $dtend;

/**
* https://www.kanzaki.com/docs/ical/duration.html
*
* @var $duration
* @var string
*/
public $duration;

/**
* https://www.kanzaki.com/docs/ical/dtstamp.html
*
* @var $dtstamp
* @var string
*/
public $dtstamp;

/**
* When the event starts, represented as a timezone-adjusted string
*
* @var $dtstart_tz
* @var string
*/
public $dtstart_tz;

/**
* When the event ends, represented as a timezone-adjusted string
*
* @var $dtend_tz
* @var string
*/
public $dtend_tz;

/**
* https://www.kanzaki.com/docs/ical/uid.html
*
* @var $uid
* @var string
*/
public $uid;

/**
* https://www.kanzaki.com/docs/ical/created.html
*
* @var $created
* @var string
*/
public $created;

/**
* https://www.kanzaki.com/docs/ical/lastModified.html
*
* @var $last_modified
* @var string
*/
public $last_modified;

/**
* https://www.kanzaki.com/docs/ical/description.html
*
* @var $description
* @var string
*/
public $description;

/**
* https://www.kanzaki.com/docs/ical/location.html
*
* @var $location
* @var string
*/
public $location;

/**
* https://www.kanzaki.com/docs/ical/sequence.html
*
* @var $sequence
* @var string
*/
public $sequence;

/**
* https://www.kanzaki.com/docs/ical/status.html
*
* @var $status
* @var string
*/
public $status;

/**
* https://www.kanzaki.com/docs/ical/transp.html
*
* @var $transp
* @var string
*/
public $transp;

/**
* https://www.kanzaki.com/docs/ical/organizer.html
*
* @var $organizer
* @var string
*/
public $organizer;

/**
* https://www.kanzaki.com/docs/ical/attendee.html
*
* @var $attendee
* @var string
*/
public $attendee;

Expand Down
52 changes: 26 additions & 26 deletions src/ICal/ICal.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class ICal
/**
* Enables customisation of the default time zone
*
* @var string
* @var string|null
*/
public $defaultTimeZone;

Expand Down Expand Up @@ -94,14 +94,14 @@ class ICal
/**
* With this being non-null the parser will ignore all events more than roughly this many days after now.
*
* @var integer
* @var integer|null
*/
public $filterDaysBefore;

/**
* With this being non-null the parser will ignore all events more than roughly this many days before now.
*
* @var integer
* @var integer|null
*/
public $filterDaysAfter;

Expand Down Expand Up @@ -880,7 +880,7 @@ protected function unfold(array $lines)
*
* @param string $component
* @param string|boolean $keyword
* @param string $value
* @param string|array $value
* @return void
*/
protected function addCalendarComponentWithKeyAndValue($component, $keyword, $value)
Expand Down Expand Up @@ -1058,7 +1058,7 @@ public function keyValueFromString($text)
$object[1] = $valueObj;
}

return $object ?: false;
return $object;
}

/**
Expand Down Expand Up @@ -1173,10 +1173,10 @@ public function iCalDateToUnixTimestamp($icalDate)
/**
* Returns a date adapted to the calendar time zone depending on the event `TZID`
*
* @param array $event
* @param string $key
* @param string $format
* @return string|boolean
* @param array $event
* @param string $key
* @param string|null $format
* @return string|boolean|\DateTime
*/
public function iCalDateWithTimeZone(array $event, $key, $format = self::DATE_TIME_FORMAT)
{
Expand Down Expand Up @@ -1343,7 +1343,7 @@ protected function processRecurrences()
}

// Get Interval
$interval = (empty($rrules['INTERVAL'])) ? 1 : $rrules['INTERVAL'];
$interval = (empty($rrules['INTERVAL'])) ? 1 : (int) $rrules['INTERVAL'];

// Throw an error if this isn't an integer.
if (!is_int($this->defaultSpan)) {
Expand Down Expand Up @@ -1456,8 +1456,8 @@ function ($weekday) use ($initialDayOfWeek, $wkstTransition, $interval) {
foreach ($matchingDays as $day) {
$clonedDateTime = clone $frequencyRecurringDateTime;
$candidateDateTimes[] = $clonedDateTime->setISODate(
$frequencyRecurringDateTime->format('o'),
$frequencyRecurringDateTime->format('W'),
(int) $frequencyRecurringDateTime->format('o'),
(int) $frequencyRecurringDateTime->format('W'),
$day
);
}
Expand Down Expand Up @@ -1495,8 +1495,8 @@ function ($monthDay) use ($matchingDays) {

$clonedDateTime = clone $frequencyRecurringDateTime;
$candidateDateTimes[] = $clonedDateTime->setDate(
$frequencyRecurringDateTime->format('Y'),
$frequencyRecurringDateTime->format('m'),
(int) $frequencyRecurringDateTime->format('Y'),
(int) $frequencyRecurringDateTime->format('m'),
$day
);
}
Expand All @@ -1510,9 +1510,9 @@ function ($monthDay) use ($matchingDays) {
$bymonthRecurringDatetime = clone $frequencyRecurringDateTime;
foreach ($rrules['BYMONTH'] as $byMonth) {
$bymonthRecurringDatetime->setDate(
$frequencyRecurringDateTime->format('Y'),
(int) $frequencyRecurringDateTime->format('Y'),
$byMonth,
$frequencyRecurringDateTime->format('d')
(int) $frequencyRecurringDateTime->format('d')
);

// Determine the days of the month affected
Expand All @@ -1529,8 +1529,8 @@ function ($monthDay) use ($matchingDays) {
// And add each of them to the list of recurrences
foreach ($monthDays as $day) {
$matchingDays[] = $bymonthRecurringDatetime->setDate(
$frequencyRecurringDateTime->format('Y'),
$bymonthRecurringDatetime->format('m'),
(int) $frequencyRecurringDateTime->format('Y'),
(int) $bymonthRecurringDatetime->format('m'),
$day
)->format('z') + 1;
}
Expand Down Expand Up @@ -1569,7 +1569,7 @@ function ($yearDay) use ($matchingDays) {
foreach ($matchingDays as $day) {
$clonedDateTime = clone $frequencyRecurringDateTime;
$candidateDateTimes[] = $clonedDateTime->setDate(
$frequencyRecurringDateTime->format('Y'),
(int) $frequencyRecurringDateTime->format('Y'),
1,
$day
);
Expand Down Expand Up @@ -1805,7 +1805,7 @@ protected function getDaysOfMonthMatchingByDayRRule(array $byDays, $initialDateT
*/
protected function getDaysOfMonthMatchingByMonthDayRRule(array $byMonthDays, $initialDateTime)
{
return $this->resolveIndicesOfRange($byMonthDays, $initialDateTime->format('t'));
return $this->resolveIndicesOfRange($byMonthDays, (int) $initialDateTime->format('t'));
}

/**
Expand Down Expand Up @@ -1931,7 +1931,7 @@ protected function getDaysOfYearMatchingByWeekNoRRule(array $byWeekNums, $initia
$byweekDateTime = clone $initialDateTime;
foreach ($matchingWeeks as $weekNum) {
$dayNum = $byweekDateTime->setISODate(
$initialDateTime->format('Y'),
(int) $initialDateTime->format('Y'),
$weekNum,
1
)->format('z') + 1;
Expand Down Expand Up @@ -1966,16 +1966,16 @@ protected function getDaysOfYearMatchingByMonthDayRRule(array $byMonthDays, $ini
$monthDateTime = clone $initialDateTime;
for ($month = 1; $month < 13; $month++) {
$monthDateTime->setDate(
$initialDateTime->format('Y'),
(int) $initialDateTime->format('Y'),
$month,
1
);

$monthDays = $this->getDaysOfMonthMatchingByMonthDayRRule($byMonthDays, $monthDateTime);
foreach ($monthDays as $day) {
$matchingDays[] = $monthDateTime->setDate(
$initialDateTime->format('Y'),
$monthDateTime->format('m'),
(int) $initialDateTime->format('Y'),
(int) $monthDateTime->format('m'),
$day
)->format('z') + 1;
}
Expand Down Expand Up @@ -2109,7 +2109,7 @@ public function calendarDescription()
* Returns the calendar time zone
*
* @param boolean $ignoreUtc
* @return string
* @return string|null
*/
public function calendarTimeZone($ignoreUtc = false)
{
Expand Down Expand Up @@ -2357,7 +2357,7 @@ public function isValidWindowsTimeZoneId($timeZone)
*
* @param string $date
* @param \DateInterval $duration
* @param string $format
* @param string|null $format
* @return integer|\DateTime
*/
protected function parseDuration($date, $duration, $format = self::UNIX_FORMAT)
Expand Down

0 comments on commit 304ed15

Please sign in to comment.