client: dev-tools: lib_linter: php-cs-fixer: add given-file(s) init, refactor

This commit is contained in:
2026-01-15 10:50:00 -08:00
parent b5a1f33159
commit e9aa72c64a

View File

@@ -206,14 +206,17 @@ function lib_linter::__lint_php()
local -r _path=("$@")
local -r _ext="php"
local -r _php_cs_fixer="time php-cs-fixer fix --rules=@PSR12 --verbose"
local -r _php_cs_fixer_init="php-cs-fixer -n init"
local -r _php_cs_fixer_fix="time php-cs-fixer fix --rules=@PSR12 --verbose"
local -r _phpstan="time phpstan analyse --debug --autoload-file /usr/local/lib/php/vendor/autoload.php --level 6" # TODO: incrementally increase to 9
if [ -z "${_path[*]}" ]; then
# Do all
lib_docker::exec \
"php-cs-fixer -n init \
&& $_php_cs_fixer $DOCKER_FINANCE_CLIENT_REPO && $_php_cs_fixer $DOCKER_FINANCE_CLIENT_PLUGINS \
"$_php_cs_fixer_init \
&& $_php_cs_fixer_fix $DOCKER_FINANCE_CLIENT_REPO \
&& $_php_cs_fixer_fix $DOCKER_FINANCE_CLIENT_PLUGINS \
&& $_phpstan $DOCKER_FINANCE_CLIENT_REPO $DOCKER_FINANCE_CLIENT_PLUGINS"
else
# Do only given file(s)
@@ -222,7 +225,9 @@ function lib_linter::__lint_php()
_file="$(dirs +1)/${_p}"
lib_utils::print_normal "Linting '${_file}'"
lib_docker::exec \
"$_php_cs_fixer $_file && $_phpstan $_file"
"$_php_cs_fixer_init \
&& $_php_cs_fixer_fix $_file \
&& $_phpstan $_file"
done
fi
}