Description
This is probably considered non-standard usage, but I stumbled over it by accident.
The following code:
<?php
$foo = new Test;
var_dump($foo);
class Test
{
public function __toString()
{
return '';
}
}
Resulted in this output:
PHP Fatal error: Uncaught Error: Class "Test" not found in /private/tmp/foo.php:3
Stack trace:
#0 {main}
thrown in /private/tmp/foo.php on line 3
Fatal error: Uncaught Error: Class "Test" not found in /private/tmp/foo.php:3
Stack trace:
#0 {main}
thrown in /private/tmp/foo.php on line 3
But I expected this output instead:
If you remove the __toString method from the class, the code functions as expected.
PHP Version
8.1.1
Operating System
No response