Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSR-2 #70

Closed
kelfink opened this issue Aug 15, 2013 · 3 comments
Closed

PSR-2 #70

kelfink opened this issue Aug 15, 2013 · 3 comments

Comments

@kelfink
Copy link

kelfink commented Aug 15, 2013

Does anyone have a PrettyPrinter compatible with PSR-2 ? Just in case...

@tcopestake
Copy link

I've just finished an early version of one, which you can find at https://github.com/tcopestake/PHP-Parser-PSR-2-pretty-printer

There may be non-PSR-2 code generated by the default pretty printer that I'm unaware of and therefore haven't patched. If that's the case, feel free to let me know or add it in yourself.

@kelfink
Copy link
Author

kelfink commented Aug 19, 2013

Thanks! I have been working on one as well. You may be further along than me, but I'll contribute back when I can. The existing printers and your, for instance like to mash long lines onto one line. I'm hoping to print onto a maximum of 120 chars and indent as required. It would be nice if the legal line feeds in existing code could be retained. That may be asking a lot.

@nikic
Copy link
Owner

nikic commented Aug 23, 2013

I won't be adding a PSR-2 printer to the main project (yet), because I don't think that it would work well enough right now. The current pretty printer is only supposed to output executable and human-readable/debuggable code, but doesn't really care about the formatting.

Printing code in PSR-2 would require a bit of a different approach to be able to enforce line limits (as @kelfink mentioned). Right now the indentation of the current line is not known by the printing methods as it's only added after they have already finished (so you don't know how long the line actually is).

Also I think that it wouldn't be particularly useful without the ability to retain some of the original formatting (issue #41).

@nikic nikic closed this as completed Aug 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants