diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatter.php b/src/Symfony/Component/Console/Formatter/OutputFormatter.php
index 90b1970f4b..a053ac6ba0 100644
--- a/src/Symfony/Component/Console/Formatter/OutputFormatter.php
+++ b/src/Symfony/Component/Console/Formatter/OutputFormatter.php
@@ -142,6 +142,7 @@ class OutputFormatter implements OutputFormatterInterface
*/
public function format($message)
{
+ $message = (string) $message;
$offset = 0;
$output = '';
$tagRegex = '[a-z][a-z0-9_=;-]*';
diff --git a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php
index 3542680a88..03b789402b 100644
--- a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php
+++ b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php
@@ -166,6 +166,14 @@ class OutputFormatterTest extends \PHPUnit_Framework_TestCase
$this->assertEquals("\033[37;41msome error\033[0m".$long, $formatter->format('some error'.$long));
}
+ public function testFormatToStringObject()
+ {
+ $formatter = new OutputFormatter(false);
+ $this->assertEquals(
+ 'some info', $formatter->format(new TableCell())
+ );
+ }
+
public function testNotDecoratedFormatter()
{
$formatter = new OutputFormatter(false);
@@ -255,3 +263,11 @@ EOF
));
}
}
+
+class TableCell
+{
+ public function __toString()
+ {
+ return 'some info';
+ }
+}