Skip to content

Commit

Permalink
Merge pull request #32901 from mdeweerd/qual/phan.2025.1.31
Browse files Browse the repository at this point in the history
Qual: Fix notices, update baseline, enable PhanTypeMismatchArgument
  • Loading branch information
eldy authored Feb 4, 2025
2 parents 1bd28eb + f750f2c commit 52bbbcd
Show file tree
Hide file tree
Showing 44 changed files with 1,225 additions and 673 deletions.
1,089 changes: 806 additions & 283 deletions dev/tools/phan/baseline.txt

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dev/tools/phan/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
'linkedObjectBlock' => '\CommonObject[]', // See htdocs/core/class/html.form.class.php
'mainmenu' => 'string',
'menumanager' => '\MenuManager',
'mysoc' => '?\Societe',
'mysoc' => '\Societe',
'nblines' => '\int',
'objectoffield' => '\CommonObject',
'objsoc' => '\Societe',
Expand Down Expand Up @@ -440,7 +440,7 @@

'PhanPluginNonBoolBranch', // Not essential - 31240+ occurrences
'PhanPluginNumericalComparison', // Not essential - 19870+ occurrences
'PhanTypeMismatchArgument', // Also reported by phpstan < lvl6 - 12300+ occurrences
// 'PhanTypeMismatchArgument', // Can detect missing array keys, invalid types, objects being passed when scalar expected - Not all reported by phpstan - <=3800 cases (was: 12300+ before)
'PhanPluginNonBoolInLogicalArith', // Not essential - 11040+ occurrences
'PhanPluginConstantVariableScalar', // Not essential - 5180+ occurrences
'PhanPluginDuplicateAdjacentStatement',
Expand Down
2 changes: 1 addition & 1 deletion dev/tools/phan/config_extended.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@

'PhanPluginNonBoolBranch', // Not essential - 31240+ occurrences
'PhanPluginNumericalComparison', // Not essential - 19870+ occurrences
'PhanTypeMismatchArgument', // Not essential - 12300+ occurrences
'PhanTypeMismatchArgument', // Not showing in cti.dolibarr until low count - Can detect missing array keys, invalid types, objects being passed when scalar expected - Not all reported by phpstan - <=3800 cases (was: 12300+ before)
'PhanPluginNonBoolInLogicalArith', // Not essential - 11040+ occurrences
'PhanPluginConstantVariableScalar', // Not essential - 5180+ occurrences
'PhanPluginDuplicateAdjacentStatement',
Expand Down
8 changes: 4 additions & 4 deletions htdocs/adherents/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Copyright (C) 2015-2024 Alexandre Spangaro <[email protected]>
* Copyright (C) 2018-2024 Frédéric France <[email protected]>
* Copyright (C) 2021 Waël Almoman <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024-2025 MDW <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -1563,14 +1563,14 @@ function initfieldrequired() {
$fullname = $object->getFullName($langs);

if ($object->morphy == 'mor') {
$companyname = $object->company;
$companyname = (string) $object->company;
if (!empty($fullname)) {
$companyalias = $fullname;
$companyalias = (string) $fullname;
}
} else {
$companyname = $fullname;
if (!empty($object->company)) {
$companyalias = $object->company;
$companyalias = (string) $object->company;
}
}

Expand Down
5 changes: 3 additions & 2 deletions htdocs/bom/bom_net_needs.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2017-2020 Laurent Destailleur <[email protected]>
* Copyright (C) 2019-2024 Frédéric France <[email protected]>
* Copyright (C) 2025 MDW <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -135,7 +136,7 @@
$formfile = new FormFile($db);

$title = $langs->trans('BOM');
$help_url ='EN:Module_BOM';
$help_url = 'EN:Module_BOM';

llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-bom page-net_needs');

Expand Down Expand Up @@ -330,7 +331,7 @@
if ($useunit) {
require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php';
$unit = new CUnits($db);
$unit->fetch($elem['fk_unit']);
$unit->fetch((int) $elem['fk_unit']);
print(isset($unit->label) ? "&nbsp;".$langs->trans(ucwords($unit->label))."&nbsp;" : '');
}
print '</td>';
Expand Down
4 changes: 2 additions & 2 deletions htdocs/compta/bank/various_payment/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (C) 2018-2025 Frédéric France <[email protected]>
* Copyright (C) 2023 Laurent Destailleur <[email protected]>
* Copyright (C) 2023 Joachim Kueter <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024-2025 MDW <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -597,7 +597,7 @@ function setPaymentType()
array('type' => 'date', 'name' => 'clone_date_value', 'label' => $langs->trans("DateValue"), 'value' => -1),
array('type' => 'other', 'tdclass' => 'fieldrequired', 'name' => 'clone_accountid', 'label' => $langs->trans("BankAccount"), 'value' => $form->select_comptes($object->fk_account, "accountid", 0, '', 1, '', 0, 'minwidth200', 1)),
array('type' => 'text', 'name' => 'clone_amount', 'label' => $langs->trans("Amount"), 'value' => price($object->amount)),
array('type' => 'select', 'name' => 'clone_sens', 'label' => $langs->trans("Sens").' '.$set_value_help, 'values' => $sensarray, 'default' => $object->sens),
array('type' => 'select', 'name' => 'clone_sens', 'label' => $langs->trans("Sens").' '.$set_value_help, 'values' => $sensarray, 'default' => (string) $object->sens),
);

