Bug #72594 [NEW]: Calling an earlier instance of an included anonymous class crashes

From: Date: Thu, 14 Jul 2016 01:17:04 +0000
Subject: Bug #72594 [NEW]: Calling an earlier instance of an included anonymous class crashes
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202293@lists.php.net to get a copy of this message
From: php+bug at tubul dot net Operating system: Linux PHP version: 7.0.8 Package: Scripting Engine problem Bug Type: Bug Bug description:Calling an earlier instance of an included anonymous class crashes Description: ------------ 1) get an instance of an anonymous class returned from a included file 2) get another instance of the same class by including it again 3) have the second instance reference the first -> This gives a fatal error If in step 2) an exact copy of the file is included instead, the error doesn't happen. Leaving out the (never used) property of the class also prevents the error. PHP Version => 7.0.8 Configure Command => './configure' Server API => Command Line Interface Test script: --------------- <?php // test.php $oldFoo = require('foo.php'); $newFoo = require('foo.php'); // using a copy of foo.php here prevents the error $newFoo->bing($oldFoo); <?php // foo.php return new class{ public $bar; // comment out this line and there is no error public function bing($foo = null) { if ($foo) $foo->bing(); } }; Now run php test.php Expected result: ---------------- There should be no output Actual result: -------------- Fatal error: Uncaught Error: Call to undefined method class@anonymous::bing() in /home/richard/foo.php:6 Stack trace: #0 /home/richard/test.php(4): class@anonymous->bing(Object(class@anonymous)) #1 {main} thrown in /home/richard/foo.php on line 6 -- Edit bug report at https://bugs.php.net/bug.php?id=72594&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72594&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72594&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72594&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=72594&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=72594&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=72594&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=72594&r=needscript Try newer version: https://bugs.php.net/fix.php?id=72594&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=72594&r=support Expected behavior: https://bugs.php.net/fix.php?id=72594&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=72594&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=72594&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=72594&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72594&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=72594&r=dst IIS Stability: https://bugs.php.net/fix.php?id=72594&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=72594&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=72594&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=72594&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=72594&r=mysqlcfg

« previous php.bugs (#202293) next »