Bug #81224 [Opn->Ver]: Failed to load a class with '__toString' in required script

From: Date: Fri, 23 Jul 2021 08:51:02 +0000
Subject: Bug #81224 [Opn->Ver]: Failed to load a class with '__toString' in required script
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235288@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81224&edit=1 ID: 81224 Updated by: lufei@php.net Reported by: wxiaoguang at gmail dot com Summary: Failed to load a class with '__toString' in required script -Status: Open +Status: Verified Type: Bug Package: Scripting Engine problem Operating System: Debian PHP Version: 8.0.8 Block user comment: N Private report: N New Comment: see https://3v4l.org/CcIbq Previous Comments: ------------------------------------------------------------------------ [2021-07-05 15:46:58] wxiaoguang at gmail dot com Description: ------------ PHP 7 can run these scripts correctly. PHP 8 reports error if the class has a __toString method. Test script: --------------- a.php: <?php require 'b.php'; class C { // with this __toString method, 'b.php' can not find clas C public function __toString() { return ''; } } function test() { return new C(); } ?> b.php: <?php var_dump(test()); ?> Expected result: ---------------- Script can run without error. Actual result: -------------- PHP Fatal error: Uncaught Error: Class "C" not found in /home/test/a.php:12 Stack trace: #0 /home/test/b.php(2): test() #1 /home/test/a.php(2): require('/home/test/b.ph...') #2 {main} thrown in /home/test/a.php on line 12 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=81224&edit=1

« previous php.bugs (#235288) next »