Skip to content

Fix: Add array return type to jsonSerialize method for PHP 8.3+ comp… #214

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
13 changes: 9 additions & 4 deletions src/Types/Point.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use GeoJson\GeoJson;
use GeoJson\Geometry\Point as GeoJsonPoint;
use Grimzy\LaravelMysqlSpatial\Exceptions\InvalidGeoJsonException;

class Point extends Geometry
class Point extends Geometry implements \JsonSerializable
{
protected $lat;

Expand Down Expand Up @@ -92,8 +91,14 @@ public static function fromJson($geoJson)
*
* @return \GeoJson\Geometry\Point
*/
public function jsonSerialize()
public function jsonSerialize(): array
{
return new GeoJsonPoint([$this->getLng(), $this->getLat()]);
return [
'type' => 'Point',
'coordinates' => [
$this->getLng(),
$this->getLat()
]
];
}
}