Skip to content

Commit

Permalink
Revert some changes in ScheduleSpec and its mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Nov 7, 2024
1 parent ca4a595 commit 9397729
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
<file src="src/Client/Schedule/Spec/ScheduleSpec.php">
<DeprecatedProperty>
<code><![CDATA[$this->excludeCalendarList]]></code>
<code><![CDATA[$this->excludeCalendarList]]></code>
</DeprecatedProperty>
</file>
<file src="src/Client/Update/UpdateHandle.php">
Expand Down
14 changes: 10 additions & 4 deletions src/Client/Schedule/Spec/ScheduleSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,25 +246,31 @@ public function withAddedInterval(mixed $interval): self
}

/**
* Does nothing.
* Returns a new instance with the replaced exclude calendar list.
*
* @deprecated This method is deprecated and will be removed in the next major release.
*/
public function withExcludeCalendarList(CalendarSpec ...$calendar): self
{
@\trigger_error('ScheduleSpec::withExcludeCalendarList() is deprecated', E_USER_DEPRECATED);
return $this;

/** @see self::$excludeCalendarList */
return $this->with('excludeCalendarList', $calendar);
}

/**
* Does nothing.
* Any timestamps matching any of exclude* will be skipped.
*
* @deprecated This method is deprecated and will be removed in the next major release.
*/
public function withAddedExcludeCalendar(CalendarSpec $calendar): self
{
@\trigger_error('ScheduleSpec::withAddedExcludeCalendar() is deprecated', E_USER_DEPRECATED);
return $this;
$value = $this->excludeCalendarList;
$value[] = $calendar;

/** @see self::$excludeCalendarList */
return $this->with('excludeCalendarList', $value);
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/Internal/Mapper/ScheduleMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ private function prepareSpec(array $result): ScheduleSpec
$result['calendar'] ?? [],
);

unset($result['exclude_calendar']);
$result['exclude_calendar'] = \array_map(
static fn(array $item): CalendarSpec => new CalendarSpec($item),
$result['exclude_calendar'] ?? [],
);

$result['interval'] = \array_map(
static fn(array $item): IntervalSpec => new IntervalSpec($item),
Expand Down

0 comments on commit 9397729

Please sign in to comment.