yii2 icon indicating copy to clipboard operation
yii2 copied to clipboard

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

Open WinterSilence opened this issue 4 years ago • 5 comments

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

WinterSilence avatar Oct 15 '21 18:10 WinterSilence

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 avatar Oct 18 '21 13:10 samdark

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

WinterSilence avatar Oct 18 '21 14:10 WinterSilence

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

samdark avatar Oct 18 '21 16:10 samdark

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

WinterSilence avatar Oct 18 '21 16:10 WinterSilence

  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).

samdark avatar Oct 18 '21 20:10 samdark