Skip to content

Commit

Permalink
Merge pull request #7 from longitude-one/deprecation-feature
Browse files Browse the repository at this point in the history
Because of improvements on doctrine/lexer:v3, parsing a float is now deprecated. Provide a string instead of a float.
  • Loading branch information
Alexandre-T authored Mar 18, 2024
2 parents e8393e7 + a5c9b8f commit 30a1377
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
8 changes: 8 additions & 0 deletions lib/LongitudeOne/Geo/String/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public function __construct($input = null)
{
$this->lexer = new Lexer();

if (is_float($input)) {
trigger_error('Since longitudeone/geo-parser 2.1: Passing a float to LongitudeOne\Geo\String\Parser::__construct() is deprecated. Use a string instead.', E_USER_DEPRECATED);
}

if (null !== $input) {
$this->input = (string) $input;
}
Expand All @@ -64,6 +68,10 @@ public function __construct($input = null)
*/
public function parse($input = null): float|int|array
{
if (is_float($input)) {
trigger_error('Since longitudeone/geo-parser 2.1: Passing a float to LongitudeOne\Geo\String\Parser::parse() is deprecated. Use a string instead.', E_USER_DEPRECATED);
}

if (null !== $input) {
$this->input = (string) $input;
}
Expand Down
4 changes: 2 additions & 2 deletions quality/php-mess-detector/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
</rule>
<rule ref="rulesets/codesize.xml/ExcessiveClassComplexity">
<properties>
<!-- Set the maximum complexity to 68, because of historical code -->
<property name="maximum" value="68" />
<!-- Set the maximum complexity to 69, because of historical code -->
<property name="maximum" value="69" />
</properties>
</rule>
<!-- Import the entire naming rule set -->
Expand Down
5 changes: 2 additions & 3 deletions tests/LongitudeOne/Geo/String/Tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public static function dataSourceGood(): \Generator
yield ['40°N', 40];
yield ['40°S', -40];
yield ['45.24', 45.24];
yield [45.24, 45.24];
yield ['45.24°', 45.24];
yield ['+45.24°', 45.24];
yield ['45.24° S', -45.24];
Expand Down Expand Up @@ -127,11 +126,11 @@ public function testBadValues(string|int|float $input, string $exception, string
}

/**
* @param int|float|int[]|float[] $expected
* @param int|float|float[]|int[] $expected
*
* @dataProvider dataSourceGood
*/
public function testGoodValues(string|int|float $input, $expected): void
public function testGoodValues(string|int|float $input, int|float|array $expected): void
{
$parser = new Parser($input);

Expand Down

0 comments on commit 30a1377

Please sign in to comment.