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") +; 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 "$@" +) 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; } /** 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 */ 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; /** 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 *