Last active
May 10, 2021 13:34
-
-
Save drupol/11a0e396722a80a72e674d2cb6f22659 to your computer and use it in GitHub Desktop.
Simple example of nikic/php-parser importer in loophp/phptree
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
include __DIR__ . '/vendor/autoload.php'; | |
use drupol\launcher\Launcher; | |
use loophp\phptree\Exporter\Image; | |
use PhpParser\ParserFactory; | |
use loophp\phptree\Importer\NikicPhpParserImporter; | |
$code = file_get_contents(__DIR__ . '/src/Cart.php'); | |
$parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7); | |
$tree = (new NikicPhpParserImporter())->import($parser->parse($code)); | |
$exporter = new Image(); | |
$imagePath = $exporter->setFormat('png')->export($tree); | |
Launcher::open($imagePath); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello !
Something like this?