Skip to content

Adds support for PHP8.1 return types #189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/Types/GeometryCollection.php
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
use Illuminate\Contracts\Support\Arrayable;
use InvalidArgumentException;
use IteratorAggregate;
use Traversable;

class GeometryCollection extends Geometry implements IteratorAggregate, ArrayAccess, Arrayable, Countable
{
@@ -87,22 +88,22 @@ public function toArray()
return $this->items;
}

public function getIterator()
public function getIterator(): Traversable
{
return new ArrayIterator($this->items);
}

public function offsetExists($offset)
public function offsetExists($offset): bool
{
return isset($this->items[$offset]);
}

public function offsetGet($offset)
public function offsetGet($offset): mixed
{
return $this->offsetExists($offset) ? $this->items[$offset] : null;
}

public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
$this->validateItemType($value);

@@ -113,12 +114,12 @@ public function offsetSet($offset, $value)
}
}

public function offsetUnset($offset)
public function offsetUnset($offset): void
{
unset($this->items[$offset]);
}

public function count()
public function count(): int
{
return count($this->items);
}
@@ -146,7 +147,7 @@ public static function fromJson($geoJson)
*
* @return \GeoJson\Geometry\GeometryCollection
*/
public function jsonSerialize()
public function jsonSerialize(): mixed
{
$geometries = [];
foreach ($this->items as $geometry) {
2 changes: 1 addition & 1 deletion src/Types/LineString.php
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ public static function fromJson($geoJson)
*
* @return \GeoJson\Geometry\LineString
*/
public function jsonSerialize()
public function jsonSerialize(): mixed
{
$points = [];
foreach ($this->items as $point) {
4 changes: 2 additions & 2 deletions src/Types/MultiLineString.php
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ public function __toString()
}, $this->getLineStrings()));
}

public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
$this->validateItemType($value);

@@ -83,7 +83,7 @@ public static function fromJson($geoJson)
*
* @return \GeoJson\Geometry\MultiLineString
*/
public function jsonSerialize()
public function jsonSerialize(): mixed
{
$lineStrings = [];

2 changes: 1 addition & 1 deletion src/Types/MultiPoint.php
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ public static function fromJson($geoJson)
*
* @return \GeoJson\Geometry\MultiPoint
*/
public function jsonSerialize()
public function jsonSerialize(): mixed
{
$points = [];
foreach ($this->items as $point) {
4 changes: 2 additions & 2 deletions src/Types/MultiPolygon.php
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@ protected static function assembleParts(array $parts)
return $polygons;
}

public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
$this->validateItemType($value);

@@ -127,7 +127,7 @@ public static function fromJson($geoJson)
*
* @return \GeoJson\Geometry\MultiPolygon
*/
public function jsonSerialize()
public function jsonSerialize(): mixed
{
$polygons = [];
foreach ($this->items as $polygon) {
2 changes: 1 addition & 1 deletion src/Types/Point.php
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ public static function fromJson($geoJson)
*
* @return \GeoJson\Geometry\Point
*/
public function jsonSerialize()
public function jsonSerialize(): mixed
{
return new GeoJsonPoint([$this->getLng(), $this->getLat()]);
}
2 changes: 1 addition & 1 deletion src/Types/PointCollection.php
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ public function toPairList()
}, $this->items));
}

public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
$this->validateItemType($value);

2 changes: 1 addition & 1 deletion src/Types/Polygon.php
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ public static function fromJson($geoJson)
*
* @return \GeoJson\Geometry\Polygon
*/
public function jsonSerialize()
public function jsonSerialize(): mixed
{
$linearRings = [];
foreach ($this->items as $lineString) {