Giter Club home page Giter Club logo

Comments (3)

tcopestake avatar tcopestake commented on May 9, 2024

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.

from php-parser.

kelfink avatar kelfink commented on May 9, 2024

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.

from php-parser.

nikic avatar nikic commented on May 9, 2024

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

from php-parser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.