Skip to content

Commit

Permalink
Merge pull request #3 from longitude-one/issue-2
Browse files Browse the repository at this point in the history
Issue 2
  • Loading branch information
Alexandre-T authored Apr 8, 2024
2 parents 6bfc7b3 + 460aa23 commit 8f2b4f1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/LongitudeOne/Geo/WKB/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function __construct($input = null)
trigger_error('Since longitudeone/geo-wkb-parser 1.0: using non-string parameter for Reader constructor deprecated.', E_USER_DEPRECATED);
}

$this->reader->load($input);
$this->reader->load((string) $input);
}
}

Expand All @@ -99,7 +99,7 @@ public function __construct($input = null)
public function parse($input = null): array
{
if (null !== $input) {
$this->reader->load($input);
$this->reader->load((string) $input);
}

return $this->readGeometry();
Expand Down
8 changes: 6 additions & 2 deletions quality/php-stan/phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
parameters:
ignoreErrors:
# readGeometry is recursive because of GeometryCollection.
-
message: "#^Method LongitudeOne\\\\Geo\\\\WKB\\\\Parser\\:\\:geometryCollection\\(\\) should return array\\<array\\{type\\: string, value\\: array\\<array\\<array\\<array\\<array\\<array\\<array\\<array\\<float\\|int\\>\\>\\|float\\|int\\|string\\>\\|float\\|int\\>\\|float\\|int\\|string\\>\\|float\\|int\\>\\|float\\|int\\|string\\>\\|float\\|int\\>\\}\\> but returns array\\<int\\<0, max\\>, array\\{type\\: string, value\\: array\\<array\\<array\\<array\\<array\\<array\\<array\\<array\\<array\\<array\\<float\\|int\\>\\>\\|float\\|int\\|string\\>\\|float\\|int\\>\\|float\\|int\\|string\\>\\|float\\|int\\>\\|float\\|int\\|string\\>\\|float\\|int\\>\\|float\\|int\\|string\\>\\|float\\|int\\>\\}\\>\\.$#"
count: 1
path: ../../lib/LongitudeOne/Geo/WKB/Parser.php
# Type cannot be null at this step

-
message: "#^Parameter \\#1 \\$type of method LongitudeOne\\\\Geo\\\\WKB\\\\Parser\\:\\:getTypeName\\(\\) expects int, int\\|null given\\.$#"
count: 1
path: ../../lib/LongitudeOne/Geo/WKB/Parser.php

-
message: "#^Parameter \\#1 \\$input of class LongitudeOne\\\\Geo\\\\WKB\\\\Parser constructor expects string\\|null, float\\|string given\\.$#"
count: 1
path: ../../tests/LongitudeOne/Geo/WKB/Tests/ParserTest.php
9 changes: 7 additions & 2 deletions tests/LongitudeOne/Geo/WKB/Tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
class ParserTest extends TestCase
{
/**
* @return \Generator<string, array{value:string, exception:class-string<ExceptionInterface>, message:string}, null, void>
* @return \Generator<string, array{value:string|float, exception:class-string<ExceptionInterface>, message:string}, null, void>
*/
public static function badBinaryData(): \Generator
{
Expand All @@ -41,6 +41,11 @@ public static function badBinaryData(): \Generator
'exception' => UnexpectedValueException::class,
'message' => 'Unsupported WKB type "21" (0x15) at byte 1',
];
yield 'badPacketType' => [
'value' => 0x0101000000000000000000F03F0000000000000040, // POINT(1 2)
'exception' => UnexpectedValueException::class,
'message' => 'Invalid byte order "16" at byte 0',
];

// Short NDR POINT
$message = 'Type d: not enough input values, need 8 values but only 4 were provided';
Expand Down Expand Up @@ -4172,7 +4177,7 @@ public static function wkbGeometryType(): \Generator
*
* @dataProvider badBinaryData
*/
public function testBadBinaryData(string $value, string $exception, string $message): void
public function testBadBinaryData(string|float $value, string $exception, string $message): void
{
self::expectException($exception);

Expand Down

0 comments on commit 8f2b4f1

Please sign in to comment.