slimphp / PHP-View

A Simple PHP Renderer for Slim 3 & 4 (or any other PSR-7 project)
MIT License
264 stars 60 forks source link

PhpRenderer::render() manipulates input response #46

Closed futape closed 5 years ago

futape commented 5 years ago

Haven't tested it, but to me it seems as if the render method work on the input response itself instead of cloning it (as described here).

Response objects are immutable which means that the call to render() won’t update the response object; instead it will return us a new object which is why it needs to be captured like this. This is always true when you operate on the response object.

l0gicgate commented 5 years ago

It's manipulating the body of the response, which is just an underlying stream that isn't immutable.

$response->getBody()->write($output);