diff --git a/composer.json b/composer.json index 3d3264b..a057af5 100644 --- a/composer.json +++ b/composer.json @@ -18,8 +18,7 @@ "php": "^8.1" }, "require-dev": { - "phpunit/phpunit": "^10.5.16", - "symfony/deprecation-contracts": "^3.0" + "phpunit/phpunit": "^10.5.16" }, "autoload": { "psr-0": { diff --git a/lib/LongitudeOne/Geo/WKB/Parser.php b/lib/LongitudeOne/Geo/WKB/Parser.php index 911d4e2..81f152d 100644 --- a/lib/LongitudeOne/Geo/WKB/Parser.php +++ b/lib/LongitudeOne/Geo/WKB/Parser.php @@ -70,55 +70,27 @@ class Parser private int $type; /** - * @param string $input - * * @throws UnexpectedValueException */ - public function __construct($input = null) + public function __construct(?string $input = null) { $this->reader = new Reader(); if (null !== $input) { - if (!is_string($input)) { - trigger_deprecation( - 'longitudeone/geo-wkb-parser', - '2.1', - sprintf('Argument 1 passed to __construct() must be of the type string, %s given, called in %s on line %d', - gettype($input), - __FILE__, - __LINE__ - ) - ); - } - - $this->reader->load((string) $input); + $this->reader->load($input); } } /** * Parse input data. * - * @param string $input - * * @return array{type:string, srid: ?int, value: (float|int)[]|(float|int)[][]|(float|int)[][][]|(float|int)[][][][]|(float|int)[][][][][]|array{type: string, value:(float|int)[][]}[]|array{type: string, value:(float|int)[][]|array{type: string, value:(float|int)[][]}[]}[]|array{type: string, value:(float|int)[][][]|array{type: string, value:(float|int)[][]|array{type: string, value:(float|int)[][]}[]}[]}[]|array{type: string, value:(float|int)[][][]}[]|array{type:string, value:(float|int)[]|(float|int)[][]|(float|int)[][][]|(float|int)[][][][]|(float|int)[][][][][]|array{type: string, value:(float|int)[][]}[]|array{type: string, value:(float|int)[][]|array{type: string, value:(float|int)[][]}[]}[]|array{type: string, value:(float|int)[][][]|array{type: string, value:(float|int)[][]|array{type: string, value:(float|int)[][]}[]}[]}[]|array{type: string, value:(float|int)[][][]}[]}[], dimension: ?string} * * @throws ExceptionInterface */ - public function parse($input = null): array + public function parse(?string $input = null): array { if (null !== $input) { - if (!is_string($input)) { - trigger_deprecation( - 'longitudeone/geo-wkb-parser', - '2.1', - sprintf('Argument 1 passed to parse() must be of the type string, %s given, called in %s on line %d', - gettype($input), - __FILE__, - __LINE__ - ) - ); - } - $this->reader->load((string) $input); } diff --git a/lib/LongitudeOne/Geo/WKB/Reader.php b/lib/LongitudeOne/Geo/WKB/Reader.php index afe2af1..07a80c4 100644 --- a/lib/LongitudeOne/Geo/WKB/Reader.php +++ b/lib/LongitudeOne/Geo/WKB/Reader.php @@ -41,24 +41,12 @@ class Reader private int $previous = 0; /** - * @param string $input - * * @throws UnexpectedValueException */ - public function __construct($input = null) + public function __construct(?string $input = null) { if (null !== $input) { - if (!is_string($input)) { - trigger_deprecation( - 'longitudeone/geo-wkb-parser', - '2.1', - 'Argument 1 passed to __construct() must be of the type string, %s given, called in %s on line %d', - gettype($input), - __FILE__, - __LINE__ - ); - } - $this->load((string) $input); + $this->load($input); } } @@ -114,42 +102,6 @@ public function readByteOrder(): int return $this->byteOrder = $byteOrder; } - /** - * @throws UnexpectedValueException - * @throws RangeException - * - * @deprecated use readFloat() - */ - public function readDouble(): float - { - trigger_deprecation( - 'longitudeone/geo-wkb-parser', - '1.0', - 'Method readDouble is deprecated, use readFloat instead.' - ); - - return $this->readFloat(); - } - - /** - * @return float[] - * - * @throws RangeException - * @throws UnexpectedValueException - * - * @deprecated use readFloats() - */ - public function readDoubles(int $count): array - { - trigger_deprecation( - 'longitudeone/geo-wkb-parser', - '1.0', - 'Method readDoubles is deprecated, use readFloats instead.' - ); - - return $this->readFloats($count); - } - /** * @throws RangeException * @throws UnexpectedValueException diff --git a/quality/php-mess-detector/codeclimate-ruleset.xml b/quality/php-mess-detector/codeclimate-ruleset.xml index 4827d74..6d98f3e 100644 --- a/quality/php-mess-detector/codeclimate-ruleset.xml +++ b/quality/php-mess-detector/codeclimate-ruleset.xml @@ -24,8 +24,8 @@ - - + + diff --git a/quality/php-mess-detector/ruleset.xml b/quality/php-mess-detector/ruleset.xml index 6682659..1742e32 100644 --- a/quality/php-mess-detector/ruleset.xml +++ b/quality/php-mess-detector/ruleset.xml @@ -18,8 +18,8 @@ - - + + diff --git a/quality/php-stan/phpstan-baseline.neon b/quality/php-stan/phpstan-baseline.neon index 92c454d..30a4916 100644 --- a/quality/php-stan/phpstan-baseline.neon +++ b/quality/php-stan/phpstan-baseline.neon @@ -9,13 +9,3 @@ parameters: 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 - - - - message: "#^Parameter \\#1 \\$input of method LongitudeOne\\\\Geo\\\\WKB\\\\Parser\\:\\:parse\\(\\) expects string\\|null, float\\|string given\\.$#" - count: 1 - path: ../../tests/LongitudeOne/Geo/WKB/Tests/ParserTest.php diff --git a/tests/LongitudeOne/Geo/WKB/Tests/ParserTest.php b/tests/LongitudeOne/Geo/WKB/Tests/ParserTest.php index 14f4453..50f6e33 100644 --- a/tests/LongitudeOne/Geo/WKB/Tests/ParserTest.php +++ b/tests/LongitudeOne/Geo/WKB/Tests/ParserTest.php @@ -41,7 +41,7 @@ public function tearDown(): void } /** - * @return \Generator, message:string}, null, void> + * @return \Generator, message:string}, null, void> */ public static function badBinaryData(): \Generator { @@ -55,11 +55,6 @@ 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'; @@ -4190,8 +4185,10 @@ public static function wkbGeometryType(): \Generator * @param class-string $exception * * @dataProvider badBinaryData + * + * @throws ExceptionInterface */ - public function testBadBinaryData(string|float $value, string $exception, string $message): void + public function testBadBinaryData(string $value, string $exception, string $message): void { self::expectException($exception); self::expectMessage($message); @@ -4206,7 +4203,7 @@ public function testBadBinaryData(string|float $value, string $exception, string * * @dataProvider badBinaryData */ - public function testBadBinaryDataWithPreparedParser(string|float $value, string $exception, string $message): void + public function testBadBinaryDataWithPreparedParser(string $value, string $exception, string $message): void { self::expectException($exception); self::expectMessage($message); diff --git a/tests/LongitudeOne/Geo/WKB/Tests/ReaderTest.php b/tests/LongitudeOne/Geo/WKB/Tests/ReaderTest.php index c983e9f..59fb8aa 100644 --- a/tests/LongitudeOne/Geo/WKB/Tests/ReaderTest.php +++ b/tests/LongitudeOne/Geo/WKB/Tests/ReaderTest.php @@ -214,33 +214,6 @@ public function testBad(?string $value, array $methods, string $exception, strin } } - public function testDeprecation(): void - { - $reader = new Reader(); - - $value = '0040411D70A3D70A3D'; - $value = pack('H*', $value); - - $reader->load($value); - - $reader->readByteOrder(); - - $result = $reader->readDouble(); - - self::assertEquals(34.23, $result); - - $value = '0040411D70A3D70A3D40411D70A3D70A3D'; - $value = pack('H*', $value); - - $reader->load($value); - - $reader->readByteOrder(); - - $result = $reader->readDoubles(2); - - $this->assertEquals([34.23, 34.23], $result); - } - /** * @param array{0:string, 1:float|int|null, 2:array|int|float|null}[] $methods *