I know it's too late to bring up something like this, but... you don't 
notice until you actually start using it in real code.

I wrote this class that uses PSR-17 to marshall between ResponseInterface 
and JSON-serializable data:

https://gist.github.com/mindplay-dk/5fc5daa1cf5efd7d7ea2be99b1ec99bf#file-responsemarshaller-php-L40-L42

See the highlighted lines?

So, whenever you need to transfer headers from one object to another, 
currently, you have to loop over
every individual header and manually transfer them one at a time.

This has performance implications (cloning the request object for every 
individual header being copied)
but also leads to ugly, repetitive loops like the one highlighted in the 
example above.

Makes me wish we had an argument for $headers in the 
ResponseFactoryInterface method.

But also makes me wonder if this was actually an oversight in PSR-7 itself?

Like, why doesn't it have a withHeaders() method that lets you 
apply/replace all the headers?

I guess as always it's too late to notice these things as PSRs are 
immutable and non-versionable? :-/

- Rasmus

-- 
You received this message because you are subscribed to the Google Groups "PHP 
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/2274cea2-1f46-404f-bb60-1b376d005d71%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to