bermudaphp/var-export

v1.2.2 2024-05-27 18:06 UTC

This package is auto-updated.

Last update: 2024-10-30 14:11:38 UTC


README

composer require bermudaphp/var-export

Usage

$closure = static function (string $filename) use ($fileReader): string {
    return $fileReader->read($filename);
});

dd(export_closure($closure));

^ """
static function(string $filename) use($fileReader): string {
    return $fileReader->read($filename);
}

$closure = static fn(): string => __FILE__ ;

dd(export_closure($closure));

^ "static fn(): string => 'path/to/closure/filename'"

class A {
    public function call()
    {
        $closure = fn(): string => self::class ;
        dd(export_closure($closure));
    }
}

^ "fn(): string => \A::class"