Skip to content

Commit 3cbf59f

Browse files
authored
chore: fix php 8.1 warnings and tests (#2131)
1 parent be74b9a commit 3cbf59f

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
php: [ "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0" ]
14+
php: [ "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1" ]
1515
composer-flags: [""]
1616
include:
1717
- php: "5.6"
1818
composer-flags: "--prefer-lowest "
1919
- php: "8.0"
2020
composer-flags: "--prefer-lowest "
2121
- php: "8.1"
22-
composer-flags: "--ignore-platform-reqs "
23-
- php: "8.1"
24-
composer-flags: "--ignore-platform-reqs --prefer-lowest "
22+
composer-flags: "--prefer-lowest "
2523
name: PHP ${{ matrix.php }} ${{ matrix.composer-flags }}Unit Test
2624
steps:
2725
- uses: actions/checkout@v2
@@ -45,7 +43,6 @@ jobs:
4543
name: Update phpunit/phpunit dependency
4644
run: composer update phpunit/phpunit phpspec/prophecy-phpunit --with-dependencies --ignore-platform-reqs
4745
- name: Run Script
48-
continue-on-error: ${{ matrix.php == '8.1' }}
4946
run: vendor/bin/phpunit
5047

5148
style:

src/Collection.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Collection extends Model implements \Iterator, \Countable
1111
{
1212
protected $collection_key = 'items';
1313

14-
#[ReturnTypeWillChange]
14+
#[\ReturnTypeWillChange]
1515
public function rewind()
1616
{
1717
if (isset($this->{$this->collection_key})
@@ -20,7 +20,7 @@ public function rewind()
2020
}
2121
}
2222

23-
#[ReturnTypeWillChange]
23+
#[\ReturnTypeWillChange]
2424
public function current()
2525
{
2626
$this->coerceType($this->key());
@@ -29,7 +29,7 @@ public function current()
2929
}
3030
}
3131

32-
#[ReturnTypeWillChange]
32+
#[\ReturnTypeWillChange]
3333
public function key()
3434
{
3535
if (isset($this->{$this->collection_key})
@@ -38,20 +38,20 @@ public function key()
3838
}
3939
}
4040

41-
#[ReturnTypeWillChange]
41+
#[\ReturnTypeWillChange]
4242
public function next()
4343
{
4444
return next($this->{$this->collection_key});
4545
}
4646

47-
#[ReturnTypeWillChange]
47+
#[\ReturnTypeWillChange]
4848
public function valid()
4949
{
5050
$key = $this->key();
5151
return $key !== null && $key !== false;
5252
}
5353

54-
#[ReturnTypeWillChange]
54+
#[\ReturnTypeWillChange]
5555
public function count()
5656
{
5757
if (!isset($this->{$this->collection_key})) {
@@ -60,7 +60,6 @@ public function count()
6060
return count($this->{$this->collection_key});
6161
}
6262

63-
#[ReturnTypeWillChange]
6463
public function offsetExists($offset)
6564
{
6665
if (!is_numeric($offset)) {
@@ -69,7 +68,6 @@ public function offsetExists($offset)
6968
return isset($this->{$this->collection_key}[$offset]);
7069
}
7170

72-
#[ReturnTypeWillChange]
7371
public function offsetGet($offset)
7472
{
7573
if (!is_numeric($offset)) {
@@ -79,7 +77,6 @@ public function offsetGet($offset)
7977
return $this->{$this->collection_key}[$offset];
8078
}
8179

82-
#[ReturnTypeWillChange]
8380
public function offsetSet($offset, $value)
8481
{
8582
if (!is_numeric($offset)) {
@@ -88,7 +85,6 @@ public function offsetSet($offset, $value)
8885
$this->{$this->collection_key}[$offset] = $value;
8986
}
9087

91-
#[ReturnTypeWillChange]
9288
public function offsetUnset($offset)
9389
{
9490
if (!is_numeric($offset)) {

src/Model.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,18 +253,21 @@ public function assertIsArray($obj, $method)
253253
}
254254
}
255255

256+
#[\ReturnTypeWillChange]
256257
public function offsetExists($offset)
257258
{
258259
return isset($this->$offset) || isset($this->modelData[$offset]);
259260
}
260261

262+
#[\ReturnTypeWillChange]
261263
public function offsetGet($offset)
262264
{
263265
return isset($this->$offset) ?
264266
$this->$offset :
265267
$this->__get($offset);
266268
}
267269

270+
#[\ReturnTypeWillChange]
268271
public function offsetSet($offset, $value)
269272
{
270273
if (property_exists($this, $offset)) {
@@ -275,6 +278,7 @@ public function offsetSet($offset, $value)
275278
}
276279
}
277280

281+
#[\ReturnTypeWillChange]
278282
public function offsetUnset($offset)
279283
{
280284
unset($this->modelData[$offset]);

0 commit comments

Comments
 (0)