Skip to content

Commit

Permalink
Add return types
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Mar 21, 2022
1 parent 42ef0cd commit d34793a
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/Types/GeometryCollectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
class GeometryCollectionType extends GeometryType
{
public function getName()
public function getName() : string
{
return 'GeometryCollection';
}
Expand Down
18 changes: 9 additions & 9 deletions src/Types/GeometryType.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ protected function hasKnownSubclasses() : bool
return true;
}

public function getName()
public function getName() : string
{
return 'Geometry';
}

public function getSQLDeclaration(array $column, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform) : string
{
if ($platform->getName() === 'postgresql') {
return 'GEOMETRY';
Expand All @@ -64,7 +64,7 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform)
return strtoupper($this->getName());
}

public function convertToPHPValue($value, AbstractPlatform $platform)
public function convertToPHPValue($value, AbstractPlatform $platform) : ?Geometry
{
/** @var string|resource|null $value */
if ($value === null) {
Expand All @@ -89,7 +89,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return new $proxyClassName($value, true, self::$srid);
}

public function convertToDatabaseValue($value, AbstractPlatform $platform)
public function convertToDatabaseValue($value, AbstractPlatform $platform) : ?string
{
if ($value === null) {
return null;
Expand All @@ -104,7 +104,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
throw new \UnexpectedValueException(sprintf('Expected %s, got %s.', Geometry::class, $type));
}

public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform)
public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform) : string
{
if ($platform->getName() === 'mysql') {
$sqlExpr = sprintf('BINARY %s', $sqlExpr);
Expand All @@ -113,22 +113,22 @@ public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform)
return sprintf('ST_GeomFromWKB(%s, %d)', $sqlExpr, self::$srid);
}

public function convertToPHPValueSQL($sqlExpr, $platform)
public function convertToPHPValueSQL($sqlExpr, $platform) : string
{
return sprintf('ST_AsBinary(%s)', $sqlExpr);
}

public function canRequireSQLConversion()
public function canRequireSQLConversion() : bool
{
return true;
}

public function requiresSQLCommentHint(AbstractPlatform $platform)
public function requiresSQLCommentHint(AbstractPlatform $platform) : bool
{
return true;
}

public function getBindingType()
public function getBindingType() : int
{
return \PDO::PARAM_LOB;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Types/LineStringType.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
class LineStringType extends GeometryType
{
public function getName()
public function getName() : string
{
return 'LineString';
}
Expand Down
2 changes: 1 addition & 1 deletion src/Types/MultiLineStringType.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
class MultiLineStringType extends GeometryType
{
public function getName()
public function getName() : string
{
return 'MultiLineString';
}
Expand Down
2 changes: 1 addition & 1 deletion src/Types/MultiPointType.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
class MultiPointType extends GeometryType
{
public function getName()
public function getName() : string
{
return 'MultiPoint';
}
Expand Down
2 changes: 1 addition & 1 deletion src/Types/MultiPolygonType.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
class MultiPolygonType extends GeometryType
{
public function getName()
public function getName() : string
{
return 'MultiPolygon';
}
Expand Down
2 changes: 1 addition & 1 deletion src/Types/PointType.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
class PointType extends GeometryType
{
public function getName()
public function getName() : string
{
return 'Point';
}
Expand Down
2 changes: 1 addition & 1 deletion src/Types/PolygonType.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
class PolygonType extends GeometryType
{
public function getName()
public function getName() : string
{
return 'Polygon';
}
Expand Down

0 comments on commit d34793a

Please sign in to comment.