Skip to content

Commit 3cfdf08

Browse files
authored
Add PHP 8.1 support by specifying return types for getIterator and count (#1142)
* Test on PHP 8.1 * Specify return types for `getIterator` and `count` This is required for PHP 8.1.
1 parent 11704a4 commit 3cfdf08

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

.github/workflows/component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
php-version: ['7.3', '7.4', '8.0']
17+
php-version: ['7.3', '7.4', '8.0', '8.1']
1818
component: [Common, Http, Plugin]
1919

2020
name: PHP ${{ matrix.php-version }} / ${{ matrix.component }}

.github/workflows/php.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
php-version: ['7.4', '8.0']
17+
php-version: ['7.4', '8.0', '8.1']
1818
deps: ['low', 'high']
1919
include:
2020
- php-version: '7.3'

.github/workflows/provider.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
php-version: ['7.3', '7.4', '8.0']
16+
php-version: ['7.3', '7.4', '8.0', '8.1']
1717
provider:
1818
- AlgoliaPlaces
1919
- ArcGISOnline

src/Common/Model/AddressCollection.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Geocoder\Exception\CollectionIsEmpty;
1717
use Geocoder\Exception\OutOfBounds;
1818
use Geocoder\Location;
19+
use Traversable;
1920

2021
final class AddressCollection implements Collection
2122
{
@@ -35,15 +36,15 @@ public function __construct(array $locations = [])
3536
/**
3637
* {@inheritdoc}
3738
*/
38-
public function getIterator()
39+
public function getIterator(): Traversable
3940
{
4041
return new \ArrayIterator($this->all());
4142
}
4243

4344
/**
4445
* {@inheritdoc}
4546
*/
46-
public function count()
47+
public function count(): int
4748
{
4849
return count($this->locations);
4950
}

src/Common/Model/AdminLevelCollection.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Geocoder\Exception\CollectionIsEmpty;
1616
use Geocoder\Exception\InvalidArgument;
1717
use Geocoder\Exception\OutOfBounds;
18+
use Traversable;
1819

1920
/**
2021
* @author Giorgio Premi <[email protected]>
@@ -53,15 +54,15 @@ public function __construct(array $adminLevels = [])
5354
/**
5455
* {@inheritdoc}
5556
*/
56-
public function getIterator()
57+
public function getIterator(): Traversable
5758
{
5859
return new \ArrayIterator($this->all());
5960
}
6061

6162
/**
6263
* {@inheritdoc}
6364
*/
64-
public function count()
65+
public function count(): int
6566
{
6667
return count($this->adminLevels);
6768
}

0 commit comments

Comments
 (0)