diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 400ab4fe833..1b89107308a 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -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'], @@ -114,7 +113,7 @@ return [ 'htdocs/comm/action/list.php' => ['PhanTypeMismatchProperty'], 'htdocs/comm/action/pertype.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanTypeComparisonFromArray', 'PhanTypeMismatchDimFetch'], 'htdocs/comm/action/peruser.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanTypeComparisonFromArray'], - 'htdocs/comm/mailing/card.php' => ['PhanPluginSuspiciousParamPosition', 'PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/comm/mailing/card.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/comm/mailing/cibles.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], 'htdocs/comm/mailing/class/advtargetemailing.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayPropertyType'], 'htdocs/comm/mailing/class/html.formadvtargetemailing.class.php' => ['PhanPluginUnknownArrayMethodParamType'], @@ -304,7 +303,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'], diff --git a/htdocs/bookcal/booking_list.php b/htdocs/bookcal/booking_list.php index 29fd7c9d005..f00e0303550 100644 --- a/htdocs/bookcal/booking_list.php +++ b/htdocs/bookcal/booking_list.php @@ -95,7 +95,7 @@ if (!$permissiontoread) { * 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) { diff --git a/htdocs/core/class/commonhookactions.class.php b/htdocs/core/class/commonhookactions.class.php index a6fd27afe7c..8b5067f03cf 100644 --- a/htdocs/core/class/commonhookactions.class.php +++ b/htdocs/core/class/commonhookactions.class.php @@ -38,6 +38,16 @@ abstract class CommonHookActions */ public $results = array(); + /** + * @var string + */ + public $error; + + /** + * @var string[] + */ + public $errors = array(); + /** * Check context of hook * @param array $parameters Hook parameters. diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 8b5c9a10bb8..620cd067b50 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -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>|string[] */ 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>|string[] + */ public $withtocc; + /** + * @var int<0,1>|string|string[] When 1|'1', enable BCC field, when not 0, use as default BCC email + */ public $withtoccc; + /** + * @var int<0,1>|string + */ 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,2>|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; @@ -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>|string + */ 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<-1,1> + */ public $withfckeditor; /** @@ -177,19 +240,36 @@ class FormMail extends Form */ public $ckeditortoolbar; + /** + * @var array + */ public $substit = array(); + /** + * @var string[] + */ public $substit_lines = array(); /** * @var array{}|array{models:string,langsmodels?:string,fileinit?:string[],returnurl:string} */ public $param = array(); + /** + * @var string[] + */ public $withtouser = array(); + /** + * @var string[] + */ 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; @@ -208,7 +288,7 @@ class FormMail extends Form $this->withto = 1; $this->withtofree = 1; $this->withtocc = 1; - $this->withtoccc = 0; + $this->withtoccc = '0'; $this->witherrorsto = 0; $this->withtopic = 1; $this->withfile = 0; // 1=Add section "Attached files". 2=Can add files. @@ -732,7 +812,7 @@ class FormMail extends Form 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 .= "\n"; } @@ -781,7 +861,7 @@ class FormMail extends Form 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 .= "\n"; } @@ -879,9 +959,9 @@ class FormMail extends Form } $out .= '
'; } - } elseif (empty($this->withmaindocfile)) { + } /*elseif (empty($this->withmaindocfile)) { //$out .= ''.$langs->trans("NoAttachedFiles").'
'; - } + }*/ if ($this->withfile == 2) { $maxfilesizearray = getMaxFileSizeArray(); $maxmin = $maxfilesizearray['maxmin']; @@ -917,7 +997,7 @@ class FormMail extends Form // Complete substitution array with the url to make online payment $validpaymentmethod = array(); - if (empty($this->substit['__REF__'])) { + if (empty($this->substit['__REF__'])) { // @phan-suppress-current-line PhanTypeMismatchProperty $paymenturl = ''; } else { // Set the online payment url link into __ONLINE_PAYMENT_URL__ key @@ -1168,7 +1248,7 @@ class FormMail extends Form } } - $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 .= "\n"; @@ -1216,7 +1296,7 @@ class FormMail extends Form $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 .= "\n"; @@ -1265,7 +1345,7 @@ class FormMail extends Form $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); } } @@ -1971,7 +2051,7 @@ class FormMail extends Form } } } - $this->substit_lines[] = $substit_line; + $this->substit_lines[] = $substit_line; // @phan-suppress-current-line PhanTypeMismatchProperty } } } @@ -1981,8 +2061,8 @@ class FormMail extends Form * 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 Array of substitution values for emails. */ public static function getAvailableSubstitKey($mode = 'formemail', $object = null) { @@ -2119,34 +2199,55 @@ class ModelMail extends CommonObject * @var array|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,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; /** @@ -2178,13 +2279,35 @@ class ModelMail extends CommonObject * @var string Model mail content */ public $content; + /** + * @var string + */ public $content_lines; + + /** + * @var string + */ public $lang; + /** + * @var int<0,1> + */ public $joinfiles; + /** + * @var string + */ public $email_from; + /** + * @var string + */ public $email_to; + /** + * @var string + */ public $email_tocc; + /** + * @var string + */ public $email_tobcc; /** diff --git a/phpstan.neon.dist b/phpstan.neon.dist index c31b481b3c8..294aff64943 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -119,6 +119,7 @@ parameters: - '# (?:Common(?:DocGenerator::get(?:(?:ExtrafieldsInHtml|_substitutionarray_lines)\(\))|Object::printO(?:(?:bject|rigin)Line\(\)))) expects CommonObjectLine#' - '#colorHexToHsl expects float\|false, true#' - '#function dolGetButtonAction expects array\{confirm\?: array.*confirm: true} given.#' + - '#(?:make_substitutions expects array,) string given\.#' internalErrorsCountLimit: 50 cache: