2016-10-07 12:55 GMT+02:00 Yasuo Ohgaki <yohg...@ohgaki.net>: > Hi Michal, > > On Fri, Oct 7, 2016 at 6:47 PM, Michał Brzuchalski > <mic...@brzuchalski.com> wrote: > > 2016-10-07 11:21 GMT+02:00 Michał Brzuchalski <mic...@brzuchalski.com>: > > > >> How about complete rewrite with OOP? It could be implemented using > Objects > >> like DateTime does. > >> I've got working implementation in userland > https://github.com/madkom/uri it > >> maybe not be finished yet but supports parsing URI with IPv4, IPv6 and > >> Hostnames. > >> It was also going to parse query arguments from URI depending on how to > >> parse multiple arguments: > >> * some languages parses `?arg1=1&arg1=2` as an array, PHP parses only > last, > >> * `?arg1[]=1&arg1=3` some parses adding element 3 to "arg1" array some > >> replaces) > >> > >> This implementation also supports UriTemplates (" > >> http://localhost/{module}/action") and UriReferences > >> ("/some/reference?arg1=2#fragment"). > >> > > > > My proposed impl supports parsing and building, I can see there is > possible > > to move functionalities from few global functions into one OO written > > package. > > This is about internal C module implementation. re2c is one of the > best way to write manageable BNF definition implementation. We use > re2c many places already. Therefore, re2c implementation is the way to > go. IMHO. > > Yes I understand that implementation in C would be different, all I wanted to point is nice OO implementation with type hints and return types so there is no `mixed` return type value used like in parse_url() and there are always classes for each component of URL not only string and you don't know what to do with it Also avoiding mixed return type allows static code analyzers to detect errors in code and all those OO benefits.
> Regards, > > -- > Yasuo Ohgaki > yohg...@ohgaki.net > -- regards / pozdrawiam, -- Michał Brzuchalski brzuchalski.com