Skip to content
Discussion options

You must be logged in to vote

Hi Honza,
I love this crazy idea :)

I know this is a niche problem as every other project use twig so we'd have to write the rules ourselves

I disagree, there are many projects who use PHP templates and need to migrate too. It would be great addition to https://github.com/rectorphp/rector-symfony

The other way around would be very hard, as there is no easy to use Twig-AST parser.
But parsing PHP and dumping TWIG is easy. All you need is a custom printer - https://github.com/rectorphp/rector-src/blob/be530c5e2f56190f5fe1813ae4344cdaf3f75d7f/src/PhpParser/Printer/BetterStandardPrinter.php#L40

E.g. writing printer for Echo_:

echo $value;

that would dump a string:

{{ value }}

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@escopecz
Comment options

@TomasVotruba
Comment options

Answer selected by escopecz
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants