1
0
mirror of https://github.com/rlanvin/php-rrule.git synced 2024-12-01 08:24:10 +01:00

Fix compatibility with PHP 8.1 (#100)

Use #[\ReturnTypeWillChange] to suppress deprecation warnings with PHP 8.1
Add PHP 8.1 to test matrix
This commit is contained in:
Cédric Anne 2021-10-06 13:18:34 +02:00 committed by GitHub
parent f77c9644c6
commit 30f9170f3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View File

@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4','8.0'] php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
name: PHP ${{ matrix.php }} name: PHP ${{ matrix.php }}
steps: steps:
- name: Checkout - name: Checkout

View File

@ -917,6 +917,7 @@ class RRule implements RRuleInterface
/** /**
* @internal * @internal
*/ */
#[\ReturnTypeWillChange]
public function offsetExists($offset) public function offsetExists($offset)
{ {
return is_numeric($offset) && $offset >= 0 && ! is_float($offset) && $offset < count($this); return is_numeric($offset) && $offset >= 0 && ! is_float($offset) && $offset < count($this);
@ -925,6 +926,7 @@ class RRule implements RRuleInterface
/** /**
* @internal * @internal
*/ */
#[\ReturnTypeWillChange]
public function offsetGet($offset) public function offsetGet($offset)
{ {
if (! is_numeric($offset) || $offset < 0 || is_float($offset)) { if (! is_numeric($offset) || $offset < 0 || is_float($offset)) {
@ -957,6 +959,7 @@ class RRule implements RRuleInterface
/** /**
* @internal * @internal
*/ */
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value) public function offsetSet($offset, $value)
{ {
throw new \LogicException('Setting a Date in a RRule is not supported'); throw new \LogicException('Setting a Date in a RRule is not supported');
@ -965,6 +968,7 @@ class RRule implements RRuleInterface
/** /**
* @internal * @internal
*/ */
#[\ReturnTypeWillChange]
public function offsetUnset($offset) public function offsetUnset($offset)
{ {
throw new \LogicException('Unsetting a Date in a RRule is not supported'); throw new \LogicException('Unsetting a Date in a RRule is not supported');
@ -980,6 +984,7 @@ class RRule implements RRuleInterface
* *
* @return int * @return int
*/ */
#[\ReturnTypeWillChange]
public function count() public function count()
{ {
if ($this->isInfinite()) { if ($this->isInfinite()) {
@ -1326,6 +1331,7 @@ class RRule implements RRuleInterface
* *
* @return \DateTime|null * @return \DateTime|null
*/ */
#[\ReturnTypeWillChange]
public function getIterator() public function getIterator()
{ {
$total = 0; $total = 0;

View File

@ -489,6 +489,7 @@ class RSet implements RRuleInterface
/** /**
* @internal * @internal
*/ */
#[\ReturnTypeWillChange]
public function offsetExists($offset) public function offsetExists($offset)
{ {
return is_numeric($offset) && $offset >= 0 && ! is_float($offset) && $offset < count($this); return is_numeric($offset) && $offset >= 0 && ! is_float($offset) && $offset < count($this);
@ -497,6 +498,7 @@ class RSet implements RRuleInterface
/** /**
* @internal * @internal
*/ */
#[\ReturnTypeWillChange]
public function offsetGet($offset) public function offsetGet($offset)
{ {
if (! is_numeric($offset) || $offset < 0 || is_float($offset)) { if (! is_numeric($offset) || $offset < 0 || is_float($offset)) {
@ -529,6 +531,7 @@ class RSet implements RRuleInterface
/** /**
* @internal * @internal
*/ */
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value) public function offsetSet($offset, $value)
{ {
throw new \LogicException('Setting a Date in a RSet is not supported (use addDate)'); throw new \LogicException('Setting a Date in a RSet is not supported (use addDate)');
@ -537,6 +540,7 @@ class RSet implements RRuleInterface
/** /**
* @internal * @internal
*/ */
#[\ReturnTypeWillChange]
public function offsetUnset($offset) public function offsetUnset($offset)
{ {
throw new \LogicException('Unsetting a Date in a RSet is not supported (use addDate)'); throw new \LogicException('Unsetting a Date in a RSet is not supported (use addDate)');
@ -551,6 +555,7 @@ class RSet implements RRuleInterface
* introduces a performance penality. * introduces a performance penality.
* @return int * @return int
*/ */
#[\ReturnTypeWillChange]
public function count() public function count()
{ {
if ($this->isInfinite()) { if ($this->isInfinite()) {
@ -588,6 +593,7 @@ class RSet implements RRuleInterface
* @param $reset (bool) Whether to restart the iteration, or keep going * @param $reset (bool) Whether to restart the iteration, or keep going
* @return \DateTime|null * @return \DateTime|null
*/ */
#[\ReturnTypeWillChange]
public function getIterator() public function getIterator()
{ {
$previous_occurrence = null; $previous_occurrence = null;