Bug #81224 [NEW]: Failed to load a class with '__toString' in required script

From: Date: Mon, 05 Jul 2021 15:46:58 +0000
Subject: Bug #81224 [NEW]: Failed to load a class with '__toString' in required script
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234804@lists.php.net to get a copy of this message
From: wxiaoguang at gmail dot com Operating system: Debian PHP version: 8.0.8 Package: Scripting Engine problem Bug Type: Bug Bug description:Failed to load a class with '__toString' in required script 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 bug report at https://bugs.php.net/bug.php?id=81224&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=81224&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=81224&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=81224&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=81224&r=needscript Try newer version: https://bugs.php.net/fix.php?id=81224&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=81224&r=support Expected behavior: https://bugs.php.net/fix.php?id=81224&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=81224&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=81224&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=81224&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=81224&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=81224&r=dst IIS Stability: https://bugs.php.net/fix.php?id=81224&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=81224&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=81224&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=81224&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=81224&r=mysqlcfg

« previous php.bugs (#234804) next »