Skip to content

Commit

Permalink
Qual: fix phan notices
Browse files Browse the repository at this point in the history
# Qual: fix phan notices

Fix phan/phpstan notices, mostly in html,formmail
  • Loading branch information
mdeweerd committed Oct 12, 2024
1 parent 307b136 commit 14013ae
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 39 deletions.
3 changes: 1 addition & 2 deletions dev/tools/phan/baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ return [
'htdocs/bom/tpl/objectline_view.tpl.php' => ['PhanUndeclaredProperty'],
'htdocs/bookcal/availabilities_card.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
'htdocs/bookcal/availabilities_list.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/bookcal/booking_list.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/bookcal/calendar_card.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
'htdocs/bookcal/calendar_list.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/bookcal/class/availabilities.class.php' => ['PhanUndeclaredMethod', 'PhanUndeclaredProperty'],
Expand Down Expand Up @@ -311,7 +310,7 @@ return [
'htdocs/core/class/html.formcompany.class.php' => ['PhanUndeclaredProperty'],
'htdocs/core/class/html.formfile.class.php' => ['PhanPluginConstantVariableNull', 'PhanPluginUnknownArrayMethodParamType', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/core/class/html.formldap.class.php' => ['PhanPluginUnknownArrayMethodParamType'],
'htdocs/core/class/html.formmail.class.php' => ['PhanPluginEmptyStatementIf', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/core/class/html.formmail.class.php' => ['PhanUndeclaredProperty'],
'htdocs/core/class/html.formmargin.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanUndeclaredProperty'],
'htdocs/core/class/html.formprojet.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/core/class/html.formsetup.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayPropertyType'],
Expand Down
2 changes: 1 addition & 1 deletion htdocs/bookcal/booking_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
* Actions
*/

$parameters = '';
$parameters = array();
$helpurl = '';
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
Expand Down
183 changes: 147 additions & 36 deletions htdocs/core/class/html.formmail.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,33 +117,54 @@ class FormMail extends Form
*/
public $inreplyto;

/**
* @var int<0,1>
*/
public $withsubstit; // Show substitution array
/**
* @var int<0,1>
*/
public $withfrom;

/**
* @var int|string|array
* @var int<0,1>
*/
public $withto; // Show recipient emails
/**
* @var int<0,1>
*/
public $withreplyto;

/**
* @var int|string 0 = Do not Show free text for recipient emails
* @var int<0,1>|string 0 = Do not Show free text for recipient emails
* 1 = Show free text for recipient emails
* or a free email
*/
public $withtofree;
/**
* @var int<0,1>
*/
public $withtocc;
/**
* @var int<0,1>
*/
public $withtoccc;
/**
* @var int<0,1>
*/
public $withtopic;
/**
* @var int<0,1>
*/
public $witherrorsto;

/**
* @var int|string 0=No attaches files, 1=Show attached files, 2=Can add new attached files, 'text'=Show attached files and the text
* @var int<0,1>|string 0=No attaches files, 1=Show attached files, 2=Can add new attached files, 'text'=Show attached files and the text
*/
public $withfile;

/**
* @var int 1=Add a button "Fill with layout"
* @var int<0,1> 1=Add a button "Fill with layout"
*/
public $withlayout;

Expand All @@ -153,23 +174,65 @@ class FormMail extends Form
public $withaiprompt;

/**
* @var int 1=Add a checkbox "Attach also main document" for mass actions (checked by default), -1=Add checkbox (not checked by default)
* @var int<-1,1> 1=Add a checkbox "Attach also main document" for mass actions (checked by default), -1=Add checkbox (not checked by default)
*/
public $withmaindocfile;
/**
* @var int<0,1>
*/
public $withbody;

/**
* @var int<0,1>
*/
public $withfromreadonly;
/**
* @var int<0,1>
*/
public $withreplytoreadonly;
/**
* @var int<0,1>
*/
public $withtoreadonly;
/**
* @var int<0,1>
*/
public $withtoccreadonly;
/**
* @var int<0,1>
*/
public $witherrorstoreadonly;
/**
* @var int<0,1>
*/
public $withtocccreadonly;
/**
* @var int<0,1>
*/
public $withtopicreadonly;
/**
* @var int<0,1>
*/
public $withbodyreadonly;
/**
* @var int<0,1>
*/
public $withfilereadonly;
/**
* @var int<0,1>
*/
public $withdeliveryreceipt;
/**
* @var int<0,1>
*/
public $withcancel;
/**
* @var int<0,1>
*/
public $withdeliveryreceiptreadonly;
/**
* @var int<0,1>
*/
public $withfckeditor;

/**
Expand All @@ -187,9 +250,14 @@ class FormMail extends Form
public $withtouser = array();
public $withtoccuser = array();

/**
* @var ModelMail[]
*/
public $lines_model;

// -1 suggest the checkbox 'one email per recipient' not checked, 0 = no suggestion, 1 = suggest and checked
/**
* @var int<-1,1> -1 suggests the checkbox 'one email per recipient' not checked, 0 = no suggestion, 1 = suggest and checked
*/
public $withoptiononeemailperrecipient;


Expand Down Expand Up @@ -732,7 +800,7 @@ public function get_form($addfileaction = 'addfile', $removefileaction = 'remove
if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') {
$withtoselected = array_keys($tmparray);
}
$out .= $form->multiselectarray("receiveruser", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, "");
$out .= $form->multiselectarray("receiveruser", $tmparray, $withtoselected, 0, 0, 'inline-block minwidth500', 0, "");
$out .= "</td></tr>\n";
}

Expand Down Expand Up @@ -781,7 +849,7 @@ public function get_form($addfileaction = 'addfile', $removefileaction = 'remove
if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') {
$withtoselected = array_keys($tmparray);
}
$out .= $form->multiselectarray("receiverccuser", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, "");
$out .= $form->multiselectarray("receiverccuser", $tmparray, $withtoselected, 0, 0, 'inline-block minwidth500', 0, "");
$out .= "</td></tr>\n";
}

Expand Down Expand Up @@ -879,9 +947,9 @@ public function get_form($addfileaction = 'addfile', $removefileaction = 'remove
}
$out .= '<br></div>';
}
} elseif (empty($this->withmaindocfile)) {
} /*elseif (empty($this->withmaindocfile)) {
//$out .= '<span class="opacitymedium">'.$langs->trans("NoAttachedFiles").'</span><br>';
}
}*/
if ($this->withfile == 2) {
$maxfilesizearray = getMaxFileSizeArray();
$maxmin = $maxfilesizearray['maxmin'];
Expand Down Expand Up @@ -1168,7 +1236,7 @@ public function getHtmlForTo()
}
}

$out .= $form->multiselectarray("receiver", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', 0, 0);
$out .= $form->multiselectarray("receiver", $tmparray, $withtoselected, 0, 0, 'inline-block minwidth500', 0, 0);
}
}
$out .= "</td></tr>\n";
Expand Down Expand Up @@ -1216,7 +1284,7 @@ public function getHtmlForCc()

$withtoccselected = GETPOST("receivercc", 'array'); // Array of selected value

$out .= $form->multiselectarray("receivercc", $tmparray, $withtoccselected, null, null, 'inline-block minwidth500', 0, 0);
$out .= $form->multiselectarray("receivercc", $tmparray, $withtoccselected, 0, 0, 'inline-block minwidth500', 0, 0);
}
}
$out .= "</td></tr>\n";
Expand Down Expand Up @@ -1265,7 +1333,7 @@ public function getHtmlForWithCcc()

$withtocccselected = GETPOST("receiverccc", 'array'); // Array of selected value

$out .= $form->multiselectarray("receiverccc", $tmparray, $withtocccselected, null, null, 'inline-block minwidth500', 0, 0);
$out .= $form->multiselectarray("receiverccc", $tmparray, $withtocccselected, 0, 0, 'inline-block minwidth500', 0, 0);
}
}

Expand Down Expand Up @@ -1981,8 +2049,8 @@ public function setSubstitFromObject($object, $outputlangs)
* This include the complete_substitutions_array.
*
* @param string $mode 'formemail', 'formemailwithlines', 'formemailforlines', 'emailing', ...
* @param Object $object Object if applicable
* @return array Array of substitution values for emails.
* @param ?Object $object Object if applicable
* @return array<string,string> Array of substitution values for emails.
*/
public static function getAvailableSubstitKey($mode = 'formemail', $object = null)
{
Expand Down Expand Up @@ -2119,34 +2187,55 @@ class ModelMail extends CommonObject
* @var array<string,array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int<-2,5>|string,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array<int|string,string>,comment?:string,validate?:int<0,1>}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
*/
public $fields = array(
"rowid" => array("type" => "integer", "label" => "TechnicalID", "enabled" => "1", 'position' => 10, 'notnull' => 1, "visible" => "-1",),
"module" => array("type" => "varchar(32)", "label" => "Module", "enabled" => "1", 'position' => 20, 'notnull' => 0, "visible" => "-1",),
"type_template" => array("type" => "varchar(32)", "label" => "Typetemplate", "enabled" => "1", 'position' => 25, 'notnull' => 0, "visible" => "-1",),
"lang" => array("type" => "varchar(6)", "label" => "Lang", "enabled" => "1", 'position' => 30, 'notnull' => 0, "visible" => "-1",),
"private" => array("type" => "smallint(6)", "label" => "Private", "enabled" => "1", 'position' => 35, 'notnull' => 1, "visible" => "-1",),
"fk_user" => array("type" => "integer:User:user/class/user.class.php", "label" => "Fkuser", "enabled" => "1", 'position' => 40, 'notnull' => 0, "visible" => "-1", "css" => "maxwidth500 widthcentpercentminusxx", "csslist" => "tdoverflowmax150",),
"datec" => array("type" => "datetime", "label" => "DateCreation", "enabled" => "1", 'position' => 45, 'notnull' => 0, "visible" => "-1",),
"tms" => array("type" => "timestamp", "label" => "DateModification", "enabled" => "1", 'position' => 50, 'notnull' => 1, "visible" => "-1",),
"label" => array("type" => "varchar(255)", "label" => "Label", "enabled" => "1", 'position' => 55, 'notnull' => 0, "visible" => "-1", "alwayseditable" => "1", "css" => "minwidth300", "cssview" => "wordbreak", "csslist" => "tdoverflowmax150",),
"position" => array("type" => "smallint(6)", "label" => "Position", "enabled" => "1", 'position' => 60, 'notnull' => 0, "visible" => "-1", "alwayseditable" => "1",),
"active" => array("type" => "integer", "label" => "Active", "enabled" => "1", 'position' => 65, 'notnull' => 1, "visible" => "-1", "alwayseditable" => "1",),
"topic" => array("type" => "text", "label" => "Topic", "enabled" => "1", 'position' => 70, 'notnull' => 0, "visible" => "-1", "alwayseditable" => "1",),
"content" => array("type" => "mediumtext", "label" => "Content", "enabled" => "1", 'position' => 75, 'notnull' => 0, "visible" => "-1", "alwayseditable" => "1",),
"content_lines" => array("type" => "text", "label" => "Contentlines", "enabled" => "1", 'position' => 80, 'notnull' => 0, "visible" => "-1", "alwayseditable" => "1",),
"enabled" => array("type" => "varchar(255)", "label" => "Enabled", "enabled" => "1", 'position' => 85, 'notnull' => 0, "visible" => "-1", "alwayseditable" => "1",),
"joinfiles" => array("type" => "varchar(255)", "label" => "Joinfiles", "enabled" => "1", 'position' => 90, 'notnull' => 0, "visible" => "-1", "alwayseditable" => "1",),
"email_from" => array("type" => "varchar(255)", "label" => "Emailfrom", "enabled" => "1", 'position' => 95, 'notnull' => 0, "visible" => "-1", "alwayseditable" => "1",),
"email_to" => array("type" => "varchar(255)", "label" => "Emailto", "enabled" => "1", 'position' => 100, 'notnull' => 0, "visible" => "-1", "alwayseditable" => "1",),
"email_tocc" => array("type" => "varchar(255)", "label" => "Emailtocc", "enabled" => "1", 'position' => 105, 'notnull' => 0, "visible" => "-1", "alwayseditable" => "1",),
"email_tobcc" => array("type" => "varchar(255)", "label" => "Emailtobcc", "enabled" => "1", 'position' => 110, 'notnull' => 0, "visible" => "-1", "alwayseditable" => "1",),
"defaultfortype" => array("type" => "smallint(6)", "label" => "Defaultfortype", "enabled" => "1", 'position' => 115, 'notnull' => 0, "visible" => "-1", "alwayseditable" => "1",),
"rowid" => array("type" => "integer", "label" => "TechnicalID", "enabled" => 1, 'position' => 10, 'notnull' => 1, "visible" => -1,),
"module" => array("type" => "varchar(32)", "label" => "Module", "enabled" => 1, 'position' => 20, 'notnull' => 0, "visible" => -1,),
"type_template" => array("type" => "varchar(32)", "label" => "Typetemplate", "enabled" => 1, 'position' => 25, 'notnull' => 0, "visible" => -1,),
"lang" => array("type" => "varchar(6)", "label" => "Lang", "enabled" => 1, 'position' => 30, 'notnull' => 0, "visible" => -1,),
"private" => array("type" => "smallint(6)", "label" => "Private", "enabled" => 1, 'position' => 35, 'notnull' => 1, "visible" => -1,),
"fk_user" => array("type" => "integer:User:user/class/user.class.php", "label" => "Fkuser", "enabled" => 1, 'position' => 40, 'notnull' => 0, "visible" => -1, "css" => "maxwidth500 widthcentpercentminusxx", "csslist" => "tdoverflowmax150",),
"datec" => array("type" => "datetime", "label" => "DateCreation", "enabled" => 1, 'position' => 45, 'notnull' => 0, "visible" => -1,),
"tms" => array("type" => "timestamp", "label" => "DateModification", "enabled" => 1, 'position' => 50, 'notnull' => 1, "visible" => -1,),
"label" => array("type" => "varchar(255)", "label" => "Label", "enabled" => 1, 'position' => 55, 'notnull' => 0, "visible" => -1, "alwayseditable" => 1, "css" => "minwidth300", "cssview" => "wordbreak", "csslist" => "tdoverflowmax150",),
"position" => array("type" => "smallint(6)", "label" => "Position", "enabled" => 1, 'position' => 60, 'notnull' => 0, "visible" => -1, "alwayseditable" => 1,),
"active" => array("type" => "integer", "label" => "Active", "enabled" => 1, 'position' => 65, 'notnull' => 1, "visible" => -1, "alwayseditable" => 1,),
"topic" => array("type" => "text", "label" => "Topic", "enabled" => 1, 'position' => 70, 'notnull' => 0, "visible" => -1, "alwayseditable" => 1,),
"content" => array("type" => "mediumtext", "label" => "Content", "enabled" => 1, 'position' => 75, 'notnull' => 0, "visible" => -1, "alwayseditable" => 1,),
"content_lines" => array("type" => "text", "label" => "Contentlines", "enabled" => 1, 'position' => 80, 'notnull' => 0, "visible" => -1, "alwayseditable" => 1,),
"enabled" => array("type" => "varchar(255)", "label" => "Enabled", "enabled" => 1, 'position' => 85, 'notnull' => 0, "visible" => -1, "alwayseditable" => 1,),
"joinfiles" => array("type" => "varchar(255)", "label" => "Joinfiles", "enabled" => 1, 'position' => 90, 'notnull' => 0, "visible" => -1, "alwayseditable" => 1,),
"email_from" => array("type" => "varchar(255)", "label" => "Emailfrom", "enabled" => 1, 'position' => 95, 'notnull' => 0, "visible" => -1, "alwayseditable" => 1,),
"email_to" => array("type" => "varchar(255)", "label" => "Emailto", "enabled" => 1, 'position' => 100, 'notnull' => 0, "visible" => -1, "alwayseditable" => 1,),
"email_tocc" => array("type" => "varchar(255)", "label" => "Emailtocc", "enabled" => 1, 'position' => 105, 'notnull' => 0, "visible" => -1, "alwayseditable" => 1,),
"email_tobcc" => array("type" => "varchar(255)", "label" => "Emailtobcc", "enabled" => 1, 'position' => 110, 'notnull' => 0, "visible" => -1, "alwayseditable" => 1,),
"defaultfortype" => array("type" => "smallint(6)", "label" => "Defaultfortype", "enabled" => 1, 'position' => 115, 'notnull' => 0, "visible" => -1, "alwayseditable" => 1,),
);
/**
* @var int
*/
public $rowid;
/**
* @var string
*/
public $type_template;
/**
* @var int|string
*/
public $datec;
/**
* @var int
*/
public $tms;
/**
* @var int
*/
public $active;
/**
* @var string
*/
public $enabled;
/**
* @var int
*/
public $defaultfortype;

/**
Expand Down Expand Up @@ -2178,13 +2267,35 @@ class ModelMail extends CommonObject
* @var string Model mail content
*/
public $content;
/**
* @var string
*/
public $content_lines;

/**
* @var string
*/
public $lang;
/**
* @var inst<0,1>
*/
public $joinfiles;

/**
* @var string
*/
public $email_from;
/**
* @var string
*/
public $email_to;
/**
* @var string
*/
public $email_tocc;
/**
* @var string
*/
public $email_tobcc;

/**
Expand Down

0 comments on commit 14013ae

Please sign in to comment.