Skip to content

Commit

Permalink
Return static
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Jun 25, 2022
1 parent 50b2610 commit c209111
Show file tree
Hide file tree
Showing 27 changed files with 166 additions and 166 deletions.
8 changes: 4 additions & 4 deletions src/CircularString.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function geometryTypeBinary() : int
return Geometry::CIRCULARSTRING;
}

public function toXY(): CircularString
public function toXY(): static
{
if ($this->coordinateDimension() === 2) {
return $this;
Expand All @@ -153,7 +153,7 @@ public function toXY(): CircularString
return new CircularString($cs, ...$points);
}

public function withoutZ(): CircularString
public function withoutZ(): static
{
if (! $this->coordinateSystem->hasZ()) {
return $this;
Expand All @@ -166,7 +166,7 @@ public function withoutZ(): CircularString
return new CircularString($cs, ...$points);
}

public function withoutM(): CircularString
public function withoutM(): static
{
if (! $this->coordinateSystem->hasM()) {
return $this;
Expand Down Expand Up @@ -201,7 +201,7 @@ public function toArray() : array
return $result;
}

public function swapXY() : Geometry
public function swapXY() : static
{
$that = clone $this;

Expand Down
8 changes: 4 additions & 4 deletions src/CompoundCurve.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function geometryTypeBinary() : int
return Geometry::COMPOUNDCURVE;
}

public function toXY(): CompoundCurve
public function toXY(): static
{
if ($this->coordinateDimension() === 2) {
return $this;
Expand All @@ -165,7 +165,7 @@ public function toXY(): CompoundCurve
return new CompoundCurve($cs, ...$curves);
}

public function withoutZ(): CompoundCurve
public function withoutZ(): static
{
if (! $this->coordinateSystem->hasZ()) {
return $this;
Expand All @@ -178,7 +178,7 @@ public function withoutZ(): CompoundCurve
return new CompoundCurve($cs, ...$curves);
}

public function withoutM(): CompoundCurve
public function withoutM(): static
{
if (! $this->coordinateSystem->hasM()) {
return $this;
Expand Down Expand Up @@ -213,7 +213,7 @@ public function toArray() : array
return $result;
}

public function swapXY() : Geometry
public function swapXY() : static
{
$that = clone $this;

Expand Down
8 changes: 4 additions & 4 deletions src/CurvePolygon.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function geometryTypeBinary() : int
return Geometry::CURVEPOLYGON;
}

public function toXY(): CurvePolygon
public function toXY(): static
{
if ($this->coordinateDimension() === 2) {
return $this;
Expand All @@ -150,7 +150,7 @@ public function toXY(): CurvePolygon
return new CurvePolygon($cs, ...$rings);
}

public function withoutZ(): CurvePolygon
public function withoutZ(): static
{
if (! $this->coordinateSystem->hasZ()) {
return $this;
Expand All @@ -163,7 +163,7 @@ public function withoutZ(): CurvePolygon
return new CurvePolygon($cs, ...$rings);
}

public function withoutM(): CurvePolygon
public function withoutM(): static
{
if (! $this->coordinateSystem->hasM()) {
return $this;
Expand Down Expand Up @@ -198,7 +198,7 @@ public function toArray() : array
return $result;
}

public function swapXY() : Geometry
public function swapXY() : static
{
$that = clone $this;

Expand Down
14 changes: 7 additions & 7 deletions src/Geometry.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function __construct(CoordinateSystem $coordinateSystem, bool $isEmpty
* @throws InvalidGeometryException If the WKT represents an invalid geometry.
* @throws UnexpectedGeometryException If the resulting geometry is not an instance of the current class.
*/
public static function fromText(string $wkt, int $srid = 0) : Geometry
public static function fromText(string $wkt, int $srid = 0) : static
{
/** @var WKTReader|null $wktReader */
static $wktReader;
Expand Down Expand Up @@ -109,7 +109,7 @@ public static function fromText(string $wkt, int $srid = 0) : Geometry
* @throws InvalidGeometryException If the WKB represents an invalid geometry.
* @throws UnexpectedGeometryException If the resulting geometry is not an instance of the current class.
*/
public static function fromBinary(string $wkb, int $srid = 0) : Geometry
public static function fromBinary(string $wkb, int $srid = 0) : static
{
/** @var WKBReader|null $wkbReader */
static $wkbReader;
Expand Down Expand Up @@ -641,7 +641,7 @@ public function coordinateSystem() : CoordinateSystem
*
* @return static
*/
public function withSRID(int $srid) : Geometry
public function withSRID(int $srid) : static
{
if ($srid === $this->SRID()) {
return $this;
Expand All @@ -658,21 +658,21 @@ public function withSRID(int $srid) : Geometry
*
* @return static
*/
abstract public function toXY() : Geometry;
abstract public function toXY() : static;

/**
* Returns a copy of this Geometry, with the Z coordinate removed.
*
* @return static
*/
abstract public function withoutZ() : Geometry;
abstract public function withoutZ() : static;

/**
* Returns a copy of this Geometry, with the M coordinate removed.
*
* @return static
*/
abstract public function withoutM() : Geometry;
abstract public function withoutM() : static;

/**
* Returns the bounding box of the Geometry.
Expand All @@ -689,7 +689,7 @@ abstract public function toArray() : array;
*
* @return static
*/
abstract public function swapXY() : Geometry;
abstract public function swapXY() : static;

/**
* Returns a text representation of this geometry.
Expand Down
10 changes: 5 additions & 5 deletions src/GeometryCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function __construct(CoordinateSystem $cs, Geometry ...$geometries)
* @throws CoordinateSystemException If the geometries use different coordinate systems.
* @throws UnexpectedGeometryException If a geometry is not a valid type for a sub-class of GeometryCollection.
*/
public static function of(Geometry $geometry1, Geometry ...$geometryN) : GeometryCollection
public static function of(Geometry $geometry1, Geometry ...$geometryN) : static
{
return new static($geometry1->coordinateSystem(), $geometry1, ...$geometryN);
}
Expand Down Expand Up @@ -162,7 +162,7 @@ public function dimension() : int
return $dimension;
}

public function toXY(): GeometryCollection
public function toXY(): static
{
if ($this->coordinateDimension() === 2) {
return $this;
Expand All @@ -177,7 +177,7 @@ public function toXY(): GeometryCollection
return new GeometryCollection($cs, ...$geometries);
}

public function withoutZ(): GeometryCollection
public function withoutZ(): static
{
if (! $this->coordinateSystem->hasZ()) {
return $this;
Expand All @@ -190,7 +190,7 @@ public function withoutZ(): GeometryCollection
return new GeometryCollection($cs, ...$geometries);
}

public function withoutM(): GeometryCollection
public function withoutM(): static
{
if (! $this->coordinateSystem->hasM()) {
return $this;
Expand Down Expand Up @@ -225,7 +225,7 @@ public function toArray() : array
return $result;
}

public function swapXY() : Geometry
public function swapXY() : static
{
$that = clone $this;

Expand Down
8 changes: 4 additions & 4 deletions src/LineString.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function geometryTypeBinary() : int
return Geometry::LINESTRING;
}

public function toXY(): LineString
public function toXY(): static
{
if ($this->coordinateDimension() === 2) {
return $this;
Expand All @@ -195,7 +195,7 @@ public function toXY(): LineString
return new LineString($cs, ...$points);
}

public function withoutZ(): LineString
public function withoutZ(): static
{
if (! $this->coordinateSystem->hasZ()) {
return $this;
Expand All @@ -208,7 +208,7 @@ public function withoutZ(): LineString
return new LineString($cs, ...$points);
}

public function withoutM(): LineString
public function withoutM(): static
{
if (! $this->coordinateSystem->hasM()) {
return $this;
Expand Down Expand Up @@ -243,7 +243,7 @@ public function toArray() : array
return $result;
}

public function swapXY() : Geometry
public function swapXY() : static
{
$that = clone $this;

Expand Down
8 changes: 4 additions & 4 deletions src/Point.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public function dimension() : int
return 0;
}

public function toXY(): Point
public function toXY(): static
{
if ($this->coordinateDimension() === 2) {
return $this;
Expand All @@ -223,7 +223,7 @@ public function toXY(): Point
return new Point($cs, ...$coords);
}

public function withoutZ(): Point
public function withoutZ(): static
{
if (! $this->coordinateSystem->hasZ()) {
return $this;
Expand All @@ -245,7 +245,7 @@ public function withoutZ(): Point
return new Point($cs, ...$coords);
}

public function withoutM(): Point
public function withoutM(): static
{
if (! $this->coordinateSystem()->hasM()) {
return $this;
Expand Down Expand Up @@ -297,7 +297,7 @@ public function toArray() : array
return $result;
}

public function swapXY() : Geometry
public function swapXY() : static
{
$that = clone $this;

Expand Down
8 changes: 4 additions & 4 deletions src/Polygon.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function geometryTypeBinary() : int
return Geometry::POLYGON;
}

public function toXY(): Polygon
public function toXY(): static
{
if ($this->coordinateDimension() === 2) {
return $this;
Expand All @@ -170,7 +170,7 @@ public function toXY(): Polygon
return new Polygon($cs, ...$rings);
}

public function withoutZ(): Polygon
public function withoutZ(): static
{
if (! $this->coordinateSystem->hasZ()) {
return $this;
Expand All @@ -183,7 +183,7 @@ public function withoutZ(): Polygon
return new Polygon($cs, ...$rings);
}

public function withoutM(): Polygon
public function withoutM(): static
{
if (! $this->coordinateSystem->hasM()) {
return $this;
Expand Down Expand Up @@ -218,7 +218,7 @@ public function toArray() : array
return $result;
}

public function swapXY() : Geometry
public function swapXY() : static
{
$that = clone $this;

Expand Down
8 changes: 4 additions & 4 deletions src/PolyhedralSurface.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function geometryTypeBinary() : int
return Geometry::POLYHEDRALSURFACE;
}

public function toXY(): PolyhedralSurface
public function toXY(): static
{
if ($this->coordinateDimension() === 2) {
return $this;
Expand All @@ -166,7 +166,7 @@ public function toXY(): PolyhedralSurface
return new PolyhedralSurface($cs, ...$patches);
}

public function withoutZ(): PolyhedralSurface
public function withoutZ(): static
{
if (! $this->coordinateSystem->hasZ()) {
return $this;
Expand All @@ -179,7 +179,7 @@ public function withoutZ(): PolyhedralSurface
return new PolyhedralSurface($cs, ...$patches);
}

public function withoutM(): PolyhedralSurface
public function withoutM(): static
{
if (! $this->coordinateSystem->hasM()) {
return $this;
Expand Down Expand Up @@ -214,7 +214,7 @@ public function toArray() : array
return $result;
}

public function swapXY() : Geometry
public function swapXY() : static
{
$that = clone $this;

Expand Down

0 comments on commit c209111

Please sign in to comment.