1--TEST-- 2Bug #37811 (define not using toString on objects) 3--FILE-- 4<?php 5 6class TestClass 7{ 8 function __toString() 9 { 10 return "Foo"; 11 } 12} 13 14define("Bar", new TestClass); 15var_dump(Bar); 16 17try { 18 define("Baz", new stdClass); 19} catch (TypeError $exception) { 20 echo $exception->getMessage() . "\n"; 21} 22 23try { 24 var_dump(Baz); 25} catch (Error $exception) { 26 echo $exception->getMessage() . "\n"; 27} 28 29?> 30--EXPECT-- 31string(3) "Foo" 32define(): Argument #2 ($value) cannot be an object, stdClass given 33Undefined constant "Baz" 34