diff --git a/libraries/classes/Gis/GisPolygon.php b/libraries/classes/Gis/GisPolygon.php index c00bc21d0d..66b7269eff 100644 --- a/libraries/classes/Gis/GisPolygon.php +++ b/libraries/classes/Gis/GisPolygon.php @@ -296,7 +296,7 @@ class GisPolygon extends GisGeometry /** * Calculates the area of a closed simple polygon. * - * @param mixed[] $ring array of points forming the ring + * @param non-empty-list $ring array of points forming the ring * * @return float the area of a closed simple polygon */ @@ -330,7 +330,7 @@ class GisPolygon extends GisGeometry * Determines whether a set of points represents an outer ring. * If points are in clockwise orientation then, they form an outer ring. * - * @param mixed[] $ring array of points forming the ring + * @param non-empty-list $ring array of points forming the ring */ public static function isOuterRing(array $ring): bool { @@ -342,8 +342,8 @@ class GisPolygon extends GisGeometry /** * Determines whether a given point is inside a given polygon. * - * @param mixed[] $point x, y coordinates of the point - * @param mixed[] $polygon array of points forming the ring + * @param array{x: float, y: float} $point x, y coordinates of the point + * @param non-empty-list $polygon array of points forming the ring */ public static function isPointInsidePolygon(array $point, array $polygon): bool { @@ -394,9 +394,9 @@ class GisPolygon extends GisGeometry * Returns a point that is guaranteed to be on the surface of the ring. * (for simple closed rings) * - * @param mixed[] $ring array of points forming the ring + * @param non-empty-list $ring array of points forming the ring * - * @return mixed[]|false a point on the surface of the ring + * @return array{x: float, y: float}|false a point on the surface of the ring */ public static function getPointOnSurface(array $ring): array|false { @@ -415,7 +415,7 @@ class GisPolygon extends GisGeometry } } - if (! isset($x0)) { + if (! isset($x0, $x1, $y0, $y1)) { return false; } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 222b80dc1f..c60c666727 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -4006,7 +4006,7 @@ parameters: path: libraries/classes/Gis/GisMultiPolygon.php - - message: "#^Parameter \\#1 \\$point of static method PhpMyAdmin\\\\Gis\\\\GisPolygon\\:\\:isPointInsidePolygon\\(\\) expects array, mixed given\\.$#" + message: "#^Parameter \\#1 \\$point of static method PhpMyAdmin\\\\Gis\\\\GisPolygon\\:\\:isPointInsidePolygon\\(\\) expects array\\{x\\: float, y\\: float\\}, mixed given\\.$#" count: 1 path: libraries/classes/Gis/GisMultiPolygon.php @@ -4016,12 +4016,12 @@ parameters: path: libraries/classes/Gis/GisMultiPolygon.php - - message: "#^Parameter \\#1 \\$ring of static method PhpMyAdmin\\\\Gis\\\\GisPolygon\\:\\:getPointOnSurface\\(\\) expects array, mixed given\\.$#" + message: "#^Parameter \\#1 \\$ring of static method PhpMyAdmin\\\\Gis\\\\GisPolygon\\:\\:getPointOnSurface\\(\\) expects non\\-empty\\-array\\, mixed given\\.$#" count: 1 path: libraries/classes/Gis/GisMultiPolygon.php - - message: "#^Parameter \\#1 \\$ring of static method PhpMyAdmin\\\\Gis\\\\GisPolygon\\:\\:isOuterRing\\(\\) expects array, mixed given\\.$#" + message: "#^Parameter \\#1 \\$ring of static method PhpMyAdmin\\\\Gis\\\\GisPolygon\\:\\:isOuterRing\\(\\) expects non\\-empty\\-array\\, mixed given\\.$#" count: 1 path: libraries/classes/Gis/GisMultiPolygon.php @@ -4031,7 +4031,7 @@ parameters: path: libraries/classes/Gis/GisMultiPolygon.php - - message: "#^Parameter \\#2 \\$polygon of static method PhpMyAdmin\\\\Gis\\\\GisPolygon\\:\\:isPointInsidePolygon\\(\\) expects array, mixed given\\.$#" + message: "#^Parameter \\#2 \\$polygon of static method PhpMyAdmin\\\\Gis\\\\GisPolygon\\:\\:isPointInsidePolygon\\(\\) expects non\\-empty\\-array\\, mixed given\\.$#" count: 1 path: libraries/classes/Gis/GisMultiPolygon.php @@ -4092,12 +4092,12 @@ parameters: - message: "#^Cannot access offset 'x' on mixed\\.$#" - count: 18 + count: 3 path: libraries/classes/Gis/GisPolygon.php - message: "#^Cannot access offset 'y' on mixed\\.$#" - count: 22 + count: 3 path: libraries/classes/Gis/GisPolygon.php - diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 7c7f49cdfa..fdf2bb55c4 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -6627,110 +6627,17 @@ $pointsArr - - ($y1 - $y0) ** 2 + ($x0 - $x1) ** 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $area - $area - $area $noOfLines $noOfPoints - $p1 - $p1 - $p1 - $p1 - $p1 - $p2 - - - - - $x0 - $x1 - $x2 - $xinters - $y0 - $y1 - $y2 - - float - - $area - $area - $epsilon * ($y1 - $y0) - $epsilon * ($y1 - $y0) - - - - - - - - - $x0 - $x0 - $x0 - $x0 - $x2 - $x2 - $y0 - $y1 - $y1 - $y1 - $y1 - $y1 - $y1 - $y0 - $y1 - $y0 - $y2 - $y2 - - - - ($y1 - $y0) ** 2 @@ -6738,31 +6645,10 @@ && trim((string) $gisData[$index]['POLYGON'][$i][$j]['y']) != '' ? $gisData[$index]['POLYGON'][$i][$j]['y'] : $empty]]> - - $area - $black $fillColor - - $x1 - $x1 - $x1 - $x1 - $y0 - $y0 - $y0 - $y0 - $y0 - $y0 - $y1 - $y1 - $y1 - $y1 - $y1 - $y1 - isset(self::$instance) diff --git a/test/classes/Gis/GisPolygonTest.php b/test/classes/Gis/GisPolygonTest.php index d5823ab822..9924aa2d19 100644 --- a/test/classes/Gis/GisPolygonTest.php +++ b/test/classes/Gis/GisPolygonTest.php @@ -126,8 +126,8 @@ class GisPolygonTest extends GisGeomTestCase /** * test for Area * - * @param mixed[] $ring array of points forming the ring - * @param float $area area of the ring + * @param non-empty-list $ring array of points forming the ring + * @param float $area area of the ring * * @dataProvider providerForTestArea */ @@ -140,7 +140,7 @@ class GisPolygonTest extends GisGeomTestCase /** * data provider for testArea * - * @return array + * @return list, float}> */ public static function providerForTestArea(): array { @@ -164,9 +164,9 @@ class GisPolygonTest extends GisGeomTestCase /** * test for isPointInsidePolygon * - * @param mixed[] $point x, y coordinates of the point - * @param mixed[] $polygon array of points forming the ring - * @param bool $isInside output + * @param array{x: float, y: float} $point x, y coordinates of the point + * @param non-empty-list $polygon array of points forming the ring + * @param bool $isInside output * * @dataProvider providerForTestIsPointInsidePolygon */ @@ -179,7 +179,7 @@ class GisPolygonTest extends GisGeomTestCase /** * data provider for testIsPointInsidePolygon * - * @return array + * @return array, bool}> */ public static function providerForTestIsPointInsidePolygon(): array { @@ -205,7 +205,7 @@ class GisPolygonTest extends GisGeomTestCase /** * test for getPointOnSurface * - * @param mixed[] $ring array of points forming the ring + * @param non-empty-list $ring array of points forming the ring * * @dataProvider providerForTestGetPointOnSurface */ @@ -417,7 +417,7 @@ class GisPolygonTest extends GisGeomTestCase /** * test case for isOuterRing() method * - * @param array> $ring coordinates of the points in a ring + * @param non-empty-list $ring coordinates of the points in a ring * * @dataProvider providerForIsOuterRing */ @@ -430,7 +430,7 @@ class GisPolygonTest extends GisGeomTestCase /** * data provider for testIsOuterRing() test case * - * @return array>}> + * @return array}> */ public static function providerForIsOuterRing(): array {