print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneVariousPayment', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 350);
Expand Down
10 changes: 5 additions & 5 deletions htdocs/compta/facture/class/facture-rec.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class FactureRec extends CommonInvoice
public $user_author;

/**
* @var int Frequency
* @var ?int Frequency
*/
public $frequency;

Expand Down Expand Up @@ -1945,10 +1945,10 @@ public static function replaceProduct(DoliDB $dbs, $origin_id, $dest_id)
/**
* Update frequency and unit
*
* @param int $frequency value of frequency
* @param string $unit unit of frequency (d, m, y)
* @param int $notrigger Disable the trigger
* @return int Return integer <0 if KO, >0 if OK
* @param ?int $frequency value of frequency
* @param string $unit unit of frequency (d, m, y)
* @param int<0,1> $notrigger Disable the trigger
* @return int Return integer <0 if KO, >0 if OK
*/
public function setFrequencyAndUnit($frequency, $unit, $notrigger = 0)
{
Expand Down
6 changes: 3 additions & 3 deletions htdocs/core/class/commoninvoice.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright (C) 2012-2014 Raphaël Doursenaud <[email protected]>
* Copyright (C) 2023 Nick Fragoulis
* Copyright (C) 2024-2025 Frédéric France <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024-2025 MDW <[email protected]>
* Copyright (C) 2024 Alexandre Spangaro <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -1984,7 +1984,7 @@ public function buildSwitzerlandQRString()
$s .= dol_trunc($mysoc->country_code, 2, 'right', 'UTF-8', 1)."\n";*/
} else {
$s .= "S\n";
$s .= dol_trunc($mysoc->name, 70, 'right', 'UTF-8', 1)."\n";
$s .= dol_trunc((string) $mysoc->name, 70, 'right', 'UTF-8', 1)."\n";
$addresslinearray = explode("\n", $mysoc->address);
$s .= dol_trunc(empty($addresslinearray[1]) ? '' : $addresslinearray[1], 70, 'right', 'UTF-8', 1)."\n"; // address line 1
$s .= dol_trunc(empty($addresslinearray[2]) ? '' : $addresslinearray[2], 70, 'right', 'UTF-8', 1)."\n"; // address line 2
Expand All @@ -2005,7 +2005,7 @@ public function buildSwitzerlandQRString()
$s .= ($this->multicurrency_code ? $this->multicurrency_code : $conf->currency)."\n";
// Buyer
$s .= "S\n";
$s .= dol_trunc($this->thirdparty->name, 70, 'right', 'UTF-8', 1)."\n";
$s .= dol_trunc((string) $this->thirdparty->name, 70, 'right', 'UTF-8', 1)."\n";
$addresslinearray = explode("\n", $this->thirdparty->address);
$s .= dol_trunc(empty($addresslinearray[1]) ? '' : $addresslinearray[1], 70, 'right', 'UTF-8', 1)."\n"; // address line 1
$s .= dol_trunc(empty($addresslinearray[2]) ? '' : $addresslinearray[2], 70, 'right', 'UTF-8', 1)."\n"; // address line 2
Expand Down
Loading

0 comments on commit 52bbbcd

Please sign in to comment.