|
143 | 143 | - This extension simply provides `PHP CS Fixer` command.
|
144 | 144 | - Configuration:
|
145 | 145 |
|
146 |
| - ```json |
147 |
| - { |
| 146 | + - VS Code Settings: |
| 147 | + |
| 148 | + ```json |
| 149 | + "[php]": { |
| 150 | + "editor.tabSize": 4, |
| 151 | + "editor.defaultFormatter": "junstyle.php-cs-fixer" |
| 152 | + }, |
148 | 153 | "php-cs-fixer.executablePath": "php-cs-fixer",
|
149 | 154 | "php-cs-fixer.executablePathWindows": "", //eg: php-cs-fixer.bat
|
150 | 155 | "php-cs-fixer.onsave": false,
|
151 | 156 | "php-cs-fixer.rules": "@PSR12",
|
152 |
| - "php-cs-fixer.config": ".php-cs-fixer.php;.php-cs-fixer.dist.php;.php_cs;.php_cs.dist", |
| 157 | + "php-cs-fixer.config": "/home/dev/.vscode/.php-cs-fixer.php;.php-cs-fixer.dist.php;.php_cs;.php_cs.dist", |
153 | 158 | "php-cs-fixer.allowRisky": false,
|
154 | 159 | "php-cs-fixer.pathMode": "override",
|
155 | 160 | "php-cs-fixer.ignorePHPVersion": false,
|
|
158 | 163 | "php-cs-fixer.autoFixBySemicolon": false,
|
159 | 164 | "php-cs-fixer.formatHtml": false,
|
160 | 165 | "php-cs-fixer.documentFormattingProvider": true
|
161 |
| - } |
162 |
| - ``` |
| 166 | + ``` |
163 | 167 |
|
164 |
| - - VS Code Settings: |
| 168 | + - ~/.vscode/.php-cs-fixer.php |
| 169 | + |
| 170 | + ```php |
| 171 | + <?php |
| 172 | +
|
| 173 | + return (new PhpCsFixer\Config()) |
| 174 | + ->setRules([ |
| 175 | + '@PSR12' => true, |
| 176 | + 'array_indentation' => true, |
| 177 | + 'array_syntax' => ['syntax' => 'short'], |
| 178 | + 'combine_consecutive_unsets' => true, |
| 179 | + 'class_attributes_separation' => ['elements' => ['method' => 'one', ]], |
| 180 | + 'multiline_whitespace_before_semicolons' => false, |
| 181 | + 'single_quote' => true, |
| 182 | +
|
| 183 | + 'binary_operator_spaces' => [ |
| 184 | + 'operators' => [ |
| 185 | + // '=>' => 'align', |
| 186 | + // '=' => 'align' |
| 187 | + ] |
| 188 | + ], |
| 189 | + // 'blank_line_after_opening_tag' => true, |
| 190 | + // 'blank_line_before_statement' => true, |
| 191 | + 'braces' => [ |
| 192 | + 'allow_single_line_closure' => true, |
| 193 | + ], |
| 194 | + // 'cast_spaces' => true, |
| 195 | + // 'class_definition' => array('singleLine' => true), |
| 196 | + 'concat_space' => ['spacing' => 'one'], |
| 197 | + 'declare_equal_normalize' => true, |
| 198 | + 'function_typehint_space' => true, |
| 199 | + 'single_line_comment_style' => ['comment_types' => ['hash']], |
| 200 | + 'include' => true, |
| 201 | + 'lowercase_cast' => true, |
| 202 | + // 'native_function_casing' => true, |
| 203 | + // 'new_with_braces' => true, |
| 204 | + // 'no_blank_lines_after_class_opening' => true, |
| 205 | + // 'no_blank_lines_after_phpdoc' => true, |
| 206 | + // 'no_blank_lines_before_namespace' => true, |
| 207 | + // 'no_empty_comment' => true, |
| 208 | + // 'no_empty_phpdoc' => true, |
| 209 | + // 'no_empty_statement' => true, |
| 210 | + 'no_extra_blank_lines' => [ |
| 211 | + 'tokens' => [ |
| 212 | + 'curly_brace_block', |
| 213 | + 'extra', |
| 214 | + // 'parenthesis_brace_block', |
| 215 | + // 'square_brace_block', |
| 216 | + 'throw', |
| 217 | + 'use', |
| 218 | + ] |
| 219 | + ], |
| 220 | + // 'no_leading_import_slash' => true, |
| 221 | + // 'no_leading_namespace_whitespace' => true, |
| 222 | + // 'no_mixed_echo_print' => array('use' => 'echo'), |
| 223 | + 'no_multiline_whitespace_around_double_arrow' => true, |
| 224 | + // 'no_short_bool_cast' => true, |
| 225 | + // 'no_singleline_whitespace_before_semicolons' => true, |
| 226 | + 'no_spaces_around_offset' => true, |
| 227 | + // 'no_trailing_comma_in_list_call' => true, |
| 228 | + // 'no_trailing_comma_in_singleline_array' => true, |
| 229 | + // 'no_unneeded_control_parentheses' => true, |
| 230 | + // 'no_unused_imports' => true, |
| 231 | + 'no_whitespace_before_comma_in_array' => true, |
| 232 | + 'no_whitespace_in_blank_line' => true, |
| 233 | + // 'normalize_index_brace' => true, |
| 234 | + 'object_operator_without_whitespace' => true, |
| 235 | + // 'php_unit_fqcn_annotation' => true, |
| 236 | + // 'phpdoc_align' => true, |
| 237 | + // 'phpdoc_annotation_without_dot' => true, |
| 238 | + // 'phpdoc_indent' => true, |
| 239 | + // 'phpdoc_inline_tag' => true, |
| 240 | + // 'phpdoc_no_access' => true, |
| 241 | + // 'phpdoc_no_alias_tag' => true, |
| 242 | + // 'phpdoc_no_empty_return' => true, |
| 243 | + // 'phpdoc_no_package' => true, |
| 244 | + // 'phpdoc_no_useless_inheritdoc' => true, |
| 245 | + // 'phpdoc_return_self_reference' => true, |
| 246 | + // 'phpdoc_scalar' => true, |
| 247 | + // 'phpdoc_separation' => true, |
| 248 | + // 'phpdoc_single_line_var_spacing' => true, |
| 249 | + // 'phpdoc_summary' => true, |
| 250 | + // 'phpdoc_to_comment' => true, |
| 251 | + // 'phpdoc_trim' => true, |
| 252 | + // 'phpdoc_types' => true, |
| 253 | + // 'phpdoc_var_without_name' => true, |
| 254 | + // 'increment_style' => true, |
| 255 | + // 'return_type_declaration' => true, |
| 256 | + // 'self_accessor' => true, |
| 257 | + // 'short_scalar_cast' => true, |
| 258 | + // 'single_blank_line_before_namespace' => true, |
| 259 | + // 'single_class_element_per_statement' => true, |
| 260 | + // 'space_after_semicolon' => true, |
| 261 | + // 'standardize_not_equals' => true, |
| 262 | + 'ternary_operator_spaces' => true, |
| 263 | + // 'trailing_comma_in_multiline' => ['elements' => ['arrays']], |
| 264 | + 'trim_array_spaces' => true, |
| 265 | + 'unary_operator_spaces' => true, |
| 266 | + 'whitespace_after_comma_in_array' => true, |
| 267 | + 'space_after_semicolon' => true, |
| 268 | + // 'single_blank_line_at_eof' => false |
| 269 | + ]) |
| 270 | + // ->setIndent("\t") |
| 271 | + ->setLineEnding("\n") |
| 272 | + ; |
165 | 273 |
|
166 |
| - ```json |
167 |
| - "[php]": { |
168 |
| - "editor.tabSize": 4, |
169 |
| - "editor.defaultFormatter": "junstyle.php-cs-fixer" |
170 |
| - }, |
171 | 274 | ```
|
172 | 275 |
|
173 | 276 | ## 3. Your First PHP Tag
|
|
0 commit comments