Visual Studio Code extension. A wrapper for the Sensiolabs PHP CS Fixer. Analyzes some PHP source code and tries to fix coding standards issues (PSR-1 and PSR-2 compatible).
Switch branches/tags
Nothing to show
Clone or download
Visser
Visser Fixed Formatter issues and improved API use.
There were some issues with formatting onSave, marking the file dirty after fixing it. This was resolved by removing the document.save().then() part in the FormattingEditProvider. The same provider has also been changed to a RangeFormattingProvider, because our Formatter also supports text selections. This means that the Helper.getSelection() method has been gotten rid of, since that is all handled outside of the formatting functionality now.

Finally, removed the window.activeTextEditor.edit() part from the Formatter, and moved it to a separate functions. Because, what happened was that edits were applied, and then the TextEdits were returned as well. What SHOULD happen, however, is that the TextEdits are returned, so that the FormattingEditProvider API can handle those. We shouldn't handle the edits ourselves.

Calling this extension's "fix" command, however, DOES call window.activeTextEditor.edit(). So this means that both editor.onSave and phpformatter.fix commands work now. Well, at least for me they do.

Last but not least I also added some code documentation.
Latest commit 71ba839 Dec 9, 2016

README.md

PHP Formatter

After installing as an extension with Visual Studio Code, this extension automatically formats your PHP code, in accordance with PSR-0, PSR-1, PSR-2 or Symfony style conventions.

GIF example of formatting your PHP code

Features

  • Format current selection only, or the whole file.
  • Trigger formatting with custom keybindings or actions.
  • Supports formatting on save.
  • Supports adjustable level (i.e. PSR2) and fixers.
  • Can be configured to support other file extensions than PHP as well, i.e. ".inc" files.
  • Supports different PHP-CS-Fixer installation methods, i.e. Composer vs manual installation.

Setup

Refer to our wiki for a quick and easy guide on how to install the extension and its dependencies.

Configuration

Want custom keybindings? Need specific levels and fixers? Check out the wiki

Troubleshooting

Set up the extension, but can't get it to work? Check the Troubleshooting section.

Contribute

Want to add a feature or fix an error? Follow the Contribute section on the wiki to get started.