diff --git a/docs/options.md b/docs/options.md index c4e0a38..a131115 100644 --- a/docs/options.md +++ b/docs/options.md @@ -7074,7 +7074,7 @@ Automatically beautify LaTeX files on save **Description**: -undefined (Supported by Latex Beautify) + (Supported by Latex Beautify) **Example `.jsbeautifyrc` Configuration** @@ -8945,7 +8945,7 @@ Automatically beautify Nginx files on save **Description**: -undefined (Supported by Nginx Beautify) + (Supported by Nginx Beautify) **Example `.jsbeautifyrc` Configuration** @@ -9575,9 +9575,10 @@ Specify a configuration file which will override the default name of .perltidyrc | `cs_fixer_version` | :white_check_mark: | :x: | :x: | | `fixers` | :white_check_mark: | :x: | :x: | | `level` | :white_check_mark: | :x: | :x: | -| `phpcbf_path` | :white_check_mark: | :x: | :x: | +| `phpcbf_path` | :x: | :white_check_mark: | :x: | +| `phpcbf_version` | :x: | :white_check_mark: | :x: | | `rules` | :white_check_mark: | :x: | :x: | -| `standard` | :white_check_mark: | :white_check_mark: | :x: | +| `standard` | :x: | :white_check_mark: | :x: | **Description**: @@ -9706,7 +9707,7 @@ Absolute path to the `php-cs-fixer` CLI executable (Supported by PHP-CS-Fixer) **Description**: -undefined (Supported by PHP-CS-Fixer) + (Supported by PHP-CS-Fixer) **Example `.jsbeautifyrc` Configuration** @@ -9774,11 +9775,11 @@ By default, all PSR-2 fixers and some additional ones are run. (PHP-CS-Fixer 1 o **Type**: `string` -**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) +**Supported Beautifiers**: [`PHPCBF`](#phpcbf) **Description**: -Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer) +Path to the `phpcbf` CLI executable (Supported by PHPCBF) **Example `.jsbeautifyrc` Configuration** @@ -9790,6 +9791,34 @@ Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer) } ``` +##### [PHPCBF Version](#phpcbf-version) + +**Namespace**: `php` + +**Key**: `phpcbf_version` + +**Default**: `2` + +**Type**: `integer` + +**Enum**: `1` `2` `3` + +**Supported Beautifiers**: [`PHPCBF`](#phpcbf) + +**Description**: + +undefined (Supported by PHPCBF) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "php": { + "phpcbf_version": 2 + } +} +``` + ##### [Rules](#rules) **Namespace**: `php` @@ -9820,20 +9849,22 @@ Add rule(s). i.e. line_ending,-full_opening_tag,@PSR2 (PHP-CS-Fixer 2 only) (Sup **Key**: `standard` +**Default**: `PEAR` + **Type**: `string` -**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) [`PHPCBF`](#phpcbf) +**Supported Beautifiers**: [`PHPCBF`](#phpcbf) **Description**: -Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules. Will use local `phpcs.xml`, `phpcs.xml.dist`, `phpcs.ruleset.xml` or `ruleset.xml` if found in the project root. (Supported by PHP-CS-Fixer, PHPCBF) +Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules. Will use local `phpcs.xml`, `phpcs.xml.dist`, `phpcs.ruleset.xml` or `ruleset.xml` if found in the project root. (Supported by PHPCBF) **Example `.jsbeautifyrc` Configuration** ```json { "php": { - "standard": "" + "standard": "PEAR" } } ``` @@ -16757,7 +16788,7 @@ Remove trailing whitespace (Supported by Latex Beautify) **Description**: -undefined (Supported by Latex Beautify) + (Supported by Latex Beautify) **Example `.jsbeautifyrc` Configuration** @@ -17311,7 +17342,7 @@ Indentation uses tabs, overrides `Indent Size` and `Indent Char` (Supported by N **Description**: -undefined (Supported by Nginx Beautify) + (Supported by Nginx Beautify) **Example `.jsbeautifyrc` Configuration** @@ -17366,7 +17397,7 @@ Absolute path to the `php-cs-fixer` CLI executable (Supported by PHP-CS-Fixer) **Description**: -undefined (Supported by PHP-CS-Fixer) + (Supported by PHP-CS-Fixer) **Example `.jsbeautifyrc` Configuration** @@ -17478,6 +17509,9 @@ allow risky rules to be applied (PHP-CS-Fixer 2 only) (Supported by PHP-CS-Fixer } ``` + +### PHPCBF + ##### [PHPCBF Path](#phpcbf-path) **Namespace**: `php` @@ -17486,11 +17520,11 @@ allow risky rules to be applied (PHP-CS-Fixer 2 only) (Supported by PHP-CS-Fixer **Type**: `string` -**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) +**Supported Beautifiers**: [`PHPCBF`](#phpcbf) **Description**: -Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer) +Path to the `phpcbf` CLI executable (Supported by PHPCBF) **Example `.jsbeautifyrc` Configuration** @@ -17502,53 +17536,56 @@ Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer) } ``` -##### [PHPCBF Standard](#phpcbf-standard) +##### [PHPCBF Version](#phpcbf-version) **Namespace**: `php` -**Key**: `standard` +**Key**: `phpcbf_version` -**Type**: `string` +**Default**: `2` -**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) [`PHPCBF`](#phpcbf) +**Type**: `integer` + +**Enum**: `1` `2` `3` + +**Supported Beautifiers**: [`PHPCBF`](#phpcbf) **Description**: -Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules. Will use local `phpcs.xml`, `phpcs.xml.dist`, `phpcs.ruleset.xml` or `ruleset.xml` if found in the project root. (Supported by PHP-CS-Fixer, PHPCBF) +undefined (Supported by PHPCBF) **Example `.jsbeautifyrc` Configuration** ```json { "php": { - "standard": "" + "phpcbf_version": 2 } } ``` - -### PHPCBF - ##### [PHPCBF Standard](#phpcbf-standard) **Namespace**: `php` **Key**: `standard` +**Default**: `PEAR` + **Type**: `string` -**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) [`PHPCBF`](#phpcbf) +**Supported Beautifiers**: [`PHPCBF`](#phpcbf) **Description**: -Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules. Will use local `phpcs.xml`, `phpcs.xml.dist`, `phpcs.ruleset.xml` or `ruleset.xml` if found in the project root. (Supported by PHP-CS-Fixer, PHPCBF) +Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules. Will use local `phpcs.xml`, `phpcs.xml.dist`, `phpcs.ruleset.xml` or `ruleset.xml` if found in the project root. (Supported by PHPCBF) **Example `.jsbeautifyrc` Configuration** ```json { "php": { - "standard": "" + "standard": "PEAR" } } ``` diff --git a/script/build-options.js b/script/build-options.js index 43141a4..4d1fabf 100644 --- a/script/build-options.js +++ b/script/build-options.js @@ -133,9 +133,9 @@ buildOptionsForBeautifiers = function(beautifiers, allLanguages) { return _.reduce(languageOptions, (function(result, optionDef, optionName) { optionDef.beautifiers = _.uniq(optionDef.beautifiers) if (optionDef.beautifiers.length > 0) { - optionDef.description = optionDef.description + " (Supported by " + (optionDef.beautifiers.join(', ')) + ")"; + optionDef.description = (optionDef.description || "") + " (Supported by " + (optionDef.beautifiers.join(', ')) + ")"; } else { - optionDef.description = optionDef.description + " (Not supported by any beautifiers)"; + optionDef.description = (optionDef.description || "") + " (Not supported by any beautifiers)"; } if (result[optionName] != null) { logger.warn("Duplicate option detected: ", optionName, optionDef); @@ -322,7 +322,7 @@ buildOptionsForBeautifiers = function(beautifiers, allLanguages) { optionDef = ref16[o]; optionDef.beautifiers = _.uniq(optionDef.beautifiers) if (optionDef.beautifiers.length > 0) { - optionDef.description = optionDef.description + " (Supported by " + (optionDef.beautifiers.join(', ')) + ")"; + optionDef.description = (optionDef.description || "") + " (Supported by " + (optionDef.beautifiers.join(', ')) + ")"; } else { unsupportedOptions.push(g + ".properties." + o); } diff --git a/src/beautifiers/php-cs-fixer.coffee b/src/beautifiers/php-cs-fixer.coffee index fd42081..9fa408d 100644 --- a/src/beautifiers/php-cs-fixer.coffee +++ b/src/beautifiers/php-cs-fixer.coffee @@ -13,7 +13,13 @@ module.exports = class PHPCSFixer extends Beautifier isPreInstalled: false options: - PHP: true + PHP: + rules: true + cs_fixer_path: true + cs_fixer_version: true + allow_risky: true + level: true + fixers: true beautify: (text, language, options, context) -> @debug('php-cs-fixer', options) diff --git a/src/beautifiers/phpcbf.coffee b/src/beautifiers/phpcbf.coffee index 4d0a472..d811ec8 100644 --- a/src/beautifiers/phpcbf.coffee +++ b/src/beautifiers/phpcbf.coffee @@ -11,12 +11,10 @@ module.exports = class PHPCBF extends Beautifier isPreInstalled: false options: { - _: - standard: ["standard", (standard) -> - if (standard) then \ - standard else "PEAR" - ] - PHP: true + PHP: + phpcbf_path: true + phpcbf_version: true + standard: true } beautify: (text, language, options) -> @@ -50,7 +48,7 @@ module.exports = class PHPCBF extends Beautifier @run(exec, [ phpcbfPath unless isExec - "--no-patch" + "--no-patch" unless options.phpcbf_version is 3 "--standard=#{options.standard}" if options.standard tempFile = @tempFile("temp", text) ], { diff --git a/src/languages/php.coffee b/src/languages/php.coffee index 42274f8..e22873f 100644 --- a/src/languages/php.coffee +++ b/src/languages/php.coffee @@ -55,10 +55,15 @@ module.exports = { type: 'string' default: "" description: "Path to the `phpcbf` CLI executable", + phpcbf_version: + title: "PHPCBF Version" + type: 'integer' + default: 2 + enum: [1, 2, 3] standard: title: "PHPCBF Standard" type: 'string' - default: "", + default: "PEAR", description: "Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules. Will use local `phpcs.xml`, `phpcs.xml.dist`, `phpcs.ruleset.xml` or `ruleset.xml` if found in the project root." } diff --git a/src/options.json b/src/options.json index e7894a9..fa024ba 100644 --- a/src/options.json +++ b/src/options.json @@ -4301,7 +4301,7 @@ "name": "LaTeX", "namespace": "latex" }, - "description": "undefined (Supported by Latex Beautify)" + "description": " (Supported by Latex Beautify)" }, "disabled": { "title": "Disable Beautifying Language", @@ -5420,7 +5420,7 @@ "name": "Nginx", "namespace": "nginx" }, - "description": "undefined (Supported by Nginx Beautify)" + "description": " (Supported by Nginx Beautify)" }, "disabled": { "title": "Disable Beautifying Language", @@ -5808,7 +5808,7 @@ "name": "PHP", "namespace": "php" }, - "description": "undefined (Supported by PHP-CS-Fixer)" + "description": " (Supported by PHP-CS-Fixer)" }, "fixers": { "type": "string", @@ -5874,9 +5874,9 @@ "title": "PHPCBF Path", "type": "string", "default": "", - "description": "Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer)", + "description": "Path to the `phpcbf` CLI executable (Supported by PHPCBF)", "beautifiers": [ - "PHP-CS-Fixer" + "PHPCBF" ], "key": "phpcbf_path", "language": { @@ -5884,13 +5884,31 @@ "namespace": "php" } }, + "phpcbf_version": { + "title": "PHPCBF Version", + "type": "integer", + "default": 2, + "enum": [ + 1, + 2, + 3 + ], + "beautifiers": [ + "PHPCBF" + ], + "key": "phpcbf_version", + "language": { + "name": "PHP", + "namespace": "php" + }, + "description": "undefined (Supported by PHPCBF)" + }, "standard": { "title": "PHPCBF Standard", "type": "string", - "default": "", - "description": "Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules. Will use local `phpcs.xml`, `phpcs.xml.dist`, `phpcs.ruleset.xml` or `ruleset.xml` if found in the project root. (Supported by PHP-CS-Fixer, PHPCBF)", + "default": "PEAR", + "description": "Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules. Will use local `phpcs.xml`, `phpcs.xml.dist`, `phpcs.ruleset.xml` or `ruleset.xml` if found in the project root. (Supported by PHPCBF)", "beautifiers": [ - "PHP-CS-Fixer", "PHPCBF" ], "key": "standard",