diff --git a/lib/langs/php-beautify.coffee b/lib/langs/php-beautify.coffee index 7562f42..43e447b 100644 --- a/lib/langs/php-beautify.coffee +++ b/lib/langs/php-beautify.coffee @@ -1,24 +1,27 @@ ### -Requires http://pear.php.net/package/PHP_Beautifier +Requires https://github.com/FriendsOfPHP/PHP-CS-Fixer ### getCmd = (inputPath, outputPath, options) -> - phpBeautifierPath = options.beautifier_path # jshint ignore: line - filters = options.filters - directoryFilters = options.directory_filters # jshint ignore: line + phpCsFixerPath = options.beautifier_path # jshint ignore: line + fixers = options.fixers + level = options.level # jshint ignore: line - cmd = "--input \"#{inputPath}\" --output \"#{outputPath}\"" + levelOption = "" + fixerOption = "" - if filters - cmd += " --filters \"#{filters}\"" - if directoryFilters - cmd += " --directory_filters \"#{directoryFilters}\"" + if level + levelOption = " --level=#{level} " + if fixers + fixerOption = " --fixers=#{fixers}" - if phpBeautifierPath + cmd = "#{levelOption} #{fixerOption} \"#{inputPath}\") || (mv \"#{inputPath}\" \"#{outputPath}\")" + + if phpCsFixerPath # Use absolute path - "php \"#{phpBeautifierPath}\" #{cmd}" + "(php \"#{phpCsFixerPath}\" fix #{cmd}" else # Use command available in $PATH - "php_beautifier #{cmd}" + "(php-cs-fixer fix #{cmd}" "use strict" cliBeautify = require("./cli-beautify") diff --git a/lib/language-options.coffee b/lib/language-options.coffee index e2311e1..6cb0837 100644 --- a/lib/language-options.coffee +++ b/lib/language-options.coffee @@ -275,15 +275,15 @@ module.exports = php_beautifier_path: type: 'string' default: "" - description: "Path to the `PHP_Beautifier` CLI executable" - php_filters: + description: "Path to the `php-cs-fixer` CLI executable" + php_fixers: type: 'string' default: "" - description: "Add filter(s). i.e. \"Filter1(setting1=value1,setting2=value2) Filter2()\"" - php_directory_filters: + description: "Add fixer(s). i.e. linefeed,-short_tag,indentation" + php_level: type: 'string' default: "" - description: "Include dirs for filters" + description: "By default, all PSR-2 fixers and some additional ones are run." # Python python_autopep8_path: