Re: Automatically execute Closures returned from primary script

From: Date: Tue, 22 Sep 2026 15:29:35 +0000
Subject: Re: Automatically execute Closures returned from primary script
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-132593@lists.php.net to get a copy of this message
Hi On 2026-09-22 17:21, Seifeddine Gmati wrote:
Just to confirm my understanding: when the file is included from another script, the closure would still be returned without being executed, so the following would continue to work as it does today:
$callable = require 'script_file.php';
$callable();
Is that correct?
Yes. The only change is that the PHP CLI SAPI will make use of the return value of the main script rather than ignoring it. No changes for any other SAPI and no changes to include/require. Please see the tests in the PR, and in particular sapi/cli/tests/primary_script_closure_004.phpt. Best regards Tim Düsterhus

« previous php.internals (#132593) next »