Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

Psr incompatibility in AbstractTransport Uri handling #1

Closed
kaiwa opened this issue Aug 6, 2015 · 3 comments
Closed

Psr incompatibility in AbstractTransport Uri handling #1

kaiwa opened this issue Aug 6, 2015 · 3 comments

Comments

@kaiwa
Copy link

kaiwa commented Aug 6, 2015

Hi,

NULL is not allowed as argument to UriInterface::withPath(), UriInterface::withQuery() and UriInterface::withFragment() according to https://github.com/php-fig/http-message/blob/master/src/UriInterface.php and implemented in AbstractTransport.php:

        $uri = $request->getUri()
            ->withPath(null)
            ->withQuery(null)
            ->withFragment(null);

I noticed this actually breaks when trying to send a RequestInterface implementation created with guzzlehttp/psr7 via your HttpClient, because they are checking the argument with is_string() inside their Uri implementation. https://github.com/guzzle/psr7/blob/master/src/Uri.php#L383

@kaiwa kaiwa changed the title Psr incompatibility in AbstractTransport Psr incompatibility in AbstractTransport Uri handling Aug 6, 2015
@asika32764
Copy link
Owner

I'm not sure. See withHost() in Guzzle and phly

https://github.com/guzzle/psr7/blob/master/src/Uri.php#L357

https://github.com/phly/http/blob/master/src/Uri.php

And PSR interface: https://github.com/php-fig/http-message/blob/master/src/UriInterface.php#L221

I think the is_string() condition was implemented by the author of phly, and guzzle forked it.

Some of the params in PSR interface are string|null but some are only string, and the docblock did not say NULL is not allowed.

I guess it is a fuzzy zone that PSR did not defined clearly. But I'll still add the is_string() condition to make my package compatibility to Guzzle.

Thank you for reporting it.

@asika32764
Copy link
Owner

Also, see withFragment() in phly
https://github.com/phly/http/blob/master/src/Uri.php#L368

https://github.com/phly/http/blob/master/src/Uri.php#L565

You will notice that NULL is allowed in phly Uri::withFragment(), so I think the is_string condition in withPath() and withQuery() is a misunderstand of Psr7.

@kaiwa
Copy link
Author

kaiwa commented Aug 7, 2015

Thank you for your quick reply, let's see what they're saying over at zendframework/zend-diactoros.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants