Skip to content

Commit

Permalink
Qual: Fix phan notices (hrm)
Browse files Browse the repository at this point in the history
# Qual: Fix phan notices (hrm)
  • Loading branch information
mdeweerd committed Feb 3, 2025
1 parent e348ea6 commit 514512d
Show file tree
Hide file tree
Showing 20 changed files with 100 additions and 104 deletions.
34 changes: 12 additions & 22 deletions dev/tools/phan/baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
*/
return [
// # Issue statistics:
// PhanTypeMismatchArgument : 3760+ occurrences
// PhanTypeMismatchArgument : 3730+ occurrences
// PhanUndeclaredProperty : 540+ occurrences
// PhanTypeMismatchArgumentNullable : 460+ occurrences
// PhanTypeMismatchArgumentNullable : 450+ occurrences
// PhanUndeclaredGlobalVariable : 190+ occurrences
// PhanPluginUnknownArrayMethodReturnType : 180+ occurrences
// PhanPossiblyUndeclaredGlobalVariable : 180+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 150+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 140+ occurrences
// PhanTypeMismatchProperty : 130+ occurrences
// PhanPluginUnknownArrayMethodParamType : 110+ occurrences
// PhanRedefineFunction : 45+ occurrences
Expand All @@ -28,11 +28,11 @@ return [
// PhanTypeComparisonFromArray : 10+ occurrences
// PhanUndeclaredMethod : 10+ occurrences
// PhanPluginUnknownObjectMethodCall : 8 occurrences
// PhanEmptyForeach : 7 occurrences
// PhanPluginEmptyStatementIf : 7 occurrences
// PhanPluginSuspiciousParamPosition : 7 occurrences
// PhanPluginDuplicateExpressionBinaryOp : 6 occurrences
// PhanTypeArraySuspiciousNull : 6 occurrences
// PhanEmptyForeach : 5 occurrences
// PhanParamTooMany : 5 occurrences
// PhanPluginBothLiteralsBinaryOp : 4 occurrences
// PhanPluginDuplicateArrayKey : 4 occurrences
Expand Down Expand Up @@ -630,27 +630,17 @@ return [
'htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php' => ['PhanUndeclaredProperty'],
'htdocs/holiday/card_group.php' => ['PhanTypeMismatchArgument'],
'htdocs/holiday/list.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/holiday/month_report.php' => ['PhanTypeMismatchArgument'],
'htdocs/hrm/admin/admin_hrm.php' => ['PhanEmptyForeach'],
'htdocs/hrm/class/establishment.class.php' => ['PhanTypeMismatchArgument'],
'htdocs/hrm/class/evaluation.class.php' => ['PhanUndeclaredProperty'],
'htdocs/hrm/class/evaluationdet.class.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'],
'htdocs/hrm/class/job.class.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'],
'htdocs/hrm/class/position.class.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'],
'htdocs/hrm/class/skill.class.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'],
'htdocs/hrm/class/skilldet.class.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'],
'htdocs/hrm/class/skillrank.class.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'],
'htdocs/hrm/compare.php' => ['PhanTypeMismatchArgument'],
'htdocs/hrm/core/tpl/objectline_view.tpl.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
'htdocs/hrm/establishment/card.php' => ['PhanTypeMismatchArgument'],
'htdocs/hrm/class/evaluationdet.class.php' => ['PhanUndeclaredProperty'],
'htdocs/hrm/class/job.class.php' => ['PhanUndeclaredProperty'],
'htdocs/hrm/class/position.class.php' => ['PhanUndeclaredProperty'],
'htdocs/hrm/class/skill.class.php' => ['PhanUndeclaredProperty'],
'htdocs/hrm/class/skilldet.class.php' => ['PhanUndeclaredProperty'],
'htdocs/hrm/class/skillrank.class.php' => ['PhanUndeclaredProperty'],
'htdocs/hrm/core/tpl/objectline_view.tpl.php' => ['PhanUndeclaredProperty'],
'htdocs/hrm/evaluation_card.php' => ['PhanTypeMismatchArgument'],
'htdocs/hrm/evaluation_list.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/hrm/job_agenda.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullable'],
'htdocs/hrm/job_card.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/hrm/job_list.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/hrm/position_list.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'],
'htdocs/hrm/skill_card.php' => ['PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgument', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
'htdocs/hrm/skill_list.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/hrm/skill_card.php' => ['PhanTypeExpectedObjectPropAccess', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
'htdocs/imports/emptyexample.php' => ['PhanRedefineFunction', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/imports/import.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/index.php' => ['PhanTypeMismatchArgument'],
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/class/html.form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -10434,7 +10434,7 @@ public function showbarcode(&$object, $width = 100, $morecss = '')
* @param string $imagesize 'mini', 'small' or '' (original)
* @param int<0,1> $addlinktofullsize Add link to fullsize image
* @param int<0,1> $cache 1=Accept to use image in cache
* @param string $forcecapture '', 'user' or 'environment'. Force parameter capture on HTML input file element to ask a smartphone to allow to open camera to take photo. Auto if ''.
* @param ''|'user'|'environment' $forcecapture '', 'user' or 'environment'. Force parameter capture on HTML input file element to ask a smartphone to allow to open camera to take photo. Auto if ''.
* @param int<0,1> $noexternsourceoverwrite No overwrite image with extern source (like 'gravatar' or other module)
* @return string HTML code to output photo
* @see getImagePublicURLOfObject()
Expand Down
6 changes: 3 additions & 3 deletions htdocs/core/modules/hrm/mod_evaluation_advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright (C) 2005-2009 Regis Houssin <[email protected]>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <[email protected]>
* Copyright (C) 2019-2024 Frédéric France <[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 All @@ -31,7 +31,7 @@


/**
* Class to manage customer Bom numbering rules advanced
* Class to manage customer evaluation numbering rules advanced
*/
class mod_evaluation_advanced extends ModeleNumRefEvaluation
{
Expand Down Expand Up @@ -125,7 +125,7 @@ public function getExample()
/**
* Return next free value
*
* @param Evaluation $object Object we need next value for
* @param Evaluation|EvaluationLine|Job|Position|Skill|Skilldet|SkillRank $object Object $object Object we need next value for
* @return string|int<-1,0> Value if OK, <=0 if KO
*/
public function getNextValue($object)
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/modules/hrm/mod_evaluation_standard.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* Copyright (C) 2005-2010 Laurent Destailleur <[email protected]>
* Copyright (C) 2005-2009 Regis Houssin <[email protected]>
* Copyright (C) 2024-2025 Frédéric France <[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 @@ -122,7 +122,7 @@ public function canBeActivated($object)
/**
* Return next free value
*
* @param Evaluation $object Object we need next value for
* @param Evaluation|EvaluationLine|Job|Position|Skill|Skilldet|SkillRank $object Object $object Object we need next value for
* @return string|int<-1,0> Value if OK, <=0 if KO
*/
public function getNextValue($object)
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/modules/hrm/modules_evaluation.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright (C) 2006 Andre Cianfarani <[email protected]>
* Copyright (C) 2012 Juanjo Menent <[email protected]>
* Copyright (C) 2014 Marcos García <[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 @@ -86,7 +86,7 @@ abstract class ModeleNumRefEvaluation extends CommonNumRefGenerator
/**
* Return next free value
*
* @param Evaluation $object Object we need next value for
* @param Evaluation|EvaluationLine|Job|Position|Skill|Skilldet|SkillRank $object Object we need next value for
* @return string|int<-1,0> Value if OK, <=0 if KO
*/
abstract public function getNextValue($object);
Expand Down
5 changes: 3 additions & 2 deletions htdocs/hrm/admin/admin_hrm.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2015 Alexandre Spangaro <[email protected]>
* Copyright (C) 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 @@ -70,7 +71,7 @@
if ($action == 'update') {
$error = 0;

foreach ($list as $constname) {
foreach ($list as $constname) { // @phan-suppress-current-line PhanEmptyForeach
$constvalue = GETPOST($constname, 'alpha');

if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
Expand Down Expand Up @@ -117,7 +118,7 @@
print '<td colspan="3">'.$langs->trans('Parameters').'</td>';
print "</tr>\n";

foreach ($list as $key) {
foreach ($list as $key) { // @phan-suppress-current-line PhanEmptyForeach
print '<tr class="oddeven value">';

// Param
Expand Down
4 changes: 2 additions & 2 deletions htdocs/hrm/class/establishment.class.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2015 Alexandre Spangaro <[email protected]>
* Copyright (C) 2018-2024 Frédéric France <[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 @@ -227,7 +227,7 @@ public function create($user)
} else {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'establishment');

$sql = 'UPDATE '.MAIN_DB_PREFIX."establishment SET ref = '".$this->db->escape($this->id)."'";
$sql = 'UPDATE '.MAIN_DB_PREFIX."establishment SET ref = '".$this->db->escape((string) $this->id)."'";
$sql .= " WHERE rowid = ".((int) $this->id);
$this->db->query($sql);

Expand Down
4 changes: 2 additions & 2 deletions htdocs/hrm/class/evaluation.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Copyright (C) 2021 Jean-Pascal BOUDET <[email protected]>
* Copyright (C) 2021 Grégory BLEMAND <[email protected]>
* Copyright (C) 2024 Frédéric France <[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 @@ -1057,7 +1057,7 @@ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hided
* Return clickable link of object (with eventually picto)
*
* @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link)
* @param array{string,mixed} $arraydata Array of data
* @param ?array<string,mixed> $arraydata Array of data
* @return string HTML Code for Kanban thumb.
*/
public function getKanbanView($option = '', $arraydata = null)
Expand Down
4 changes: 2 additions & 2 deletions htdocs/hrm/class/job.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Copyright (C) 2021 Jean-Pascal BOUDET <[email protected]>
* Copyright (C) 2021 Grégory BLEMAND <[email protected]>
* Copyright (C) 2024 Frédéric France <[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 @@ -1046,7 +1046,7 @@ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hided
* Return clickable link of object (with eventually picto)
*
* @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link)
* @param array{string,mixed} $arraydata Array of data
* @param ?array<string,mixed> $arraydata Array of data
* @return string HTML Code for Kanban thumb.
*/
public function getKanbanView($option = '', $arraydata = null)
Expand Down
4 changes: 2 additions & 2 deletions htdocs/hrm/class/position.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Copyright (C) 2021 Jean-Pascal BOUDET <[email protected]>
* Copyright (C) 2021 Grégory BLEMAND <[email protected]>
* Copyright (C) 2024 Frédéric France <[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 @@ -1119,7 +1119,7 @@ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hided
* Return clickable link of object (with eventually picto)
*
* @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link)
* @param array{string,mixed} $arraydata Array of data
* @param ?array<string,mixed> $arraydata Array of data
* @return string HTML Code for Kanban thumb.
*/
public function getKanbanView($option = '', $arraydata = null)
Expand Down
4 changes: 2 additions & 2 deletions htdocs/hrm/class/skill.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Copyright (C) 2021 Jean-Pascal BOUDET <[email protected]>
* Copyright (C) 2021 Grégory BLEMAND <[email protected]>
* Copyright (C) 2024 Frédéric France <[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 @@ -1123,7 +1123,7 @@ public static function typeCodeToLabel($code)
* Return clickable link of object (with eventually picto)
*
* @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link)
* @param array{string,mixed} $arraydata Array of data
* @param ?array<string,mixed> $arraydata Array of data
* @return string HTML Code for Kanban thumb.
*/
public function getKanbanView($option = '', $arraydata = null)
Expand Down
6 changes: 2 additions & 4 deletions htdocs/hrm/compare.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Copyright (C) 2021 Jean-Pascal BOUDET <[email protected]>
* Copyright (C) 2021 Grégory BLEMAND <[email protected]>
* Copyright (C) 2024 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 @@ -295,7 +295,6 @@


/**
*
* Return a html list element with diff between required rank and user rank
*
* @param array<int,stdClass> $TMergedSkills skill list with all rate to add good picto
Expand Down Expand Up @@ -496,7 +495,7 @@ function displayUsersListWithPicto(&$TUser, $fk_usergroup = 0, $namelist = 'list
}

$out .= '<li fk_user="' . $user->id . '" class="' . $class . '">
' . $form->showphoto('userphoto', $user, 0, 0, 0, 'photoref', 'small', 1, 0, 1) . '
' . $form->showphoto('userphoto', $user, 0, 0, 0, 'photoref', 'small', 1, 0, '', 1) . '
<h3>' . $name . '</h3>
<p>' . $desc . '</p>
</li>';
Expand All @@ -510,7 +509,6 @@ function displayUsersListWithPicto(&$TUser, $fk_usergroup = 0, $namelist = 'list


/**
*
* Allow to get skill(s) of a user
*
* @param int[] $TUser array of employees we need to get skills
Expand Down
3 changes: 2 additions & 1 deletion htdocs/hrm/core/tpl/objectline_view.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<?php } ?>
<td class="linecollabel"><?php $coldisplay++; ?><div id="line_<?php print $line->id; ?>"></div>
<?php
$skill = null;
$resSkill = 0;
if ($line->fk_skill > 0) {
$skill = new Skill($this->db);
Expand All @@ -84,7 +85,7 @@
</td>
<td>
<?php
if ($line->fk_skill > 0) {
if ($line->fk_skill > 0 && $skill !== null) {
print $skill->getNomUrl(1);
}
?>
Expand Down
9 changes: 5 additions & 4 deletions htdocs/hrm/establishment/card.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2015 Alexandre Spangaro <[email protected]>
* Copyright (C) 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 @@ -49,8 +50,8 @@

// List of status
static $tmpstatus2label = array(
'0'=>'CloseEtablishment',
'1'=>'OpenEtablishment'
'0' => 'CloseEtablishment',
'1' => 'OpenEtablishment'
);
$status2label = array('');
foreach ($tmpstatus2label as $key => $val) {
Expand Down Expand Up @@ -242,7 +243,7 @@
print '<tr>';
print '<td>'.$form->editfieldkey('Country', 'selectcountry_id', '', $object, 0).'</td>';
print '<td class="maxwidthonsmartphone">';
print $form->select_country(GETPOSTISSET('country_id') ? GETPOSTINT('country_id') : ($object->country_id ? $object->country_id : $mysoc->country_id), 'country_id');
print $form->select_country((string) (GETPOSTISSET('country_id') ? GETPOSTINT('country_id') : ($object->country_id ? $object->country_id : $mysoc->country_id)), 'country_id');
if ($user->admin) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
Expand Down Expand Up @@ -326,7 +327,7 @@
// Country
print '<tr><td>'.$form->editfieldkey('Country', 'selectcountry_id', '', $object, 0).'</td>';
print '<td class="maxwidthonsmartphone">';
print $form->select_country($object->country_id, 'country_id');
print $form->select_country((string) $object->country_id, 'country_id');
if ($user->admin) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
Expand Down
Loading

0 comments on commit 514512d

Please sign in to comment.