Agree with Woody, although ResponseFactoryInterface should've added headers 
as an argument.
Body and headers is what a http message is really constituted of.

Den måndag 12 november 2018 kl. 13:05:53 UTC+1 skrev Woody Gilk:
>
> I don't see what the problem with this code is. It's clear and easily 
> understandable.
>
> As has been discussed many times, there is very little performance penalty 
> for lots of clones, especially in PHP >7.
> --
> Woody Gilk
> https://shadowhand.me
>
>
> On Fri, Nov 9, 2018 at 3:47 AM Rasmus Schultz <[email protected] 
> <javascript:>> wrote:
>
>> 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] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/php-fig/2274cea2-1f46-404f-bb60-1b376d005d71%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/php-fig/2274cea2-1f46-404f-bb60-1b376d005d71%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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/189c70c7-c074-419b-a762-d0d2ddb97f23%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to