mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
53aed48e5d
This was separately discussed in https://externals.io/message/114863, but also necessary for consistency now that https://wiki.php.net/rfc/new_in_initializers has landed. Closes GH-7149.
34 lines
504 B
PHP
34 lines
504 B
PHP
--TEST--
|
|
Bug #37811 (define not using toString on objects)
|
|
--FILE--
|
|
<?php
|
|
|
|
class TestClass
|
|
{
|
|
function __toString()
|
|
{
|
|
return "Foo";
|
|
}
|
|
}
|
|
|
|
define("Bar", new TestClass);
|
|
var_dump(Bar);
|
|
var_dump((string) Bar);
|
|
|
|
define("Baz", new stdClass);
|
|
var_dump(Baz);
|
|
try {
|
|
var_dump((string) Baz);
|
|
} catch (Error $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
object(TestClass)#1 (0) {
|
|
}
|
|
string(3) "Foo"
|
|
object(stdClass)#2 (0) {
|
|
}
|
|
Object of class stdClass could not be converted to string
|