Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f58f479

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 b5db7cd commit f58f479

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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
}

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)