php-src/Zend/tests/bug37811.phpt
Nikita Popov 53aed48e5d Allow objects in define()
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.
2021-07-15 10:09:56 +02:00

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