2017 © Pedro Peláez
 

application phormat

PHP source formatter with a single style - essentially godoc for PHP

image

nochso/phormat

PHP source formatter with a single style - essentially godoc for PHP

  • Monday, April 25, 2016
  • by nochso
  • Repository
  • 1 Watchers
  • 4 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

nochso/phormat

write me to read me License Latest tag on Github Travis CI build status Coverage status, (*1)

Phormat formats PHP source code., (*2)

Differences to other fixers or PSR2:, (*3)

  • You can not influence the style, similar to gofmt.
  • Tabs for indentation.
  • Opening braces { on the same line: ) {
  • No extra whitespacy lines in code or comments.
  • Use statements are always sorted.
  • Optional re-arranging of class level elements.
  • Fast. Check out the benchmarks.

Introduction, goals and scope

Phormat is a pretty printer based on nikic/php-parser. It discards any formatting and prints source code in a uniform style. Custom formatting options are out of scope., (*4)

The chosen style is personal preference and attempts to keep the line count low while keeping the code readable., (*5)

You're anti-PSR! Why do you hate FIG?, (*6)

I'm not. I don't. This is not a replacement, improvement or critique of PSR2 but merely an alternative you're free to ignore., (*7)

PSR2 is quite widespread for a reason and has helped lots of projects decide on a common style. However it does not mean everybody loves it personally or that it is a de-facto standard you must adhere to. The questions of tabs vs. spaces or placement of braces will always be part of a holy war as it comes down to personal preference., (*8)

In the end, it's best for collaboration if a project has a well defined style that is easy for contributors to adhere to. Which is easily possible for both PSR2 and phormat., (*9)

See php-cs-fixer for a great way to adhere to PSR2., (*10)

Requirements

This project is written for and tested with PHP 5.6, 7.0 and HHVM., (*11)

Installation

For end-users the PHAR version is preferred. To install it globally:, (*12)

  1. Download the PHAR file from the latest release.
  2. Make it executable: chmod +x phormat.phar
  3. Move it somewhere within your PATH: sudo cp phormat.phar /usr/local/bin/phormat

As local Composer development dependency per project:, (*13)

composer require --dev nochso/phormat

As global Composer dependency:, (*14)

composer global require nochso/phormat

Usage

As a local dependency php vendor/bin/phormat or if installed globally just phormat., (*15)

phormat [options] <path>
phormat [options] <path1> <path2> ...

By default PHP files from the specified paths will be overwritten. See the options below to override this behaviour., (*16)

If path is a folder it will be searched recursively for files ending with *.php., (*17)

Native PHP templates will be skipped to avoid messing up their formatting. Templates are detected by looking for alternative syntax for control structures like if (true): .. endif;, (*18)

Command line options

Arguments
    <paths>
        One or many paths to files or directories.

Options
    -d, --diff
        Preview diff of formatted code. Implies --no-output.

    -s, --summary
        Show a status summary for each file.

    -o, --order
        Change order of class elements:
        constants > properties > methods
        static > abstract > *
        public > protected > private
        __* > has* > is* > get* > set* > add* > remove* > enable* > disable* > *

    -p, --print
        Print full output of formatted code. Implies --no-output.

    -n, --no-output
        Do not overwrite source files.

    -h, --help
        Show this help.

    --version
        Show version information.

    --self-update
        Update phormat to the latest version.

Contributing

Feedback, bug reports and pull requests are always welcome., (*19)

Please read the contributing guide for instructions., (*20)

Change log

See CHANGELOG.md for the full history of changes between releases., (*21)

[Unreleased]

Changed

  • Improved line wrapping: Use a soft limit of 100 characters for lines made of ., || and &&.

[0.1.5] - 2016-04-23

Changed

  • Allow self-update without public key.

[0.1.4] - 2016-04-23

Added

  • Show warnings when xdebug or xdebug-profiling is enabled.

Changed

  • Put closing parenthesis of multiple lines on a new line.
  • Use statements are always sorted.
  • Separate classes, interfaces and traits.
  • Keep use and group-use statements together.

License

This project is released under the MIT license. See LICENSE.md for the full text., (*22)

The Versions

25/04 2016
23/04 2016

dev-master

9999999-dev

PHP source formatter with a single style - essentially godoc for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

23/04 2016
23/04 2016
23/04 2016
23/04 2016
18/04 2016

0.1.1

0.1.1.0

PHP source formatter with a single style - essentially godoc for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

16/04 2016

0.1.0

0.1.0.0

PHP source formatter with a single style - essentially godoc for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires