|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-07-14 02:02 UTC] requinix@php.net
-Summary: Calling an earlier instance of an
included anonymous class crashes
+Summary: Calling an earlier instance of an
included anonymous class fatals with undefined method
-Status: Open
+Status: Verified
-Package: Scripting Engine problem
+Package: Reproducible crash
-Operating System: Linux
+Operating System: Linux, Windows
[2016-07-14 02:02 UTC] requinix@php.net
[2016-07-14 02:02 UTC] requinix@php.net
-Summary: Calling an earlier instance of an included anonymous
class fatals with undefined
+Summary: Calling an earlier instance of an included anonymous
class fatals
[2016-07-14 05:38 UTC] laruence@php.net
[2016-07-14 05:38 UTC] laruence@php.net
-Status: Verified
+Status: Closed
[2016-07-20 11:29 UTC] davey@php.net
[2016-10-17 10:11 UTC] bwoebi@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 21:00:02 2025 UTC |
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