Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 0 additions & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ parameters:
- tests
level: max
ignoreErrors:
-
message: '#^Undefined variable\: \$this$#'
path: tests/*.php
-
message: '#^Call to an undefined method Pest\\Expectation\|Pest\\Support\\Extendable\:\:.+\(\)\.$#'
path: tests/*.php
Expand Down
2 changes: 1 addition & 1 deletion src/Objects/Geometry.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function toArray(): array
public function toFeatureCollectionJson(): string
{
if (static::class === GeometryCollection::class) {
/** @var GeometryCollection<Geometry> $this */
/** @var GeometryCollection $this */
$geometries = $this->geometries;
} else {
$geometries = collect([$this]);
Expand Down
29 changes: 9 additions & 20 deletions src/Objects/GeometryCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,17 @@
use Illuminate\Support\Str;
use InvalidArgumentException;

/**
* @template TGeometry of Geometry
*
* @implements ArrayAccess<int, TGeometry>
*/
class GeometryCollection extends Geometry implements ArrayAccess
{
/** @var Collection<int, TGeometry> */
/** @var Collection<int, Geometry> */
protected Collection $geometries;

/** @var class-string<TGeometry> */
protected string $collectionOf = Geometry::class;

protected int $minimumGeometries = 0;

/**
* @param Collection<int, TGeometry>|array<int, TGeometry> $geometries
* @param Collection<int, Geometry>|array<int, Geometry> $geometries
*
* @throws InvalidArgumentException
*/
Expand All @@ -41,12 +35,6 @@ public function __construct(Collection|array $geometries)
$this->validateGeometriesCount();
}

/**
* @param bool $withFunction
* @return string
*
* @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter
*/
public function toWkt(bool $withFunction = true): string
{
$wkt = $this->toCollectionWkt(withFunction: true);
Expand Down Expand Up @@ -84,7 +72,7 @@ public function toArray(): array
}

/**
* @return Collection<int, TGeometry>
* @return Collection<int, Geometry>
*/
public function getGeometries(): Collection
{
Expand All @@ -102,20 +90,21 @@ public function offsetExists($offset): bool

/**
* @param int $offset
* @return TGeometry|null
* @return Geometry
*/
public function offsetGet($offset): ?Geometry
public function offsetGet($offset): Geometry
{
// @phpstan-ignore-next-line
return $this->geometries[$offset];
}

/**
* @param int $offset
* @param TGeometry $geometry
* @param Geometry $value
*/
public function offsetSet($offset, $geometry): void
public function offsetSet($offset, $value): void
{
$this->geometries[$offset] = $geometry;
$this->geometries[$offset] = $value;
$this->validateGeometriesType();
}

Expand Down
21 changes: 15 additions & 6 deletions src/Objects/MultiLineString.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@

namespace MatanYadaev\EloquentSpatial\Objects;

use Illuminate\Support\Collection;
use InvalidArgumentException;

/**
* @method array<LineString> getGeometries()
* @method LineString offsetGet(mixed $offset)
* @property Collection<int, LineString> $geometries
*
* @extends GeometryCollection<LineString>
* @method Collection<int, LineString> getGeometries()
* @method LineString offsetGet(int $offset)
* @method void offsetSet(int $offset, LineString $value)
*/
class MultiLineString extends GeometryCollection
{
Expand All @@ -17,11 +21,16 @@ class MultiLineString extends GeometryCollection
protected int $minimumGeometries = 1;

/**
* @param bool $withFunction
* @return string
* @param Collection<int, LineString>|array<int, LineString> $geometries
*
* @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter
* @throws InvalidArgumentException
*/
public function __construct(Collection|array $geometries)
{
// @phpstan-ignore-next-line
parent::__construct($geometries);
}

public function toWkt(bool $withFunction = true): string
{
$wkt = $this->toCollectionWkt(withFunction: false);
Expand Down
6 changes: 0 additions & 6 deletions src/Objects/MultiPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ class MultiPoint extends PointCollection
{
protected int $minimumGeometries = 1;

/**
* @param bool $withFunction
* @return string
*
* @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter
*/
public function toWkt(bool $withFunction = true): string
{
$wkt = $this->toCollectionWkt(withFunction: false);
Expand Down
21 changes: 15 additions & 6 deletions src/Objects/MultiPolygon.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@

namespace MatanYadaev\EloquentSpatial\Objects;

use Illuminate\Support\Collection;
use InvalidArgumentException;

/**
* @method array<Polygon> getGeometries()
* @method Polygon offsetGet(mixed $offset)
* @property Collection<int, Polygon> $geometries
*
* @extends GeometryCollection<Polygon>
* @method Collection<int, Polygon> getGeometries()
* @method Polygon offsetGet(int $offset)
* @method void offsetSet(int $offset, Polygon $value)
*/
class MultiPolygon extends GeometryCollection
{
Expand All @@ -17,11 +21,16 @@ class MultiPolygon extends GeometryCollection
protected int $minimumGeometries = 1;

/**
* @param bool $withFunction
* @return string
* @param Collection<int, Polygon>|array<int, Polygon> $geometries
*
* @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter
* @throws InvalidArgumentException
*/
public function __construct(Collection|array $geometries)
{
// @phpstan-ignore-next-line
parent::__construct($geometries);
}

public function toWkt(bool $withFunction = true): string
{
$wkt = $this->toCollectionWkt(withFunction: false);
Expand Down
21 changes: 18 additions & 3 deletions src/Objects/PointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,28 @@

namespace MatanYadaev\EloquentSpatial\Objects;

use Illuminate\Support\Collection;
use InvalidArgumentException;

/**
* @method array<Point> getGeometries()
* @method Point offsetGet(mixed $offset)
* @property Collection<int, Point> $geometries
*
* @extends GeometryCollection<Point>
* @method Collection<int, Point> getGeometries()
* @method Point offsetGet(int $offset)
* @method void offsetSet(int $offset, Point $value)
*/
abstract class PointCollection extends GeometryCollection
{
protected string $collectionOf = Point::class;

/**
* @param Collection<int, Point>|array<int, Point> $geometries
*
* @throws InvalidArgumentException
*/
public function __construct(Collection|array $geometries)
{
// @phpstan-ignore-next-line
parent::__construct($geometries);
}
}
Loading