From caccf8a9fb90d17d1918eb24d8048aaca1cc74b4 Mon Sep 17 00:00:00 2001 From: MDW Date: Fri, 24 Nov 2023 13:43:59 +0100 Subject: [PATCH 1/6] Add .php-cs-fixer.dist.php configuration --- .php-cs-fixer.dist.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .php-cs-fixer.dist.php diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 00000000000..d145f9e143d --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,30 @@ +in(__DIR__) + ->exclude([ + 'htdocs/includes', + ]) + ->notPath([ + 'vendor', + ]) +; + +return (new PhpCsFixer\Config()) + ->setRules([ + // Apply PSR-12 as per https://wiki.dolibarr.org/index.php?title=Langages_et_normes#PHP:~:text=utiliser%20est%20le-,PSR%2D12,-(https%3A//www + // '@PSR12' => true, // Disabled for now to limit number of changes + // Minimum version Dolibarr v18.0.0 + '@PHP71Migration' => true, + //'strict_param' => true, + //'array_syntax' => ['syntax' => 'short'], + 'array_syntax' => false, + ]) + ->setFinder($finder) + // TAB Indent violates PSR-12 "must" rule, but used in code + // (See https://www.php-fig.org/psr/psr-12/#24-indenting ) + ->setIndent("\t") + // All files MUST use the Unix LF line ending only + // https://www.php-fig.org/psr/psr-12/#22-files + ->setLineEnding("\n") +; From 88e71ef2528669694be70b745db891f525a0e18c Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 28 Nov 2023 16:32:41 +0100 Subject: [PATCH 2/6] Add script to run php-cs-fixer --- dev/tools/run-php-cs-fixer.sh | 52 +++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 dev/tools/run-php-cs-fixer.sh diff --git a/dev/tools/run-php-cs-fixer.sh b/dev/tools/run-php-cs-fixer.sh new file mode 100644 index 00000000000..309e1dfec59 --- /dev/null +++ b/dev/tools/run-php-cs-fixer.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# +# Usage: +# Optionally set COMPOSER_CMD to the command to use to run composer. +# Optionally set COMPOSER_VENDOR_DIR to your vendor path for composer. +# +# Run php-cs-fixer by calling this script: +# ./run-php-cs-fixer.sh check # Only checks (the default) +# ./run-php-cs-fixer.sh fix # Fixes +# +# You can fix only a few files using +# ./run-php-cs-fixer.sh fix htdocs/path/to/myfile.php +# +# You can run this from the root directory of dolibarr +# dev/tools/run-php-cs-fixer.sh fix htdocs/path/to/myfile.php +# +# You can provide the environment variables on the CLI like this: +# COMPOSER_CMD="php ~/composer.phar" COMPOSER_VENDOR_DIR="~/vendor" ./run-php-cs-fixer.sh +# +# or export them: +# export COMPOSER_CMD="php ~/composer.phar" +# export COMPOSER_VENDOR_DIR="~/vendor" +# ./run-php-cs-fixer.sh +# +# Or some other method +# + + +MYDIR=$(dirname "$(realpath "$0")") +export COMPOSER_VENDOR_DIR=${COMPOSER_VENDOR_DIR:=$MYDIR/vendor} +COMPOSER_CMD=${COMPOSER_CMD:=composer} + +# +# Install/update +# +PHP_CS_FIXER="${COMPOSER_VENDOR_DIR}/bin/php-cs-fixer" +if [ ! -r "${PHP_CS_FIXER}" ] ; then + [[ ! -e "${COMPOSER_VENDOR_DIR}" ]] && ${COMPOSER_CMD} install + [[ -e "${COMPOSER_VENDOR_DIR}" ]] && ${COMPOSER_CMD} update + ${COMPOSER_CMD} require --dev friendsofphp/php-cs-fixer +fi + + +( + cd "${MYDIR}/../.." || exit + CMD= + # If no argument, run check by default + [[ "$1" == "" ]] && CMD=check + # shellcheck disable=SC2086 + "${PHP_CS_FIXER}" $CMD "$@" +) From adfc58bd7defe7ede653950e46ffd71eb9e8dbe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Dec 2023 21:18:10 +0100 Subject: [PATCH 3/6] fix phpstan --- htdocs/expedition/class/expedition.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 463e3b07c39..3ad356d02e5 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -997,7 +997,7 @@ class Expedition extends CommonObject $linebatch = new ExpeditionLineBatch($this->db); $ret = $linebatch->fetchFromStock($value['id_batch']); // load serial, sellby, eatby if ($ret < 0) { - $this->error = $linebatch->error; + $this->setErrorsFromObject($linebatch); return -1; } $linebatch->qty = $value['q']; @@ -1038,6 +1038,7 @@ class Expedition extends CommonObject $this->lines[$num] = $line; return 1; } + return 0; } /** From 5cec32977d0b5a963ebb8a50ad4becff3986ae22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Dec 2023 22:02:45 +0100 Subject: [PATCH 4/6] fix phpstan --- htdocs/loan/class/loanschedule.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/loan/class/loanschedule.class.php b/htdocs/loan/class/loanschedule.class.php index ceeca8324c0..6a3064bdc75 100644 --- a/htdocs/loan/class/loanschedule.class.php +++ b/htdocs/loan/class/loanschedule.class.php @@ -45,6 +45,8 @@ class LoanSchedule extends CommonObject */ public $fk_loan; + public $bank_account; + public $bank_line; /** * @var string Create date */ From bc6d4d0dffe26494d4adcbce1ce8ec887e7f4b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Dec 2023 22:06:12 +0100 Subject: [PATCH 5/6] fix phpstan --- htdocs/loan/class/paymentloan.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index 073681ad5d5..b735773bec9 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -98,6 +98,11 @@ class PaymentLoan extends CommonObject public $type_code; public $type_label; + public $chid; + public $label; + public $paymenttype; + public $bank_account; + public $bank_line; /** From 91d8758e5267209433c6d4f3803c619c27a0850e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Dec 2023 22:28:04 +0100 Subject: [PATCH 6/6] fix phpstan --- htdocs/societe/class/api_thirdparties.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index b01954767c4..7efb611bdf3 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -829,7 +829,7 @@ class Thirdparties extends DolibarrApi * Get representatives of thirdparty * * @param int $id ID of the thirdparty - * @param string $mode 0=Array with properties, 1=Array of id. + * @param int $mode 0=Array with properties, 1=Array of id. * * @url GET {id}/representatives *