[php-src] Issue #8323: Declaring __toString() stops class hoisting in CLI apps

From: Date: Fri, 08 Apr 2022 04:02:48 +0000
Subject: [php-src] Issue #8323: Declaring __toString() stops class hoisting in CLI apps
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-240786@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8323 Author: dansmill ### Description The following code: ```php #!/usr/bin/env php <?php var_dump(in_array('A', get_declared_classes())); var_dump(in_array('B', get_declared_classes())); class A {} class B { public function __toString() {} } var_dump(in_array('A', get_declared_classes())); var_dump(in_array('B', get_declared_classes())); ``` Resulted in this output from PHP 8: ``` bool(true) bool(false) bool(true) bool(true) ``` However in PHP 7 I get: ``` bool(true) bool(true) bool(true) bool(true) ``` In a PHP 8 CLI app it seems declaring __toString() in a class causes it to not be hoisted. ### PHP Version PHP 8.0.15 ### Operating System Rocky Linux release 8.4

« previous php.bugs (#240786) next »