Skip to content

Commit dba4d8e

Browse files
committed
feat - add psr12 suppport
1 parent 7e00e73 commit dba4d8e

25 files changed

Lines changed: 1166 additions & 8 deletions

Default.sublime-commands

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
{"caption": "phpfmt: toggle PSR1 - Class and Methods names", "command": "toggle", "args": {"option":"psr1_naming"}},
1515
{"caption": "phpfmt: toggle PSR1", "command": "toggle", "args": {"option":"psr1"}},
1616
{"caption": "phpfmt: toggle PSR2", "command": "toggle", "args": {"option":"psr2"}},
17+
{"caption": "phpfmt: toggle PSR-12", "command": "toggle", "args": {"option":"psr12"}},
1718
{"caption": "phpfmt: toggle WP Coding Standards", "command": "toggle", "args": {"option":"wp"}},
1819
{"caption": "phpfmt: analyse this", "command": "analyse_this"},
1920
{"caption": "phpfmt: build autocomplete database", "command": "build_oracle"},

README.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ PHPFmt is a PHP code formatter tailored for Sublime Text 4 with full support for
77
## Features
88

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

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

3333
```json
3434
{
35-
"php_bin": "c:/PHP/php.exe"
35+
"php_bin": "c:/PHP/php.exe",
36+
"psr2": true,
37+
"psr12": false
3638
}
3739
```
3840

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

4345
```json
4446
{
45-
"php_bin": "/usr/local/bin/php"
47+
"php_bin": "/usr/local/bin/php",
48+
"psr2": true,
49+
"psr12": false
4650
}
4751
```
4852

53+
`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.
54+
4955
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.
5056

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

5966
... and more.
6067

68+
## PSR Profiles
69+
70+
- `psr1`: enables the PSR-1 profile.
71+
- `psr1_naming`: enables PSR-1 naming rules for classes and methods.
72+
- `psr2`: keeps the legacy PSR-2 behavior unchanged.
73+
- `psr12`: enables the newer PSR-12 profile on top of the existing PSR base without changing `psr2` semantics.
74+
75+
In the Sublime plugin, enabling `psr12` disables `psr2`, and enabling `psr2` disables `psr12`.
76+
6177

6278
## Currently Supported Transformations:
6379

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

0 commit comments

Comments
 (0)