From b586f90f59576317daaf2d2c201e6f4485aa6b4c Mon Sep 17 00:00:00 2001 From: Jon Bendtsen Date: Sun, 7 Apr 2024 12:35:40 +0200 Subject: [PATCH 1/4] Qual: 4 functions with hardcoded elementtype = 'member' replaced with elementtype = '' (#29256) Co-authored-by: Jon Bendtsen --- htdocs/core/class/extrafields.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 7b0673848e8..2a45604b5cd 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -201,7 +201,7 @@ class ExtraFields * @param array $moreparams More parameters. Example: array('css'=>, 'csslist'=>, 'cssview'=>...) * @return int Return integer <=0 if KO, >0 if OK */ - private function create($attrname, $type = 'varchar', $length = '255', $elementtype = 'member', $unique = 0, $required = 0, $default_value = '', $param = array(), $perms = '', $list = '0', $computed = '', $help = '', $moreparams = array()) + private function create($attrname, $type = 'varchar', $length = '255', $elementtype = '', $unique = 0, $required = 0, $default_value = '', $param = array(), $perms = '', $list = '0', $computed = '', $help = '', $moreparams = array()) { if ($elementtype == 'thirdparty') { $elementtype = 'societe'; @@ -305,7 +305,7 @@ class ExtraFields * @return int Return integer <=0 if KO, >0 if OK * @throws Exception */ - private function create_label($attrname, $label = '', $type = '', $pos = 0, $size = '', $elementtype = 'member', $unique = 0, $required = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0, $moreparams = array()) + private function create_label($attrname, $label = '', $type = '', $pos = 0, $size = '', $elementtype = '', $unique = 0, $required = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0, $moreparams = array()) { // phpcs:enable global $conf, $user; @@ -437,7 +437,7 @@ class ExtraFields * @param string $elementtype Element type ('member', 'product', 'thirdparty', 'contact', ...) * @return int Return integer < 0 if KO, 0 if nothing is done, 1 if OK */ - public function delete($attrname, $elementtype = 'member') + public function delete($attrname, $elementtype = '') { if ($elementtype == 'thirdparty') { $elementtype = 'societe'; @@ -495,7 +495,7 @@ class ExtraFields * @param string $elementtype Element type ('member', 'product', 'thirdparty', ...) * @return int Return integer < 0 if KO, 0 if nothing is done, 1 if OK */ - private function delete_label($attrname, $elementtype = 'member') + private function delete_label($attrname, $elementtype = '') { // phpcs:enable global $conf; From 97240a05b0b4d672f6972f99f799899d887a0af3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 7 Apr 2024 14:17:50 +0200 Subject: [PATCH 2/4] fix phpdoc (#29266) --- htdocs/compta/bank/class/account.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 010df2a0fc9..45e3b1d4bd5 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -81,8 +81,8 @@ class Account extends CommonObject public $courant; /** - * Bank account type. Check TYPE_ constants - * @var int + * Bank account type. Check TYPE_ constants. It's integer but Company bank account use string to identify type account + * @var int|string */ public $type; From 95eb1abf2ef6bbad5db3e6f261a3c19ac30947cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 7 Apr 2024 15:01:29 +0200 Subject: [PATCH 3/4] clean code (#29268) --- htdocs/compta/bank/class/account.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 45e3b1d4bd5..dfb140e33d9 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -76,6 +76,8 @@ class Account extends CommonObject /** * Bank account type. Check TYPE_ constants + * @deprecated + * @see $type * @var int */ public $courant; @@ -1051,6 +1053,7 @@ class Account extends CommonObject $this->courant = $obj->courant; $this->bank = $obj->bank; $this->clos = $obj->clos; + $this->status = $obj->clos; $this->rappro = $obj->rappro; $this->url = $obj->url; @@ -1857,6 +1860,8 @@ class Account extends CommonObject $this->label = 'My Big Company Bank account'; $this->courant = Account::TYPE_CURRENT; $this->clos = Account::STATUS_OPEN; + $this->type = Account::TYPE_CURRENT; + $this->status = Account::STATUS_OPEN; $this->code_banque = '30001'; $this->code_guichet = '00794'; $this->number = '12345678901'; @@ -1945,11 +1950,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; */ class AccountLine extends CommonObjectLine { - /** - * @var string Error code (or message) - */ - public $error = ''; - /** * @var DoliDB Database handler. */ From 4d496209cef7699fb5bafd7a7156ed0cefaeca81 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 7 Apr 2024 15:02:00 +0200 Subject: [PATCH 4/4] Qual: Phan/apstats should not be using the standard baseline (#29267) # Qual: Phan/apstats should not be using the standard baseline Fix to get apstats reporting on the technical debt. The 'baseline.txt' is for the ci regression. The code is changed to allow a 'baseline_extended.txt' which should not be generated, only hand-crafted --- dev/tools/apstats.php | 22 +++++++++++++++------- dev/tools/phan/baseline_extended.txt | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 dev/tools/phan/baseline_extended.txt diff --git a/dev/tools/apstats.php b/dev/tools/apstats.php index 28c21cdcd0e..ca87e1a9b59 100755 --- a/dev/tools/apstats.php +++ b/dev/tools/apstats.php @@ -95,7 +95,15 @@ while ($i < $argc) { $i++; } -if (!is_readable("{$path}phan/config.php")) { + +// Configuration is required, otherwise phan is disabled. +$PHAN_CONFIG = "{$path}phan/config_extended.php"; +// BASELINE is ignored if it does not exist +$PHAN_BASELINE = "{$path}phan/baseline_extended.txt"; +$PHAN_MIN_PHP = "7.0"; +$PHAN_MEMORY_OPT = "--memory-limit 5G"; + +if (!is_readable($PHAN_CONFIG)) { print "Skipping phan - configuration not found\n"; // Disable phan while not integrated yet $dir_phan = 'disabled'; @@ -139,15 +147,15 @@ if ($dirphpstan != 'disabled') { $output_phan_json = array(); $res_exec_phan = 0; if ($dir_phan != 'disabled') { + if (is_readable($PHAN_BASELINE)) { + $PHAN_BASELINE_OPT = "-B '${PHAN_BASELINE}'"; + } else { + $PHAN_BASELINE_OPT = ''; + } // Get technical debt (phan) - $PHAN_CONFIG = "dev/tools/phan/config_extended.php"; - $PHAN_BASELINE = "dev/tools/phan/baseline.txt"; - $PHAN_MIN_PHP = "7.0"; - $PHAN_MEMORY_OPT = "--memory-limit 5G"; - $commandcheck = ($dir_phan ? $dir_phan.DIRECTORY_SEPARATOR : '') - ."phan --output-mode json $PHAN_MEMORY_OPT -k $PHAN_CONFIG -B $PHAN_BASELINE --analyze-twice --minimum-target-php-version $PHAN_MIN_PHP"; + ."phan --output-mode json $PHAN_MEMORY_OPT -k '$PHAN_CONFIG' $PHAN_BASELINE_OPT --analyze-twice --minimum-target-php-version $PHAN_MIN_PHP"; print 'Execute Phan to get the technical debt: '.$commandcheck."\n"; exec($commandcheck, $output_phan_json, $res_exec_phan); } diff --git a/dev/tools/phan/baseline_extended.txt b/dev/tools/phan/baseline_extended.txt new file mode 100644 index 00000000000..bee8eea7ae1 --- /dev/null +++ b/dev/tools/phan/baseline_extended.txt @@ -0,0 +1,22 @@ + [ + 'internal' => ['PhanUndeclaredConstant'], + ], + // 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed. + // (directory_suppressions will currently be ignored by subsequent calls to --save-baseline, but may be preserved in future Phan releases) +];