On Tue, Jul 17, 2018 at 10:51 AM Tomasz Darmetko <
isi...@gmail.com> wrote:
>
> I'm more concerned about the end users of the interface.
>
> If my application already implements URL value object with __toString, should I be able to pass it directly?
>
> If one implementation will accept it and other not, I won't be able to swap them. Or I will get nasty surprises after I do.
>
> I personally think we should accept all object implementing __toString as strings. After all, it improves interoperability.
>
> Either way IMO it should be clarified to avoid issues.
Accepting `string`, and knowing that `UriInterface` defines
`__toString()` explicitly, if you're worried about interop, all you
need to do is cast the argument to a string when passing it to the
factory:
$request = $factory->createRequest('GET', (string) $uri);
While this would mean creating a new `Uri` instance if you passed one,
it satisfies the interoperability concerns. Anything else is
duck-typing, and requires reflection to manage.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/php-fig/4e452879-2dbe-4bb4-8218-4d0f0729943f%40googlegroups.com.
--
Matthew Weier O'Phinney
mweiero...@gmail.com
https://mwop.net/