creof / geo-parser

Parser for geography coordinate strings
MIT License
61 stars 16 forks source link

Incompatible with doctrine/lexer 1.1.0 #15

Closed chrisnoden closed 5 years ago

chrisnoden commented 5 years ago

Updating project to use doctrine/lexer v1.1.0 causes an Exception:

preg_split() expects parameter 2 to be string, float given

  at vendor/doctrine/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php:255
  at preg_split('/([nesw\'",\\X])|((?:[0-9]+)(?:[\\.][0-9]+)?(?:e[+-]?[0-9]+)?)|\\s+/i', -0.33378, -1, 7)
     (vendor/doctrine/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php:255)
  at Doctrine\Common\Lexer\AbstractLexer->scan(-0.33378)
     (vendor/doctrine/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php:93)
  at Doctrine\Common\Lexer\AbstractLexer->setInput(-0.33378)
     (vendor/creof/geo-parser/lib/CrEOF/Geo/String/Parser.php:91)
  at CrEOF\Geo\String\Parser->parse()
     (vendor/creof/doctrine2-spatial/lib/CrEOF/Spatial/PHP/Types/AbstractPoint.php:70)
  at CrEOF\Spatial\PHP\Types\AbstractPoint->setX(-0.33378)
     (vendor/creof/doctrine2-spatial/lib/CrEOF/Spatial/PHP/Types/AbstractPoint.php:220)
  at CrEOF\Spatial\PHP\Types\AbstractPoint->construct(-0.33378, 51.75129, '4326')
  at call_user_func_array(array(object(Point), 'construct'), array(-0.33378, 51.75129, '4326'))
     (vendor/creof/doctrine2-spatial/lib/CrEOF/Spatial/PHP/Types/AbstractPoint.php:56)
  at CrEOF\Spatial\PHP\Types\AbstractPoint->__construct(array(-0.33378, 51.75129), '4326')
     (vendor/harness/geo-spatial/src/Geometry/GeoJson.php:69)

Can be resolved by downgrading to lexer 1.0.2

chrisnoden commented 5 years ago

Quick fix is to change line 91 of Parser.php to:

$this->lexer->setInput((string)$this->input);

Unable to update your tests because composer requirements are too general (PHPUnit is at 8.2.5 which meets your composer requirements but which is clearly incompatible, plus PHP 5.3.3 is no longer supported....)

bzis commented 5 years ago

Also in PHP 7.3.7 "\X" modifier causes an error. In 7.3.6 this regular expression works, but in 7.3.7 I get an error Warning: preg_split(): Compilation failed: escape sequence is invalid in character class at offset 10

PowerKiKi commented 5 years ago

@chrisnoden PHP requirement were updated to PHP 7.1+ in #14. You should be able to create a PR to fix your issue more easily now.

@bzis your issue has been fixed in #14 and released as 2.2.0.