Skip to content
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

PHP8.4 Deprecation fix #63

Open
wants to merge 2 commits into
base: v3
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/Shapefile/Geometry/GeometryCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ abstract protected function getCollectionClass();
*
* @param \Shapefile\Geometry\Geometry[] $geometries Optional array of geometries to initialize the collection.
*/
public function __construct(array $geometries = null)
public function __construct(array $geometries = [])
{
if ($geometries !== null) {
foreach ($geometries as $Geometry) {
Expand Down
8 changes: 4 additions & 4 deletions src/Shapefile/Geometry/MultiPolygon.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class MultiPolygon extends GeometryCollection
* - Shapefile::ORIENTATION_COUNTERCLOCKWISE
* - Shapefile::ORIENTATION_UNCHANGED
*/
public function __construct(array $polygons = null, $closed_rings = Shapefile::ACTION_CHECK, $force_orientation = Shapefile::ORIENTATION_COUNTERCLOCKWISE)
public function __construct(array $polygons = [], $closed_rings = Shapefile::ACTION_CHECK, $force_orientation = Shapefile::ORIENTATION_COUNTERCLOCKWISE)
{
$this->closed_rings = $closed_rings;
$this->force_orientation = $force_orientation;
Expand All @@ -109,7 +109,7 @@ public function initFromArray($array)
if (!isset($part['rings']) || !is_array($part['rings'])) {
throw new ShapefileException(Shapefile::ERR_INPUT_ARRAY_NOT_VALID);
}
$Polygon = new Polygon(null, $this->closed_rings, $this->force_orientation);
$Polygon = new Polygon([], $this->closed_rings, $this->force_orientation);
foreach ($part['rings'] as $part) {
if (!isset($part['points']) || !is_array($part['points'])) {
throw new ShapefileException(Shapefile::ERR_INPUT_ARRAY_NOT_VALID);
Expand All @@ -135,7 +135,7 @@ public function initFromWKT($wkt)
$force_z = $this->wktIsZ($wkt);
$force_m = $this->wktIsM($wkt);
foreach (explode(')),((', substr($this->wktExtractData($wkt), 2, -2)) as $part) {
$Polygon = new Polygon(null, $this->closed_rings, $this->force_orientation);
$Polygon = new Polygon([], $this->closed_rings, $this->force_orientation);
foreach (explode('),(', $part) as $ring) {
$Linestring = new Linestring();
foreach (explode(',', $ring) as $wkt_coordinates) {
Expand All @@ -160,7 +160,7 @@ public function initFromGeoJSON($geojson)
if (!is_array($part)) {
throw new ShapefileException(Shapefile::ERR_INPUT_GEOJSON_NOT_VALID, 'Wrong coordinates format');
}
$Polygon = new Polygon(null, $this->closed_rings, $this->force_orientation);
$Polygon = new Polygon([], $this->closed_rings, $this->force_orientation);
foreach ($part as $ring) {
if (!is_array($ring)) {
throw new ShapefileException(Shapefile::ERR_INPUT_GEOJSON_NOT_VALID, 'Wrong coordinates format');
Expand Down
2 changes: 1 addition & 1 deletion src/Shapefile/Geometry/Polygon.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class Polygon extends MultiLinestring
* - Shapefile::ORIENTATION_COUNTERCLOCKWISE
* - Shapefile::ORIENTATION_UNCHANGED
*/
public function __construct(array $linestrings = null, $closed_rings = Shapefile::ACTION_CHECK, $force_orientation = Shapefile::ORIENTATION_COUNTERCLOCKWISE)
public function __construct(array $linestrings = [], $closed_rings = Shapefile::ACTION_CHECK, $force_orientation = Shapefile::ORIENTATION_COUNTERCLOCKWISE)
{
$this->closed_rings = $closed_rings;
$this->force_orientation = $force_orientation;
Expand Down
4 changes: 2 additions & 2 deletions src/Shapefile/ShapefileReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ private function readPolygonZ()
*/
private function createPolygon($data)
{
$MultiPolygon = new MultiPolygon(null, $this->getOption(Shapefile::OPTION_POLYGON_CLOSED_RINGS_ACTION), $this->getOption(Shapefile::OPTION_POLYGON_OUTPUT_ORIENTATION));
$MultiPolygon = new MultiPolygon([], $this->getOption(Shapefile::OPTION_POLYGON_CLOSED_RINGS_ACTION), $this->getOption(Shapefile::OPTION_POLYGON_OUTPUT_ORIENTATION));
$Polygon = null;
$temp_state = null;
foreach ($data['geometry']['parts'] as $part) {
Expand All @@ -988,7 +988,7 @@ private function createPolygon($data)
if ($Polygon !== null) {
$MultiPolygon->addPolygon($Polygon);
}
$Polygon = new Polygon(null, $this->getOption(Shapefile::OPTION_POLYGON_CLOSED_RINGS_ACTION), $this->getOption(Shapefile::OPTION_POLYGON_OUTPUT_ORIENTATION));
$Polygon = new Polygon([], $this->getOption(Shapefile::OPTION_POLYGON_CLOSED_RINGS_ACTION), $this->getOption(Shapefile::OPTION_POLYGON_OUTPUT_ORIENTATION));
$temp_state = $is_clockwise;
}
$Polygon->addRing($Linestring);
Expand Down