yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.24k stars 6.91k forks source link

`VarDumper::exportClosure()` not support arrow functions #18952

Open WinterSilence opened 2 years ago

WinterSilence commented 2 years ago

VarDumper::exportClosure() not support arrow functions:

$f = fn($x) => $x + 10;
VarDumper::export($f);

Additional info

Q A
Yii version 2.0.43
PHP version 7.4
Operating system any
samdark commented 2 years ago

https://github.com/yiisoft/var-dumper/blob/master/src/ClosureExporter.php from Yii 3 could be useful for ideas on how to fix that. It supports short closures.

WinterSilence commented 2 years ago

@samdark bad idea - "php": "^7.4|^8.0"

samdark commented 2 years ago

I haven't said that the library should be used. I've said there are interesting ideas there.

WinterSilence commented 2 years ago

@samdark why not https://github.com/jeremeamia/super_closure or https://opis.io/closure/3.x/ ?

samdark commented 2 years ago
  1. SuperClosure is not maintained anymore.
  2. We've initially used Opis for Yii 3 but then found that it doesn't work for a few edge cases we had and that the 4.x version will require FFI.
  3. It is another dependency. We'd like to avoid it (especially considering that it's already implemented for Yii 3 and could be partially back-ported).