From cb8b34bae75cb39e6dc0eafba0e59b3c6d597eff Mon Sep 17 00:00:00 2001 From: kj Date: Mon, 20 Oct 2025 14:22:46 -0300 Subject: [PATCH] refactor(php-cs-fixer): Move rules to external config file --- configs/lang-php.el | 14 ++------------ php-cs-fixer-config | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 php-cs-fixer-config diff --git a/configs/lang-php.el b/configs/lang-php.el index dd24981..ab19e30 100644 --- a/configs/lang-php.el +++ b/configs/lang-php.el @@ -32,18 +32,8 @@ (use-package php-cs-fixer :custom - (php-cs-fixer-rules-level-part-options (list (json-encode '(("@PSR12" . t) - ("ordered_imports" . (("sort_algorithm" . "alpha"))) - ("concat_space" . (("spacing" . "one"))) - ("whitespace_after_comma_in_array" . t) - ("align_multiline_comment" . t) - ("no_unused_imports" . t) - ("phpdoc_align" . t) - ("phpdoc_indent" . t) - ("no_useless_return" . t) - ("return_assignment" . t) - ("trailing_comma_in_multiline" . t))))) - (php-cs-fixer-rules-fixer-part-options '()) + (php-cs-fixer-config-option (expand-file-name + (concat user-emacs-directory "php-cs-fixer-config"))) ;; :hook (before-save . php-cs-fixer-before-save) ) diff --git a/php-cs-fixer-config b/php-cs-fixer-config new file mode 100644 index 0000000..d526bd4 --- /dev/null +++ b/php-cs-fixer-config @@ -0,0 +1,24 @@ +#!/usr/bin/php +setRules([ + '@PSR12' => true, + 'ordered_imports' => ['sort_algorithm' => 'alpha'], + 'concat_space' => ['spacing' => 'one'], + 'whitespace_after_comma_in_array' => true, + 'align_multiline_comment' => true, + 'no_unused_imports' => true, + 'phpdoc_align' => true, + 'phpdoc_indent' => true, + // 'psr_autoloading' => true, + 'no_useless_return' => true, + 'return_assignment' => true, + 'trailing_comma_in_multiline' => true, +])->setRiskyAllowed(true); + +return $config->setFinder($finder);