Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(docs): remove redundant type #76

Merged
merged 1 commit into from
Jan 7, 2025
Merged
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
6 changes: 0 additions & 6 deletions src/EventsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,13 @@ class EventsList extends ArrayObject {

/**
* Return array of Events
*
* @return array
*/
public function getArrayCopy(): array {
return array_values(parent::getArrayCopy());
}

/**
* Return sorted EventList (the newest dates are first)
*
* @return $this
*/
public function sorted(): EventsList {
$this->uasort(static function ($a, $b): int {
Expand All @@ -39,8 +35,6 @@ public function sorted(): EventsList {

/**
* Return reversed sorted EventList (the oldest dates are first)
*
* @return $this
*/
public function reversed(): EventsList {
$this->uasort(static function ($a, $b): int {
Expand Down
26 changes: 2 additions & 24 deletions src/Freq.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
* @license http://creativecommons.org/licenses/by-sa/2.5/dk/deed.en_GB CC-BY-SA-DK
*/
class Freq {

/** @var bool */
public static bool $debug = false;

protected array $weekdays = [
Expand All @@ -56,7 +54,7 @@ class Freq {
'yearday',
'hour',
'minute',
]; //others : 'setpos', 'second'
]; // others: 'setpos', 'second'

protected array $ruleModifiers = ['wkst'];
protected bool $simpleMode = true;
Expand All @@ -73,8 +71,7 @@ class Freq {
/**
* Constructs a new Frequency-rule
*
* @param array|string $rule
* @param int $start Unix-timestamp (important : Need to be the start of Event)
* @param int $start Unix-timestamp (important: Need to be the start of Event)
* @param array $excluded of int (timestamps), see EXDATE documentation
* @param array $added of int (timestamps), see RDATE documentation
* @throws Exception
Expand Down Expand Up @@ -188,8 +185,6 @@ private function isPrerule(string $rule, string $freq): bool {
* If no new timestamps were found in the period, we try in the
* next period
*
* @param int $offset
* @return int|bool
* @throws Exception
*/
public function findNext(int $offset): bool|int {
Expand Down Expand Up @@ -295,11 +290,6 @@ public function findNext(int $offset): bool|int {
/**
* Finds the starting point for the next rule. It goes $interval
* 'freq' forward in time since the given offset
*
* @param int $offset
* @param int $interval
* @param boolean $truncate
* @return int
*/
private function findStartingPoint(int $offset, int $interval, bool $truncate = true): int {
$_freq = ($this->freq === 'daily') ? 'day__' : $this->freq;
Expand All @@ -325,10 +315,6 @@ private function findStartingPoint(int $offset, int $interval, bool $truncate =
* period specified by freq
*
* Yes - the fall-through is on purpose!
*
* @param int $time
* @param string $freq
* @return int
*/
private function truncateToPeriod(int $time, string $freq): int {
$date = getdate($time);
Expand Down Expand Up @@ -410,9 +396,6 @@ private function validDate($t): bool {

/**
* Finds the earliest timestamp possible outside this period.
*
* @param int $offset
* @return int
*/
public function findEndOfPeriod(int $offset = 0): int {
return $this->findStartingPoint($offset, 1, false);
Expand Down Expand Up @@ -494,7 +477,6 @@ public function lastOccurrence(): int {
/**
* Returns all timestamps array(), build the cache if not made before
*
* @return array
* @throws Exception
*/
public function getAllOccurrences(): array {
Expand All @@ -519,10 +501,6 @@ public function getAllOccurrences(): array {

/**
* Applies the BYDAY rule to the given timestamp
*
* @param string $rule
* @param int $t
* @return int
*/
private function ruleByDay(string $rule, int $t): int {
$dir = ($rule[0] === '-') ? -1 : 1;
Expand Down
18 changes: 2 additions & 16 deletions src/IcalParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,19 @@
* @author Roman Ožana <[email protected]>
*/
class IcalParser {

/** @var ?DateTimeZone */
public ?DateTimeZone $timezone = null;

/** @var array|null */
public ?array $data = null;

/** @var array */
protected array $counters = [];

/** @var array */
private array $windowsTimezones;

public function __construct() {
$this->windowsTimezones = require __DIR__ . '/WindowsTimezones.php'; // load Windows timezones from separate file
}

/**
* @param string $file
* @param callable|null $callback
* @return array|null
* @throws Exception
*/
public function parseFile(string $file, callable $callback = null): ?array {
public function parseFile(string $file, ?callable $callback = null): ?array {
if (!$handle = fopen($file, 'rb')) {
throw new RuntimeException('Can\'t open file' . $file . ' for reading.');
}
Expand All @@ -50,13 +39,10 @@ public function parseFile(string $file, callable $callback = null): ?array {
}

/**
* @param string $string
* @param callable|null $callback
* @param boolean $add if true the parsed string is added to existing data
* @return array|null
* @throws Exception
*/
public function parseString(string $string, callable $callback = null, bool $add = false): ?array {
public function parseString(string $string, ?callable $callback = null, bool $add = false): ?array {
if ($add === false) {
// delete old data
$this->data = [];
Expand Down
4 changes: 0 additions & 4 deletions src/Recurrence.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ class Recurrence {
protected mixed $wkst;
/**
* A list of the properties that can have comma-separated lists for values.
*
* @var array
*/
protected array $listProperties = [
'bysecond', 'byminute', 'byhour', 'byday', 'bymonthday',
Expand All @@ -59,8 +57,6 @@ public function __construct(array $rrule) {
/**
* Parses an 'RRULE' array and sets the member variables of this object.
* Expects a string that looks like this: 'FREQ=WEEKLY;INTERVAL=2;BYDAY=SU,TU,WE'
*
* @param array $rrule
*/
protected function parseRrule(array $rrule): void {
$this->rrule = $rrule;
Expand Down
Loading