Re: RFC: Support Closures in constant expressions

From: Date: Wed, 30 Oct 2024 08:10:05 +0000
Subject: Re: RFC: Support Closures in constant expressions
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-125876@lists.php.net to get a copy of this message
Hi Am 2024-10-29 21:12, schrieb Valentin Udaltsov:
Will the first class callable syntax be supported?
#[Serialize\Custom(strtoupper(...))]
It is currently listed in the “Future Scope” section. Mainly, because the implementation does not *trivially* extend to first-class callables. When you have a regular Closure, everything you need to know is right inside the file. For first-class callables the target function might reside in a different file and already needs to be available. For static methods, the autoloader might need to be called. So first-class callables behave similarly to new-expressions, whereas Closures behave more like string literals or number literals. Best regards Tim Düsterhus

« previous php.internals (#125876) next »