|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-02-22 04:13 UTC] requinix@php.net
-Status: Open
+Status: Feedback
[2019-02-22 04:13 UTC] requinix@php.net
[2019-02-22 04:16 UTC] eric at ericstern dot com
-Status: Feedback
+Status: Open
[2019-02-22 04:16 UTC] eric at ericstern dot com
[2019-02-22 08:47 UTC] nikic@php.net
-Status: Open
+Status: Assigned
-Assigned To:
+Assigned To: nikic
[2019-02-22 09:15 UTC] nikic@php.net
[2019-02-22 09:15 UTC] nikic@php.net
-Status: Assigned
+Status: Closed
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 20:00:02 2025 UTC |
Description: ------------ When a closure returns an anonymous class that implements an interface is returned in a file that is require()d multiple times, subsequent return values have the interface information stripped. I discovered this behavior while writing unit tests around a configuration tool (asserting that the returned value implemented an interface) - the test would pass if it was the _first_ test to run, but fail otherwise. It would also pass if I ran the tests with process isolation enabled. The attached script is the simplest reproduce case I could come up with. Test script: --------------- // run.php <?php interface I {} require 'data.php'; // comment this line out to get the expected behavior $data = require 'data.php'; print_r(class_implements($data['I']())); // data.php <?php return [ 'I' => function() { return new class implements I {}; }, ]; Expected result: ---------------- $ php run.php Array ( [I] => I ) Actual result: -------------- $ php run.php Array ( )