yii2
yii2 copied to clipboard
`VarDumper::exportClosure()` not support arrow functions
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 |
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.
@samdark bad idea - "php": "^7.4|^8.0"
I haven't said that the library should be used. I've said there are interesting ideas there.
@samdark why not https://github.com/jeremeamia/super_closure or https://opis.io/closure/3.x/ ?
- SuperClosure is not maintained anymore.
- 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.
- 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).