Closed steffenbrand closed 6 years ago
@steffenbrand Are your sure? Please look at:
Ah, sure php://memory
is a string as well.
Maybe removing the string is not the right suggestion ;) But I think an additional hint would help that the string must actually be a stream identifier, maybe with a link to http://php.net/manual/de/wrappers.php.php.
To be honest, it actually says must be a string stream identifier or stream resource
in the exception, but I didn't get the meaning of string stream identifier
at first.
My expectation was, that I could use it like new Stream('my string that this class is going to wrap in some kind of I/O stream by itself.');
@steffenbrand If you are able to upgrade to version 2 (which, unless you are using the emitters or on pre-7.1 versions of PHP, is fully backwards compatible), you can use Zend\Diactoros\StreamFactory::createString()
to do what you suggest.
We'll definitely accept a patch that would clarify the constructor argument, however.
Thank you for the answer! I guess we can update to ZE 3.2 / Diactoros 2 and use the StreamFactory, as you suggested. :v:
If I come up with a clarifying sentence, I'll provide a PR.
Stream constructor says it accepts a string, but it doesn't. Providing a string results in an InvalidArgumentException. In my opinion, this is misleading.
Suggestion
Simply remove
string
from@param string|resource $stream
, because I have a feeling providing a simple string was never intended.Feel free to correct me ;)