Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
{"caption": "phpfmt: toggle PSR1 - Class and Methods names", "command": "toggle", "args": {"option":"psr1_naming"}},
{"caption": "phpfmt: toggle PSR1", "command": "toggle", "args": {"option":"psr1"}},
{"caption": "phpfmt: toggle PSR2", "command": "toggle", "args": {"option":"psr2"}},
{"caption": "phpfmt: toggle PSR-12", "command": "toggle", "args": {"option":"psr12"}},
{"caption": "phpfmt: toggle WP Coding Standards", "command": "toggle", "args": {"option":"wp"}},
{"caption": "phpfmt: analyse this", "command": "analyse_this"},
{"caption": "phpfmt: build autocomplete database", "command": "build_oracle"},
Expand Down
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PHPFmt is a PHP code formatter tailored for Sublime Text 4 with full support for
## Features

- **PHP 8 Support**: Seamlessly format PHP >= 5.6 code.
- **Rich Formatting Options**: Includes PSR-1, PSR-2, and WordPress coding standards, among others.
- **Rich Formatting Options**: Includes PSR-1, PSR-2, PSR-12, and WordPress coding standards, among others.
- **Customization**: Supports a wide array of transformations and formatting tweaks.
- **Easy Integration**: Simple setup and configuration within Sublime Text.

Expand All @@ -32,7 +32,9 @@ Edit the configuration file at `%AppData%\Sublime Text\Packages\phpfmt\phpfmt.su

```json
{
"php_bin": "c:/PHP/php.exe"
"php_bin": "c:/PHP/php.exe",
"psr2": true,
"psr12": false
}
```

Expand All @@ -42,10 +44,14 @@ Edit `phpfmt.sublime-settings` and set the `php_bin` path:

```json
{
"php_bin": "/usr/local/bin/php"
"php_bin": "/usr/local/bin/php",
"psr2": true,
"psr12": false
}
```

`psr12` is opt-in and does not change the existing `psr2` profile. In the Sublime plugin, `psr12` and `psr2` are treated as mutually exclusive profile toggles so enabling one disables the other.

You may find an example configuration file in https://github.com/driade/phpfmt8/blob/master/driade.sublime-settings , where you can see how to configure the extension.

## Usage
Expand All @@ -55,9 +61,19 @@ PHPFmt provides a variety of commands accessible via the command palette (`Ctrl+
- `phpfmt: format now`
- `phpfmt: toggle format on save`
- `phpfmt: toggle PSR2`
- `phpfmt: toggle PSR-12`

... and more.

## PSR Profiles

- `psr1`: enables the PSR-1 profile.
- `psr1_naming`: enables PSR-1 naming rules for classes and methods.
- `psr2`: keeps the legacy PSR-2 behavior unchanged.
- `psr12`: enables the newer PSR-12 profile on top of the existing PSR base without changing `psr2` semantics.

In the Sublime plugin, enabling `psr12` disables `psr2`, and enabling `psr2` disables `psr12`.


## Currently Supported Transformations:

Expand Down Expand Up @@ -102,6 +118,13 @@ PHPFmt provides a variety of commands accessible via the command palette (`Ctrl+
* PrettyPrintDocBlocks Prettify Doc Blocks
* PSR2EmptyFunction Merges in the same line of function header the body of empty functions.
* PSR2MultilineFunctionParams Break function parameters into multiple lines.
* PSR12ControlStructureBlocks Expand control-structure blocks, switch cases, and block declare syntax to multiline PSR-12 form.
* PSR12IndentImplementsList Indent wrapped anonymous-class implements lists for PSR-12.
* PSR12MultilineCalls Normalize multiline function and method calls to PSR-12 hanging indentation.
* PSR12TernaryConditions Normalize multiline ternary operators to PSR-12 hanging indentation.
* PSR12TopFileFormat Normalize top-of-file PSR-12 blocks and import grouping.
* PSR12TraitUseSpacing Ensure a blank line after trait use blocks before class members.
* PSR12TypeHints Normalize nullable and return-type spacing for PSR-12.
* ReindentAndAlignObjOps Align object operators.
* ReindentSwitchBlocks Reindent one level deeper the content of switch blocks.
* ReindentEnumBlocks Reindent one level deeper the content of enum blocks.
Expand Down
Loading
Loading