Skip to content

Commit 37521b6

Browse files
committed
[HttpFoundation] forced Response content to be string
1 parent b2b0c4a commit 37521b6

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Symfony/Component/HttpFoundation/Response.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ public function setContent($content)
170170
if (!is_string($content) && !is_numeric($content) && !is_callable(array($content, '__toString'))) {
171171
throw new \UnexpectedValueException('The Response content must be a string or object implementing __toString(), "'.gettype($content).'" given.');
172172
}
173-
$this->content = $content;
173+
174+
$this->content = (string) $content;
174175
}
175176

176177
/**

tests/Symfony/Tests/Component/HttpFoundation/ResponseTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ public function testSetContent($content)
431431
{
432432
$response = new Response();
433433
$response->setContent($content);
434-
$this->assertEquals($content, $response->getContent());
434+
$this->assertEquals((string) $content, $response->getContent());
435435
}
436436

437437
/**

0 commit comments

Comments
 (0)