Add array shapes in GisPolygon

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
Kamil Tekiela 2023-05-03 14:15:37 +01:00
parent 23c536099d
commit 2400dde8c1
4 changed files with 23 additions and 137 deletions

View File

@ -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<array{x: float, y: float}> $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<array{x: float, y: float}> $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<array{x: float, y: float}> $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<array{x: float, y: float}> $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;
}

View File

@ -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\\<int, array\\{x\\: float, y\\: float\\}\\>, 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\\<int, array\\{x\\: float, y\\: float\\}\\>, 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\\<int, array\\{x\\: float, y\\: float\\}\\>, 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
-

View File

@ -6627,110 +6627,17 @@
<ArgumentTypeCoercion>
<code>$pointsArr</code>
</ArgumentTypeCoercion>
<MixedArgument>
<code>($y1 - $y0) ** 2 + ($x0 - $x1) ** 2</code>
</MixedArgument>
<MixedArrayAccess>
<code><![CDATA[$gisData[$index]['POLYGON']]]></code>
<code><![CDATA[$gisData[$index]['POLYGON'][$i]]]></code>
<code><![CDATA[$gisData[$index]['POLYGON'][$i]['no_of_points']]]></code>
<code><![CDATA[$gisData[$index]['POLYGON']['no_of_lines']]]></code>
<code><![CDATA[$p1['x']]]></code>
<code><![CDATA[$p1['x']]]></code>
<code><![CDATA[$p1['x']]]></code>
<code><![CDATA[$p1['x']]]></code>
<code><![CDATA[$p1['y']]]></code>
<code><![CDATA[$p1['y']]]></code>
<code><![CDATA[$p1['y']]]></code>
<code><![CDATA[$p1['y']]]></code>
<code><![CDATA[$p1['y']]]></code>
<code><![CDATA[$p2['x']]]></code>
<code><![CDATA[$p2['x']]]></code>
<code><![CDATA[$p2['x']]]></code>
<code><![CDATA[$p2['y']]]></code>
<code><![CDATA[$p2['y']]]></code>
<code><![CDATA[$p2['y']]]></code>
<code><![CDATA[$p2['y']]]></code>
<code><![CDATA[$polygon[$last]['x']]]></code>
<code><![CDATA[$polygon[$last]['y']]]></code>
<code><![CDATA[$polygon[0]['x']]]></code>
<code><![CDATA[$polygon[0]['y']]]></code>
<code><![CDATA[$ring[$i + 1]['x']]]></code>
<code><![CDATA[$ring[$i + 1]['y']]]></code>
<code><![CDATA[$ring[$i + 1]['y']]]></code>
<code><![CDATA[$ring[$i]['x']]]></code>
<code><![CDATA[$ring[$i]['x']]]></code>
<code><![CDATA[$ring[$i]['y']]]></code>
<code><![CDATA[$ring[$i]['y']]]></code>
<code><![CDATA[$ring[$i]['y']]]></code>
<code><![CDATA[$ring[$j]['x']]]></code>
<code><![CDATA[$ring[$j]['y']]]></code>
<code><![CDATA[$ring[$last]['x']]]></code>
<code><![CDATA[$ring[$last]['y']]]></code>
<code><![CDATA[$ring[0]['x']]]></code>
<code><![CDATA[$ring[0]['y']]]></code>
</MixedArrayAccess>
<MixedAssignment>
<code>$area</code>
<code>$area</code>
<code>$area</code>
<code>$noOfLines</code>
<code>$noOfPoints</code>
<code>$p1</code>
<code>$p1</code>
<code>$p1</code>
<code>$p1</code>
<code>$p1</code>
<code>$p2</code>
<code><![CDATA[$pointA['x']]]></code>
<code><![CDATA[$pointA['y']]]></code>
<code><![CDATA[$pointB['x']]]></code>
<code><![CDATA[$pointB['y']]]></code>
<code>$x0</code>
<code>$x1</code>
<code>$x2</code>
<code>$xinters</code>
<code>$y0</code>
<code>$y1</code>
<code>$y2</code>
</MixedAssignment>
<MixedInferredReturnType>
<code>float</code>
</MixedInferredReturnType>
<MixedOperand>
<code>$area</code>
<code>$area</code>
<code>$epsilon * ($y1 - $y0)</code>
<code>$epsilon * ($y1 - $y0)</code>
<code><![CDATA[$p2['x']]]></code>
<code><![CDATA[$p2['y']]]></code>
<code><![CDATA[$pointA['x']]]></code>
<code><![CDATA[$pointB['x']]]></code>
<code><![CDATA[$point['y']]]></code>
<code><![CDATA[$ring[$i]['x']]]></code>
<code><![CDATA[$ring[$i]['x'] * $ring[$j]['y']]]></code>
<code><![CDATA[$ring[$i]['y']]]></code>
<code>$x0</code>
<code>$x0</code>
<code>$x0</code>
<code>$x0</code>
<code>$x2</code>
<code>$x2</code>
<code>$y0</code>
<code>$y1</code>
<code>$y1</code>
<code>$y1</code>
<code>$y1</code>
<code>$y1</code>
<code>$y1 - $y0</code>
<code>$y1 - $y0</code>
<code>$y2</code>
<code>$y2</code>
<code><![CDATA[($pointA['x'] - $x2) * ($x0 - $x1)]]></code>
<code><![CDATA[($pointB['x'] - $x2) * ($x0 - $x1)]]></code>
<code><![CDATA[($point['y'] - $p1['y'])
* ($p2['x'] - $p1['x'])]]></code>
<code>($y1 - $y0) ** 2</code>
<code><![CDATA[isset($gisData[$index]['POLYGON'][$i][$j]['x'])
&& trim((string) $gisData[$index]['POLYGON'][$i][$j]['x']) != ''
? $gisData[$index]['POLYGON'][$i][$j]['x'] : $empty]]></code>
@ -6738,31 +6645,10 @@
&& trim((string) $gisData[$index]['POLYGON'][$i][$j]['y']) != ''
? $gisData[$index]['POLYGON'][$i][$j]['y'] : $empty]]></code>
</MixedOperand>
<MixedReturnStatement>
<code>$area</code>
</MixedReturnStatement>
<PossiblyFalseArgument>
<code>$black</code>
<code>$fillColor</code>
</PossiblyFalseArgument>
<PossiblyNullOperand>
<code>$x1</code>
<code>$x1</code>
<code>$x1</code>
<code>$x1</code>
<code>$y0</code>
<code>$y0</code>
<code>$y0</code>
<code>$y0</code>
<code>$y0</code>
<code>$y0</code>
<code>$y1</code>
<code>$y1</code>
<code>$y1</code>
<code>$y1</code>
<code>$y1</code>
<code>$y1</code>
</PossiblyNullOperand>
<RedundantPropertyInitializationCheck>
<code>isset(self::$instance)</code>
</RedundantPropertyInitializationCheck>

View File

@ -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<array{x: float, y: float}> $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<array{mixed[], float}>
* @return list<array{non-empty-list<array{x: float, y: float}>, 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<array{x: float, y: float}> $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<array{mixed[], mixed[], bool}>
* @return array<array{array{x: float, y: float}, non-empty-list<array{x: float, y: float}>, 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<array{x: float, y: float}> $ring array of points forming the ring
*
* @dataProvider providerForTestGetPointOnSurface
*/
@ -417,7 +417,7 @@ class GisPolygonTest extends GisGeomTestCase
/**
* test case for isOuterRing() method
*
* @param array<array<string, int>> $ring coordinates of the points in a ring
* @param non-empty-list<array{x: float, y: float}> $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<array{array<array<string, int>>}>
* @return array<array{non-empty-list<array{x: float, y: float}>}>
*/
public static function providerForIsOuterRing(): array
{