Skip to content

Commit 766e9dd

Browse files
authored
Merge pull request #125 from thephpleague/feature/version5-compatibility
Reduce BC Break from version 5.0.0
2 parents 9b56621 + 21bfd92 commit 766e9dd

File tree

2 files changed

+56
-19
lines changed

2 files changed

+56
-19
lines changed

CHANGELOG.md

+47-9
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,41 @@
22

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

5-
## Next - TBD
5+
## 4.12.0 - 2022-02-21
66

77
### Added
88

9+
- `Datepoint::second`
10+
- `Datepoint::minute`
11+
- `Datepoint::hour`
12+
- `Datepoint::isoWeek`
13+
- `Datepoint::month`
14+
- `Datepoint::quarter`
15+
- `Datepoint::semester`
16+
- `Datepoint::year`
17+
- `Datepoint::isoYear`
18+
- `Duration::fromDateInterval`
19+
- `Duration::fromSeconds`
20+
- `Duration::fromChronoString`
21+
- `Duration::fromTimeString`
22+
- `Duration::fromDateString`
23+
- `Period::timeDuration`
24+
- `Period::dateInterval`
25+
- `Period::dateRangeForward`
26+
- `Period::dateRangeBackwards`
27+
- `Period::toIso80000`
28+
- `Period::splitForward`
29+
- `Period::timeDurationDiff`
30+
- `Period::boundedBy`
31+
- `Sequence::length`
32+
- `Sequence::totalTimeDuration`
33+
34+
### Fixed
35+
36+
- None
37+
38+
### Deprecated
39+
940
- `Datepoint::getSecond` is deprecated in favor of `Datepoint::second`
1041
- `Datepoint::getMinute` is deprecated in favor of `Datepoint::minute`
1142
- `Datepoint::getHour` is deprecated in favor of `Datepoint::hour`
@@ -15,14 +46,21 @@ All notable changes to `Period` will be documented in this file
1546
- `Datepoint::getSemester` is deprecated in favor of `Datepoint::semester`
1647
- `Datepoint::getYear` is deprecated in favor of `Datepoint::year`
1748
- `Datepoint::getIsoYear` is deprecated in favor of `Datepoint::isoYear`
18-
19-
### Fixed
20-
21-
- None
22-
23-
### Deprecated
24-
25-
- None
49+
- `Duration::createfromDateInterval` is deprecated in favor of `Datepoint::fromDateInterval`
50+
- `Duration::createfromSeconds` is deprecated in favor of `Datepoint::fromSeconds`
51+
- `Duration::createfromChronoString` is deprecated in favor of `Datepoint::fromChronoString`
52+
- `Duration::createfromTimeString` is deprecated in favor of `Datepoint::fromTimeString`
53+
- `Duration::createfromDateString` is deprecated in favor of `Datepoint::fromDateString`
54+
- `Period::getTimestampInterval` is deprecated in favor of `Period::timeDuration`
55+
- `Period::getDateInterval` is deprecated in favor of `Period::dateInterval`
56+
- `Period::getDatePeriod` is deprecated in favor of `Period::dateRangeForward`
57+
- `Period::getDatePeriodBackwards` is deprecated in favor of `Period::dateRangeBackwards`
58+
- `Period::format` is deprecated in favor of `Period::toIso80000`
59+
- `Period::split` is deprecated in favor of `Period::splitForward`
60+
- `Period::withBoundaryType` is deprecated in favor of `Period::boundedBy`
61+
- `Period::timestampIntervalDiff` is deprecated in favor of `Period::timeDurationDiff`
62+
- `Sequence::boundaries` is deprecated in favor of `Sequence::length`
63+
- `Sequence::getTotalTimestampInterval` is deprecated in favor of `Sequence::totalTimeDuration`
2664

2765
### Removed
2866

src/Sequence.php

+9-10
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
use function array_values;
2727
use function count;
2828
use function reset;
29-
use function sort;
3029
use function sprintf;
3130
use function uasort;
3231
use function usort;
@@ -42,7 +41,7 @@
4241
final class Sequence implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
4342
{
4443
/** @var array<Period> */
45-
private $intervals = [];
44+
private $intervals;
4645

4746
public function __construct(Period ...$intervals)
4847
{
@@ -455,30 +454,30 @@ public function offsetUnset($offset): void
455454

456455
/**
457456
* @inheritDoc
458-
* @param mixed $offset the integer index of the Period to add or update
459-
* @param mixed $interval the Period instance to add
457+
* @param mixed $offset the integer index of the Period to add or update
458+
* @param mixed $value the Period instance to add
460459
*
461460
* @throws InvalidIndex If the offset is illegal for the current sequence
462461
*
463462
* @see Sequence::push
464463
* @see Sequence::set
465464
*/
466-
public function offsetSet($offset, $interval): void
465+
public function offsetSet($offset, $value): void
467466
{
468467
if (!is_int($offset) && !is_null($offset)) {
469-
throw new TypeError('Argument #1 ($offset) must be of type integer, '.gettype($interval).' given.');
468+
throw new TypeError('Argument #1 ($offset) must be of type integer, '.gettype($value).' given.');
470469
}
471470

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

476475
if (null !== $offset) {
477-
$this->set($offset, $interval);
476+
$this->set($offset, $value);
478477
return;
479478
}
480479

481-
$this->push($interval);
480+
$this->push($value);
482481
}
483482

484483
/**

0 commit comments

Comments
 (0)