Skip to content

Commit

Permalink
Merge pull request #125 from thephpleague/feature/version5-compatibility
Browse files Browse the repository at this point in the history
Reduce BC Break from version 5.0.0
  • Loading branch information
nyamsprod authored Feb 21, 2022
2 parents 9b56621 + 21bfd92 commit 766e9dd
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 19 deletions.
56 changes: 47 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,41 @@

All notable changes to `Period` will be documented in this file

## Next - TBD
## 4.12.0 - 2022-02-21

### Added

- `Datepoint::second`
- `Datepoint::minute`
- `Datepoint::hour`
- `Datepoint::isoWeek`
- `Datepoint::month`
- `Datepoint::quarter`
- `Datepoint::semester`
- `Datepoint::year`
- `Datepoint::isoYear`
- `Duration::fromDateInterval`
- `Duration::fromSeconds`
- `Duration::fromChronoString`
- `Duration::fromTimeString`
- `Duration::fromDateString`
- `Period::timeDuration`
- `Period::dateInterval`
- `Period::dateRangeForward`
- `Period::dateRangeBackwards`
- `Period::toIso80000`
- `Period::splitForward`
- `Period::timeDurationDiff`
- `Period::boundedBy`
- `Sequence::length`
- `Sequence::totalTimeDuration`

### Fixed

- None

### Deprecated

- `Datepoint::getSecond` is deprecated in favor of `Datepoint::second`
- `Datepoint::getMinute` is deprecated in favor of `Datepoint::minute`
- `Datepoint::getHour` is deprecated in favor of `Datepoint::hour`
Expand All @@ -15,14 +46,21 @@ All notable changes to `Period` will be documented in this file
- `Datepoint::getSemester` is deprecated in favor of `Datepoint::semester`
- `Datepoint::getYear` is deprecated in favor of `Datepoint::year`
- `Datepoint::getIsoYear` is deprecated in favor of `Datepoint::isoYear`

### Fixed

- None

### Deprecated

- None
- `Duration::createfromDateInterval` is deprecated in favor of `Datepoint::fromDateInterval`
- `Duration::createfromSeconds` is deprecated in favor of `Datepoint::fromSeconds`
- `Duration::createfromChronoString` is deprecated in favor of `Datepoint::fromChronoString`
- `Duration::createfromTimeString` is deprecated in favor of `Datepoint::fromTimeString`
- `Duration::createfromDateString` is deprecated in favor of `Datepoint::fromDateString`
- `Period::getTimestampInterval` is deprecated in favor of `Period::timeDuration`
- `Period::getDateInterval` is deprecated in favor of `Period::dateInterval`
- `Period::getDatePeriod` is deprecated in favor of `Period::dateRangeForward`
- `Period::getDatePeriodBackwards` is deprecated in favor of `Period::dateRangeBackwards`
- `Period::format` is deprecated in favor of `Period::toIso80000`
- `Period::split` is deprecated in favor of `Period::splitForward`
- `Period::withBoundaryType` is deprecated in favor of `Period::boundedBy`
- `Period::timestampIntervalDiff` is deprecated in favor of `Period::timeDurationDiff`
- `Sequence::boundaries` is deprecated in favor of `Sequence::length`
- `Sequence::getTotalTimestampInterval` is deprecated in favor of `Sequence::totalTimeDuration`

### Removed

Expand Down
19 changes: 9 additions & 10 deletions src/Sequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
use function array_values;
use function count;
use function reset;
use function sort;
use function sprintf;
use function uasort;
use function usort;
Expand All @@ -42,7 +41,7 @@
final class Sequence implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
{
/** @var array<Period> */
private $intervals = [];
private $intervals;

public function __construct(Period ...$intervals)
{
Expand Down Expand Up @@ -455,30 +454,30 @@ public function offsetUnset($offset): void

/**
* @inheritDoc
* @param mixed $offset the integer index of the Period to add or update
* @param mixed $interval the Period instance to add
* @param mixed $offset the integer index of the Period to add or update
* @param mixed $value the Period instance to add
*
* @throws InvalidIndex If the offset is illegal for the current sequence
*
* @see Sequence::push
* @see Sequence::set
*/
public function offsetSet($offset, $interval): void
public function offsetSet($offset, $value): void
{
if (!is_int($offset) && !is_null($offset)) {
throw new TypeError('Argument #1 ($offset) must be of type integer, '.gettype($interval).' given.');
throw new TypeError('Argument #1 ($offset) must be of type integer, '.gettype($value).' given.');
}

if (!$interval instanceof Period) {
throw new TypeError('Argument #2 ($interval) must be of type Period, '.gettype($interval).' given.');
if (!$value instanceof Period) {
throw new TypeError('Argument #2 ($interval) must be of type League\Period\Period, '.gettype($value).' given.');
}

if (null !== $offset) {
$this->set($offset, $interval);
$this->set($offset, $value);
return;
}

$this->push($interval);
$this->push($value);
}

/**
Expand Down

0 comments on commit 766e9dd

Please sign in to comment.